summaryrefslogtreecommitdiffstats
path: root/libtomcrypt/misc/pk_get_oid.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-09-06 22:02:15 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-09-06 22:02:38 +0200
commita92443718f19ffc36fbe55d85a4785130a4b33c7 (patch)
tree79850bdf3cd559d389b2908d17e0e21bdb893b20 /libtomcrypt/misc/pk_get_oid.c
parente6177630198eb1eea2def0374fae1196da0e40ec (diff)
downloadcryptodev-linux-a92443718f19ffc36fbe55d85a4785130a4b33c7.tar.gz
cryptodev-linux-a92443718f19ffc36fbe55d85a4785130a4b33c7.tar.xz
cryptodev-linux-a92443718f19ffc36fbe55d85a4785130a4b33c7.zip
Algorithm to OID discovery moved to a single place.
Diffstat (limited to 'libtomcrypt/misc/pk_get_oid.c')
-rw-r--r--libtomcrypt/misc/pk_get_oid.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/libtomcrypt/misc/pk_get_oid.c b/libtomcrypt/misc/pk_get_oid.c
index 7b2803f..07d0b5b 100644
--- a/libtomcrypt/misc/pk_get_oid.c
+++ b/libtomcrypt/misc/pk_get_oid.c
@@ -8,32 +8,20 @@
*
*/
#include "tomcrypt.h"
-
-static const oid_st rsa_oid = {
- .OIDlen = 7,
- .OID = {1, 2, 840, 113549, 1, 1, 1},
-};
-
-static const oid_st dsa_oid = {
- .OIDlen = 6,
- .OID = {1, 2, 840, 10040, 4, 1},
-};
+#include <ncr-int.h>
/*
Returns the OID of the public key algorithm.
@return CRYPT_OK if valid
*/
-int pk_get_oid(int pk, oid_st * st)
+int pk_get_oid(const struct algo_properties_st *pk, oid_st * st)
{
- switch (pk) {
- case PKA_RSA:
- memcpy(st, &rsa_oid, sizeof(*st));
- break;
- case PKA_DSA:
- memcpy(st, &dsa_oid, sizeof(*st));
- break;
- default:
+ if (pk->is_pk == 0 || pk->oids[0].key_size != -1) {
+ /* not a pk */
return CRYPT_INVALID_ARG;
}
+
+ memcpy(st, &pk->oids[0].oid, sizeof(*st));
+
return CRYPT_OK;
}