comparison src/pk/pkcs1/pkcs_1_oaep_encode.c @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16

Update to LibTomCrypt 1.16
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:22:00 +0000
parents 59400faa4b44
children
comparison
equal deleted inserted replaced
280:59400faa4b44 380:d5faf4814ddb
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 $ */