More algorithm trace logging.
This commit is contained in:
parent
779d2776a0
commit
cdeee2576d
@ -78,7 +78,11 @@ static const char *mpw_passwordForSite_v0(const uint8_t *masterKey, const char *
|
|||||||
trc( "siteCounter: %d\n", siteCounter );
|
trc( "siteCounter: %d\n", siteCounter );
|
||||||
trc( "siteVariant: %d\n", siteVariant );
|
trc( "siteVariant: %d\n", siteVariant );
|
||||||
trc( "siteType: %d\n", siteType );
|
trc( "siteType: %d\n", siteType );
|
||||||
trc( "site scope: %s, context: %s\n", siteScope, siteContext == NULL? "<empty>": siteContext );
|
trc( "site scope: %s, context: %s\n", siteScope, siteContext? "<empty>": siteContext );
|
||||||
|
trc( "seed from: hmac-sha256(masterKey, %s | %s | %s | %s | %s | %s)\n",
|
||||||
|
siteScope, mpw_hex_l( htonl( strlen( siteName ) ) ), siteName,
|
||||||
|
mpw_hex_l( htonl( siteCounter ) ),
|
||||||
|
mpw_hex_l( htonl( siteContext? strlen( siteContext ): 0 ) ), siteContext? "(null)": siteContext );
|
||||||
|
|
||||||
// Calculate the site seed.
|
// Calculate the site seed.
|
||||||
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
||||||
|
@ -62,7 +62,11 @@ static const char *mpw_passwordForSite_v1(const uint8_t *masterKey, const char *
|
|||||||
trc( "siteCounter: %d\n", siteCounter );
|
trc( "siteCounter: %d\n", siteCounter );
|
||||||
trc( "siteVariant: %d\n", siteVariant );
|
trc( "siteVariant: %d\n", siteVariant );
|
||||||
trc( "siteType: %d\n", siteType );
|
trc( "siteType: %d\n", siteType );
|
||||||
trc( "site scope: %s, context: %s\n", siteScope, siteContext == NULL? "<empty>": siteContext );
|
trc( "site scope: %s, context: %s\n", siteScope, siteContext? "<empty>": siteContext );
|
||||||
|
trc( "seed from: hmac-sha256(masterKey, %s | %s | %s | %s | %s | %s)\n",
|
||||||
|
siteScope, mpw_hex_l( htonl( strlen( siteName ) ) ), siteName,
|
||||||
|
mpw_hex_l( htonl( siteCounter ) ),
|
||||||
|
mpw_hex_l( htonl( siteContext? strlen( siteContext ): 0 ) ), siteContext? "(null)": siteContext );
|
||||||
|
|
||||||
// Calculate the site seed.
|
// Calculate the site seed.
|
||||||
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
||||||
|
@ -62,7 +62,11 @@ static const char *mpw_passwordForSite_v2(const uint8_t *masterKey, const char *
|
|||||||
trc( "siteCounter: %d\n", siteCounter );
|
trc( "siteCounter: %d\n", siteCounter );
|
||||||
trc( "siteVariant: %d\n", siteVariant );
|
trc( "siteVariant: %d\n", siteVariant );
|
||||||
trc( "siteType: %d\n", siteType );
|
trc( "siteType: %d\n", siteType );
|
||||||
trc( "site scope: %s, context: %s\n", siteScope, siteContext == NULL? "<empty>": siteContext );
|
trc( "site scope: %s, context: %s\n", siteScope, siteContext? "<empty>": siteContext );
|
||||||
|
trc( "seed from: hmac-sha256(masterKey, %s | %s | %s | %s | %s | %s)\n",
|
||||||
|
siteScope, mpw_hex_l( htonl( strlen( siteName ) ) ), siteName,
|
||||||
|
mpw_hex_l( htonl( siteCounter ) ),
|
||||||
|
mpw_hex_l( htonl( siteContext? strlen( siteContext ): 0 ) ), siteContext? "(null)": siteContext );
|
||||||
|
|
||||||
// Calculate the site seed.
|
// Calculate the site seed.
|
||||||
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
||||||
|
@ -62,7 +62,11 @@ static const char *mpw_passwordForSite_v3(const uint8_t *masterKey, const char *
|
|||||||
trc( "siteCounter: %d\n", siteCounter );
|
trc( "siteCounter: %d\n", siteCounter );
|
||||||
trc( "siteVariant: %d\n", siteVariant );
|
trc( "siteVariant: %d\n", siteVariant );
|
||||||
trc( "siteType: %d\n", siteType );
|
trc( "siteType: %d\n", siteType );
|
||||||
trc( "site scope: %s, context: %s\n", siteScope, siteContext == NULL? "<empty>": siteContext );
|
trc( "site scope: %s, context: %s\n", siteScope, siteContext? "<empty>": siteContext );
|
||||||
|
trc( "seed from: hmac-sha256(masterKey, %s | %s | %s | %s | %s | %s)\n",
|
||||||
|
siteScope, mpw_hex_l( htonl( strlen( siteName ) ) ), siteName,
|
||||||
|
mpw_hex_l( htonl( siteCounter ) ),
|
||||||
|
mpw_hex_l( htonl( siteContext? strlen( siteContext ): 0 ) ), siteContext? "(null)": siteContext );
|
||||||
|
|
||||||
// Calculate the site seed.
|
// Calculate the site seed.
|
||||||
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
// sitePasswordSeed = hmac-sha256( masterKey, siteScope . #siteName . siteName . siteCounter . #siteContext . siteContext )
|
||||||
|
@ -96,14 +96,25 @@ const char *mpw_idForBuf(const void *buf, size_t length) {
|
|||||||
return mpw_hex( hash, 32 );
|
return mpw_hex( hash, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *mpw_hex_buf = NULL;
|
static char **mpw_hex_buf = NULL;
|
||||||
|
static unsigned int mpw_hex_buf_i = 0;
|
||||||
const char *mpw_hex(const void *buf, size_t length) {
|
const char *mpw_hex(const void *buf, size_t length) {
|
||||||
|
|
||||||
mpw_hex_buf = realloc( mpw_hex_buf, length * 2 + 1 );
|
if (!mpw_hex_buf) {
|
||||||
for (size_t kH = 0; kH < length; kH++)
|
mpw_hex_buf = malloc( 10 * sizeof( char* ) );
|
||||||
sprintf( &(mpw_hex_buf[kH * 2]), "%02X", ((const uint8_t *)buf)[kH] );
|
for (uint8_t i = 0; i < 10; ++i)
|
||||||
|
mpw_hex_buf[i] = NULL;
|
||||||
|
}
|
||||||
|
mpw_hex_buf_i = (mpw_hex_buf_i + 1) % 10;
|
||||||
|
|
||||||
return mpw_hex_buf;
|
mpw_hex_buf[mpw_hex_buf_i] = realloc( mpw_hex_buf[mpw_hex_buf_i], length * 2 + 1 );
|
||||||
|
for (size_t kH = 0; kH < length; kH++)
|
||||||
|
sprintf( &(mpw_hex_buf[mpw_hex_buf_i][kH * 2]), "%02X", ((const uint8_t *)buf)[kH] );
|
||||||
|
|
||||||
|
return mpw_hex_buf[mpw_hex_buf_i];
|
||||||
|
}
|
||||||
|
const char *mpw_hex_l(uint32_t number) {
|
||||||
|
return mpw_hex( &number, sizeof( number ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COLOR
|
#ifdef COLOR
|
||||||
|
@ -66,6 +66,7 @@ uint8_t const *mpw_hmac_sha256(
|
|||||||
/** Encode a buffer as a string of hexadecimal characters.
|
/** Encode a buffer as a string of hexadecimal characters.
|
||||||
* @return A C-string in a reused buffer, do not free or store it. */
|
* @return A C-string in a reused buffer, do not free or store it. */
|
||||||
const char *mpw_hex(const void *buf, size_t length);
|
const char *mpw_hex(const void *buf, size_t length);
|
||||||
|
const char *mpw_hex_l(uint32_t number);
|
||||||
/** Encode a fingerprint for a buffer.
|
/** Encode a fingerprint for a buffer.
|
||||||
* @return A C-string in a reused buffer, do not free or store it. */
|
* @return A C-string in a reused buffer, do not free or store it. */
|
||||||
const char *mpw_idForBuf(const void *buf, size_t length);
|
const char *mpw_idForBuf(const void *buf, size_t length);
|
||||||
|
Loading…
Reference in New Issue
Block a user