Mercurial > dropbear
comparison pkcs_1_pss_decode.c @ 15:6362d3854bb4 libtomcrypt-orig
0.96 release of LibTomCrypt
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 15 Jun 2004 14:07:21 +0000 |
parents | 7faae8f46238 |
children | 5d99163f7e32 |
comparison
equal
deleted
inserted
replaced
3:7faae8f46238 | 15:6362d3854bb4 |
---|---|
58 for (y = 0; y < hLen; y++) { | 58 for (y = 0; y < hLen; y++) { |
59 hash[y] = sig[x++]; | 59 hash[y] = sig[x++]; |
60 } | 60 } |
61 | 61 |
62 /* check the MSB */ | 62 /* check the MSB */ |
63 if ((sig[0] & ~(0xFF >> ((modulus_len<<3) - modulus_bitlen))) != 0) { | 63 if ((sig[0] & ~(0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)))) != 0) { |
64 return CRYPT_OK; | 64 return CRYPT_OK; |
65 } | 65 } |
66 | 66 |
67 /* generate mask of length modulus_len - hLen - 1 from hash */ | 67 /* generate mask of length modulus_len - hLen - 1 from hash */ |
68 if ((err = pkcs_1_mgf1(hash, hLen, hash_idx, mask, modulus_len - hLen - 1)) != CRYPT_OK) { | 68 if ((err = pkcs_1_mgf1(hash, hLen, hash_idx, mask, modulus_len - hLen - 1)) != CRYPT_OK) { |
71 | 71 |
72 /* xor against DB */ | 72 /* xor against DB */ |
73 for (y = 0; y < (modulus_len - hLen - 1); y++) { | 73 for (y = 0; y < (modulus_len - hLen - 1); y++) { |
74 DB[y] ^= mask[y]; | 74 DB[y] ^= mask[y]; |
75 } | 75 } |
76 | |
77 /* now clear the first byte [make sure smaller than modulus] */ | |
78 DB[0] &= 0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)); | |
76 | 79 |
77 /* DB = PS || 0x01 || salt, PS == modulus_len - saltlen - hLen - 2 zero bytes */ | 80 /* DB = PS || 0x01 || salt, PS == modulus_len - saltlen - hLen - 2 zero bytes */ |
78 | 81 |
79 /* check for zeroes and 0x01 */ | 82 /* check for zeroes and 0x01 */ |
80 for (x = 0; x < modulus_len - saltlen - hLen - 2; x++) { | 83 for (x = 0; x < modulus_len - saltlen - hLen - 2; x++) { |