#ifndef OPENSSL_NO_RSA
#include "openssl_rsa_public_key.h"
+#include "openssl_util.h"
#include <utils/debug.h>
private_openssl_rsa_public_key_t *this, cred_encoding_type_t type,
chunk_t *encoding)
{
+ bool success = FALSE;
u_char *p;
switch (type)
case PUBKEY_SPKI_ASN1_DER:
case PUBKEY_PEM:
{
- bool success = TRUE;
-
*encoding = chunk_alloc(i2d_RSA_PUBKEY(this->rsa, NULL));
p = encoding->ptr;
i2d_RSA_PUBKEY(this->rsa, &p);
+ success = TRUE;
if (type == PUBKEY_PEM)
{
return TRUE;
}
default:
- return FALSE;
+ {
+ chunk_t n = chunk_empty, e = chunk_empty;
+
+ if (openssl_bn2chunk(this->rsa->n, &n) &&
+ openssl_bn2chunk(this->rsa->e, &e))
+ {
+ success = lib->encoding->encode(lib->encoding, type, NULL,
+ encoding, CRED_PART_RSA_MODULUS, n,
+ CRED_PART_RSA_PUB_EXP, e, CRED_PART_END);
+ }
+ chunk_free(&n);
+ chunk_free(&e);
+ return success;
+ }
}
}