2
0

Clean up aes state, default to 512 key size, improve log output.

This commit is contained in:
Maarten Billemont
2017-09-24 12:00:38 -04:00
parent 39dcef46d2
commit b4c2a393f1
11 changed files with 125 additions and 91 deletions

View File

@@ -486,6 +486,8 @@ void AES_ECB_encrypt(uint8_t *output, const uint8_t *input, const uint32_t lengt
// The next function call encrypts the PlainText with the Key using AES algorithm.
Cipher();
bzero( RoundKey, keyExpSize );
}
void AES_ECB_decrypt(uint8_t *output, const uint8_t *input, const uint32_t length, const uint8_t *key)
@@ -499,6 +501,8 @@ void AES_ECB_decrypt(uint8_t *output, const uint8_t *input, const uint32_t lengt
KeyExpansion();
InvCipher();
bzero( RoundKey, keyExpSize );
}
@@ -555,6 +559,8 @@ void AES_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, co
state = (state_t*)output;
Cipher();
}
bzero( RoundKey, keyExpSize );
}
void AES_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv)
@@ -592,6 +598,8 @@ void AES_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, co
state = (state_t*)output;
InvCipher();
}
bzero( RoundKey, keyExpSize );
}
#endif // #if defined(AES_CBC) && (AES_CBC == 1)

View File

@@ -175,7 +175,7 @@ const char *mpw_siteState(
trc( "-- mpw_siteState (algorithm: %u)\n", algorithmVersion );
trc( "resultType: %d (%s)\n", resultType, mpw_nameForType( resultType ) );
trc( "resultParam: %s\n", resultParam );
trc( "resultParam: %zu bytes = %s\n", sizeof( resultParam ), resultParam );
if (!masterKey || !resultParam)
return NULL;

View File

@@ -180,7 +180,7 @@ static const char *mpw_sitePasswordFromCrypt_v0(
mpw_free( &plainBytes, bufSize );
if (!plainText)
err( "AES decryption error: %s\n", strerror( errno ) );
trc( "decrypted -> plainText: %s\n", plainText );
trc( "decrypted -> plainText: %zu bytes = %s = %s\n", sizeof( plainText ), plainText, mpw_hex( plainText, sizeof( plainText ) ) );
return plainText;
}
@@ -195,6 +195,8 @@ static const char *mpw_sitePasswordFromDerive_v0(
return NULL;
}
int resultParamInt = atoi( resultParam );
if (!resultParamInt)
resultParamInt = 512;
if (resultParamInt < 128 || resultParamInt > 512 || resultParamInt % 8 != 0) {
err( "Parameter is not a valid key size (should be 128 - 512): %s\n", resultParam );
return NULL;

View File

@@ -44,6 +44,24 @@ time_t mpw_mktime(
&tm.tm_hour, &tm.tm_min, &tm.tm_sec ) == 6) {
tm.tm_year -= 1900; // tm_year 0 = rfc3339 year 1900
tm.tm_mon -= 1; // tm_mon 0 = rfc3339 month 1
/*
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
frame #0: 0x00007fff9fe4d219 libsystem_notify.dylib`_nc_table_find_64 + 22
libsystem_notify.dylib`_nc_table_find_64:
-> 0x7fff9fe4d219 <+22>: divl 0x4(%rdi)
0x7fff9fe4d21c <+25>: movq 0x8(%rdi), %rax
0x7fff9fe4d220 <+29>: movq (%rax,%rdx,8), %rcx
0x7fff9fe4d224 <+33>: xorl %eax, %eax
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
* frame #0: 0x00007fff9fe4d219 libsystem_notify.dylib`_nc_table_find_64 + 22
frame #1: 0x00007fff9fe4a21e libsystem_notify.dylib`registration_node_find + 53
frame #2: 0x00007fff9fe4b78d libsystem_notify.dylib`notify_check + 105
frame #3: 0x00007fff9fccc164 libsystem_c.dylib`notify_check_tz + 24
frame #4: 0x00007fff9fccbd97 libsystem_c.dylib`tzsetwall_basic + 45
frame #5: 0x00007fff9fccdcd0 libsystem_c.dylib`mktime + 46
frame #6: 0x0000000100009496 mpw`mpw_mktime(time="2017-04-16T03:16:35Z") at mpw-marshal-util.c:47
*/
return mktime( &tm );
}