comparison libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c @ 478:d4f32c3443ac dbclient-netcat-alike

propagate from branch 'au.asn.ucc.matt.dropbear' (head f21045c791002d81fc6b8dde6537ea481e513eb2) to branch 'au.asn.ucc.matt.dropbear.dbclient-netcat-alike' (head d1f69334581dc4c35f9ca16aa5355074c9dd315d)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 14 Sep 2008 06:47:51 +0000
parents 0cbe8f6dbf9e
children f849a5ca2efc
comparison
equal deleted inserted replaced
296:6b41e2cbf071 478:d4f32c3443ac
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 $ */