ported most of the libstrongswan chunk_t macros to pluto

This commit is contained in:
Andreas Steffen
2009-04-17 16:11:33 +00:00
parent c04e75487f
commit 9b91b81870
27 changed files with 273 additions and 250 deletions
+6 -5
View File
@@ -491,7 +491,7 @@ RSA_encrypt(const RSA_public_key_t *key, chunk_t in)
bool
RSA_decrypt(const RSA_private_key_t *key, chunk_t in, chunk_t *out)
{
chunk_t padded;
chunk_t padded, plaintext;
u_char *pos;
mpz_t t1, t2;
@@ -530,7 +530,7 @@ RSA_decrypt(const RSA_private_key_t *key, chunk_t in, chunk_t *out)
if ((*pos++ != 0x00) || (*(pos++) != 0x02))
{
plog("incorrect padding - probably wrong RSA key");
freeanychunk(padded);
chunk_clear(&padded);
return FALSE;
}
padded.len -= 2;
@@ -541,12 +541,13 @@ RSA_decrypt(const RSA_private_key_t *key, chunk_t in, chunk_t *out)
if (padded.len == 0)
{
plog("no plaintext data");
freeanychunk(padded);
free(padded.ptr);
return FALSE;
}
clonetochunk(*out, pos, padded.len);
freeanychunk(padded);
plaintext = chunk_create(pos, padded.len);
*out = chunk_clone(plaintext);
chunk_clear(&padded);
return TRUE;
}