split return values.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19170 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-11-28 11:48:01 +00:00
parent a8fd77a69a
commit da9641ef4f

View File

@@ -79,7 +79,7 @@ imath_rsa_public_encrypt(int flen, const unsigned char* from,
size = RSA_size(rsa); size = RSA_size(rsa);
if (size < RSA_PKCS1_PADDING_SIZE || size - RSA_PKCS1_PADDING_SIZE < flen) if (size < RSA_PKCS1_PADDING_SIZE || size - RSA_PKCS1_PADDING_SIZE < flen)
return -1; return -2;
BN2mpz(&n, rsa->n); BN2mpz(&n, rsa->n);
BN2mpz(&e, rsa->e); BN2mpz(&e, rsa->e);
@@ -88,7 +88,7 @@ imath_rsa_public_encrypt(int flen, const unsigned char* from,
if (p0 == NULL) { if (p0 == NULL) {
mp_int_clear(&e); mp_int_clear(&e);
mp_int_clear(&n); mp_int_clear(&n);
return -1; return -3;
} }
padlen = size - flen - 3; padlen = size - flen - 3;
@@ -99,7 +99,7 @@ imath_rsa_public_encrypt(int flen, const unsigned char* from,
mp_int_clear(&e); mp_int_clear(&e);
mp_int_clear(&n); mp_int_clear(&n);
free(p0); free(p0);
return -1; return -4;
} }
while(padlen) { while(padlen) {
if (*p == 0) if (*p == 0)
@@ -146,7 +146,7 @@ imath_rsa_public_decrypt(int flen, const unsigned char* from,
return -1; return -1;
if (flen > RSA_size(rsa)) if (flen > RSA_size(rsa))
return -1; return -2;
BN2mpz(&n, rsa->n); BN2mpz(&n, rsa->n);
BN2mpz(&e, rsa->e); BN2mpz(&e, rsa->e);
@@ -156,7 +156,7 @@ imath_rsa_public_decrypt(int flen, const unsigned char* from,
if (mp_int_compare_value(&e, 3) <= 0) { if (mp_int_compare_value(&e, 3) <= 0) {
mp_int_clear(&n); mp_int_clear(&n);
mp_int_clear(&e); mp_int_clear(&e);
return -1; return -3;
} }
#endif #endif
@@ -167,7 +167,7 @@ imath_rsa_public_decrypt(int flen, const unsigned char* from,
if (mp_int_compare(&s, &n) >= 0) { if (mp_int_compare(&s, &n) >= 0) {
mp_int_clear(&n); mp_int_clear(&n);
mp_int_clear(&e); mp_int_clear(&e);
return -1; return -4;
} }
res = rsa_rsavp(&s, &e, &n, &us); res = rsa_rsavp(&s, &e, &n, &us);
@@ -176,7 +176,7 @@ imath_rsa_public_decrypt(int flen, const unsigned char* from,
mp_int_clear(&e); mp_int_clear(&e);
if (res != MP_OK) if (res != MP_OK)
return -1; return -5;
p = to; p = to;
@@ -188,13 +188,13 @@ imath_rsa_public_decrypt(int flen, const unsigned char* from,
/* head zero was skipped by mp_int_to_unsigned */ /* head zero was skipped by mp_int_to_unsigned */
if (*p != 1) if (*p != 1)
return -1; return -6;
size--; p++; size--; p++;
while (size && *p == 0xff) { while (size && *p == 0xff) {
size--; p++; size--; p++;
} }
if (size == 0 || *p != 0) if (size == 0 || *p != 0)
return -1; return -7;
size--; p++; size--; p++;
memmove(to, p, size); memmove(to, p, size);
@@ -217,7 +217,7 @@ imath_rsa_private_encrypt(int flen, const unsigned char* from,
size = RSA_size(rsa); size = RSA_size(rsa);
if (size < RSA_PKCS1_PADDING_SIZE || size - RSA_PKCS1_PADDING_SIZE < flen) if (size < RSA_PKCS1_PADDING_SIZE || size - RSA_PKCS1_PADDING_SIZE < flen)
return -1; return -2;
BN2mpz(&n, rsa->n); BN2mpz(&n, rsa->n);
BN2mpz(&d, rsa->d); BN2mpz(&d, rsa->d);
@@ -271,7 +271,7 @@ imath_rsa_private_decrypt(int flen, const unsigned char* from,
size = RSA_size(rsa); size = RSA_size(rsa);
if (flen > size) if (flen > size)
return -1; return -2;
mp_int_init(&enc); mp_int_init(&enc);
mp_int_init(&dec); mp_int_init(&dec);
@@ -303,13 +303,13 @@ imath_rsa_private_decrypt(int flen, const unsigned char* from,
/* head zero was skipped by mp_int_to_unsigned */ /* head zero was skipped by mp_int_to_unsigned */
if (*p != 2) if (*p != 2)
return -1; return -3;
size--; p++; size--; p++;
while (size && *p != 0) { while (size && *p != 0) {
size--; p++; size--; p++;
} }
if (size == 0) if (size == 0)
return -1; return -4;
size--; p++; size--; p++;
memmove(to, p, size); memmove(to, p, size);