Commit b56eb2e9 authored by Jakub Jelen's avatar Jakub Jelen Committed by Marc-André Lureau

vcard_emul: New function vcard_emul_rsa_bits

 * Introduce a new API to get the key size from the key to present it in
   CAC properties structures later
Signed-off-by: default avatarJakub Jelen <jjelen@redhat.com>
Reviewed-by: default avatarRobert Relyea <rrelyea@redhat.com>
Message-Id: <20180802094407.4104-3-jjelen@redhat.com>
[ Marc-André - do not export the function ]
Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
parent b806a9b5
......@@ -350,6 +350,10 @@ and applet.
This function does a raw rsa op on the buffer with the given key.
int vcard_emul_rsa_bits(VCardKey *key);
This function returns the size of RSA key in bits.
The sample card type emulator is found in cac.c. It implements the cac specific
applets. Only those applets needed by the coolkey pkcs#11 driver on the guest
have been implemented. To support the full range CAC middleware, a complete CAC
......
......@@ -47,6 +47,7 @@ void vcard_emul_logout(VCard *card);
*/
/* delete a key */
void vcard_emul_delete_key(VCardKey *key);
int vcard_emul_rsa_bits(VCardKey *key);
/* RSA sign/decrypt with the key, signature happens 'in place' */
vcard_7816_status_t vcard_emul_rsa_op(VCard *card, VCardKey *key,
unsigned char *buffer, int buffer_size);
......
......@@ -213,6 +213,28 @@ vcard_emul_map_error(int error)
return VCARD7816_STATUS_EXC_ERROR_CHANGE;
}
/* get RSA bits */
int
vcard_emul_rsa_bits(VCardKey *key)
{
SECKEYPublicKey *pub_key;
int bits = -1;
if (key == NULL) {
/* couldn't get the key, indicate that we aren't logged in */
return -1;
}
pub_key = CERT_ExtractPublicKey(key->cert);
if (pub_key == NULL) {
/* couldn't get the key, indicate that we aren't logged in */
return -1;
}
bits = SECKEY_PublicKeyStrengthInBits(pub_key);
SECKEY_DestroyPublicKey(pub_key);
return bits;
}
/* RSA sign/decrypt with the key, signature happens 'in place' */
vcard_7816_status_t
vcard_emul_rsa_op(VCard *card, VCardKey *key,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment