diff options
| author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-19 20:10:26 +0200 |
|---|---|---|
| committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-19 20:10:26 +0200 |
| commit | 56eb45f752baa978a9ea3573faee44857678597d (patch) | |
| tree | 3c7da78ba84669d0f988b98450e4e55779dfcb41 /libtomcrypt/misc | |
| parent | 035b7bf3544ab9927dc2d64cf1e3214237ff0f71 (diff) | |
| download | cryptodev-linux-56eb45f752baa978a9ea3573faee44857678597d.tar.gz cryptodev-linux-56eb45f752baa978a9ea3573faee44857678597d.tar.xz cryptodev-linux-56eb45f752baa978a9ea3573faee44857678597d.zip | |
Public Keys are being exported to SubjectPublicKeyInfo format, instead of custom formats. For RSA keys the PKCS #1 format can be used as well.
Diffstat (limited to 'libtomcrypt/misc')
| -rw-r--r-- | libtomcrypt/misc/pk_get_oid.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libtomcrypt/misc/pk_get_oid.c b/libtomcrypt/misc/pk_get_oid.c new file mode 100644 index 0000000..197d7ae --- /dev/null +++ b/libtomcrypt/misc/pk_get_oid.c @@ -0,0 +1,40 @@ +/* LibTomCrypt, modular cryptographic library + * + * LibTomCrypt is a library that provides various cryptographic + * algorithms in a highly modular and flexible manner. + * + * The library is free for all purposes without any express + * guarantee it works. + * + */ +#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 }, +}; + +/* + Returns the OID of the public key algorithm. + @return CRYPT_OK if valid +*/ +int pk_get_oid(int 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: + return CRYPT_INVALID_ARG; + } + return CRYPT_OK; +} + |
