summaryrefslogtreecommitdiffstats
path: root/libtomcrypt/misc/pk_get_oid.c
blob: 07d0b5bcbf718444fa54f06c124cb2c7634d61ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* 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"
#include <ncr-int.h>

/*
   Returns the OID of the public key algorithm.
   @return CRYPT_OK if valid
*/
int pk_get_oid(const struct algo_properties_st *pk, oid_st * st)
{
	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;
}