Mercurial > dropbear
comparison src/pk/pkcs1/pkcs_1_oaep_encode.c @ 381:999a5eb4ed10 libtomcrypt-dropbear
propagate from branch 'au.asn.ucc.matt.ltc.orig' (head 52840647ac7f5c707c3bd158d119a15734a7ef28)
to branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:39:21 +0000 |
parents | d5faf4814ddb |
children |
comparison
equal
deleted
inserted
replaced
281:997e6f7dc01e | 381:999a5eb4ed10 |
---|---|
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 $ */ |