mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Introduce a new utility function smemclr(), which memsets things to
zero but does it in such a way that over-clever compilers hopefully won't helpfully optimise the call away if you do it just before freeing something or letting it go out of scope. Use this for (hopefully) every memset whose job is to destroy sensitive data that might otherwise be left lying around in the process's memory. [originally from svn r9586]
This commit is contained in:
8
sshdes.c
8
sshdes.c
@ -858,7 +858,7 @@ void des3_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len)
|
||||
des_key_setup(GET_32BIT_MSB_FIRST(key),
|
||||
GET_32BIT_MSB_FIRST(key + 4), &ourkeys[2]);
|
||||
des_3cbc_decrypt(blk, len, ourkeys);
|
||||
memset(ourkeys, 0, sizeof(ourkeys));
|
||||
smemclr(ourkeys, sizeof(ourkeys));
|
||||
}
|
||||
|
||||
void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len)
|
||||
@ -871,7 +871,7 @@ void des3_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len)
|
||||
des_key_setup(GET_32BIT_MSB_FIRST(key),
|
||||
GET_32BIT_MSB_FIRST(key + 4), &ourkeys[2]);
|
||||
des_3cbc_encrypt(blk, len, ourkeys);
|
||||
memset(ourkeys, 0, sizeof(ourkeys));
|
||||
smemclr(ourkeys, sizeof(ourkeys));
|
||||
}
|
||||
|
||||
void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
|
||||
@ -887,7 +887,7 @@ void des3_decrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
|
||||
ourkeys[0].iv0 = GET_32BIT_MSB_FIRST(iv);
|
||||
ourkeys[0].iv1 = GET_32BIT_MSB_FIRST(iv+4);
|
||||
des_cbc3_decrypt(blk, len, ourkeys);
|
||||
memset(ourkeys, 0, sizeof(ourkeys));
|
||||
smemclr(ourkeys, sizeof(ourkeys));
|
||||
}
|
||||
|
||||
void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
|
||||
@ -903,7 +903,7 @@ void des3_encrypt_pubkey_ossh(unsigned char *key, unsigned char *iv,
|
||||
ourkeys[0].iv0 = GET_32BIT_MSB_FIRST(iv);
|
||||
ourkeys[0].iv1 = GET_32BIT_MSB_FIRST(iv+4);
|
||||
des_cbc3_encrypt(blk, len, ourkeys);
|
||||
memset(ourkeys, 0, sizeof(ourkeys));
|
||||
smemclr(ourkeys, sizeof(ourkeys));
|
||||
}
|
||||
|
||||
static void des_keysetup_xdmauth(unsigned char *keydata, DESContext *dc)
|
||||
|
Reference in New Issue
Block a user