Mercurial > dropbear
comparison libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c @ 382:0cbe8f6dbf9e
propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f)
to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:41:05 +0000 |
parents | 1b9e69c058d2 |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
379:b66a00272a90 | 382:0cbe8f6dbf9e |
---|---|
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | 8 * |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | 9 * Tom St Denis, [email protected], http://libtomcrypt.com |
10 */ | 10 */ |
11 #include "tomcrypt.h" | 11 #include "tomcrypt.h" |
12 | 12 |
13 /** | 13 /** |
14 @file pkcs_1_oaep_encode.c | 14 @file pkcs_1_oaep_encode.c |
112 err = CRYPT_ERROR_READPRNG; | 112 err = CRYPT_ERROR_READPRNG; |
113 goto LBL_ERR; | 113 goto LBL_ERR; |
114 } | 114 } |
115 | 115 |
116 /* compute MGF1 of seed (k - hlen - 1) */ | 116 /* compute MGF1 of seed (k - hlen - 1) */ |
117 if ((err = pkcs_1_mgf1(seed, hLen, hash_idx, mask, modulus_len - hLen - 1)) != CRYPT_OK) { | 117 if ((err = pkcs_1_mgf1(hash_idx, seed, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { |
118 goto LBL_ERR; | 118 goto LBL_ERR; |
119 } | 119 } |
120 | 120 |
121 /* xor against DB */ | 121 /* xor against DB */ |
122 for (y = 0; y < (modulus_len - hLen - 1); y++) { | 122 for (y = 0; y < (modulus_len - hLen - 1); y++) { |
123 DB[y] ^= mask[y]; | 123 DB[y] ^= mask[y]; |
124 } | 124 } |
125 | 125 |
126 /* compute MGF1 of maskedDB (hLen) */ | 126 /* compute MGF1 of maskedDB (hLen) */ |
127 if ((err = pkcs_1_mgf1(DB, modulus_len - hLen - 1, hash_idx, mask, hLen)) != CRYPT_OK) { | 127 if ((err = pkcs_1_mgf1(hash_idx, DB, modulus_len - hLen - 1, mask, hLen)) != CRYPT_OK) { |
128 goto LBL_ERR; | 128 goto LBL_ERR; |
129 } | 129 } |
130 | 130 |
131 /* XOR against seed */ | 131 /* XOR against seed */ |
132 for (y = 0; y < hLen; y++) { | 132 for (y = 0; y < hLen; y++) { |
133 seed[y] ^= mask[y]; | 133 seed[y] ^= mask[y]; |
134 } | 134 } |
135 | 135 |
136 /* create string of length modulus_len */ | 136 /* create string of length modulus_len */ |
137 if (*outlen < modulus_len) { | 137 if (*outlen < modulus_len) { |
138 *outlen = modulus_len; | |
138 err = CRYPT_BUFFER_OVERFLOW; | 139 err = CRYPT_BUFFER_OVERFLOW; |
139 goto LBL_ERR; | 140 goto LBL_ERR; |
140 } | 141 } |
141 | 142 |
142 /* start output which is 0x00 || maskedSeed || maskedDB */ | 143 /* start output which is 0x00 || maskedSeed || maskedDB */ |
166 | 167 |
167 #endif /* PKCS_1 */ | 168 #endif /* PKCS_1 */ |
168 | 169 |
169 | 170 |
170 /* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c,v $ */ | 171 /* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c,v $ */ |
171 /* $Revision: 1.4 $ */ | 172 /* $Revision: 1.7 $ */ |
172 /* $Date: 2005/05/05 14:35:59 $ */ | 173 /* $Date: 2006/06/16 21:53:41 $ */ |