aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libstrongswan/plugins/pkcs11/pkcs11_public_key.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/pkcs11/pkcs11_public_key.c b/src/libstrongswan/plugins/pkcs11/pkcs11_public_key.c
index 65bf54bc0..81ab6cb31 100644
--- a/src/libstrongswan/plugins/pkcs11/pkcs11_public_key.c
+++ b/src/libstrongswan/plugins/pkcs11/pkcs11_public_key.c
@@ -192,6 +192,10 @@ static bool encode_rsa(private_pkcs11_public_key_t *this,
{
chunk_t n, e;
n = chunk_create(attr[0].pValue, attr[0].ulValueLen);
+ if (n.ptr[0] & 0x80)
+ { /* add leading 0x00, encoders expect it already like this */
+ n = chunk_cata("cc", chunk_from_chars(0x00), n);
+ }
e = chunk_create(attr[1].pValue, attr[1].ulValueLen);
success = lib->encoding->encode(lib->encoding, type, cache, encoding,
CRED_PART_RSA_MODULUS, n, CRED_PART_RSA_PUB_EXP, e, CRED_PART_END);