diff src/pk/pkcs1/pkcs_1_oaep_decode.c @ 209:39d5d58461d6 libtomcrypt-orig LTC_1.05

Import of libtomcrypt 1.05
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Jul 2005 03:53:40 +0000
parents 1c15b283127b
children
line wrap: on
line diff
--- a/src/pk/pkcs1/pkcs_1_oaep_decode.c	Fri May 06 13:23:02 2005 +0000
+++ b/src/pk/pkcs1/pkcs_1_oaep_decode.c	Wed Jul 06 03:53:40 2005 +0000
@@ -63,7 +63,7 @@
    /* allocate ram for DB/mask/salt of size modulus_len */
    DB   = XMALLOC(modulus_len);
    mask = XMALLOC(modulus_len);
-   seed = XMALLOC(modulus_len);
+   seed = XMALLOC(hLen);
    if (DB == NULL || mask == NULL || seed == NULL) {
       if (DB != NULL) {
          XFREE(DB);
@@ -92,14 +92,13 @@
    }
 
    /* now read the masked seed */
-   for (x = 1, y = 0; y < hLen; y++) {
-      seed[y] = msg[x++];
-   }
+   x = 1;
+   XMEMCPY(seed, msg + x, hLen);
+   x += hLen;
 
    /* now read the masked DB */
-   for (y = 0; y < modulus_len - hLen - 1; y++) {
-      DB[y] = msg[x++];
-   }
+   XMEMCPY(DB, msg + x, modulus_len - hLen - 1);
+   x += modulus_len - hLen - 1;
 
    /* compute MGF1 of maskedDB (hLen) */ 
    if ((err = pkcs_1_mgf1(DB, modulus_len - hLen - 1, hash_idx, mask, hLen)) != CRYPT_OK) {
@@ -161,9 +160,8 @@
 
    /* copy message */
    *outlen = (modulus_len - hLen - 1) - x;
-   for (y = 0; x != (modulus_len - hLen - 1); ) {
-       out[y++] = DB[x++];
-   }
+   XMEMCPY(out, DB + x, modulus_len - hLen - 1 - x);
+   x += modulus_len - hLen - 1;
 
    /* valid packet */
    *res = 1;
@@ -172,7 +170,7 @@
 LBL_ERR:
 #ifdef LTC_CLEAN_STACK
    zeromem(DB,   modulus_len);
-   zeromem(seed, modulus_len);
+   zeromem(seed, hLen);
    zeromem(mask, modulus_len);
 #endif
 
@@ -184,3 +182,7 @@
 }
 
 #endif /* PKCS_1 */
+
+/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c,v $ */
+/* $Revision: 1.5 $ */
+/* $Date: 2005/06/18 02:37:06 $ */