summaryrefslogtreecommitdiffstats
path: root/include/crypto/ecx.h
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-03-18 08:40:33 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-03-18 08:40:33 +1000
commit244bc29746c83e76e2fba542ca87552b8aef5c5f (patch)
tree5e2391571abf8ea2d69d8f8c14c49ff044f49b7f /include/crypto/ecx.h
parentb3e6d666e351d45e93d29fe3813245b92a0f5815 (diff)
Implement serializers for ED25519 and ED448
This is largely based on the existing X25519 and X448 serializers - but a few adjustments were necessary so that we can identify what type of key we are using. Previously we used the keylen for this but X25519 and ED25519 have the same keylen. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11272)
Diffstat (limited to 'include/crypto/ecx.h')
-rw-r--r--include/crypto/ecx.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/crypto/ecx.h b/include/crypto/ecx.h
index 3e494bf092..8afb104438 100644
--- a/include/crypto/ecx.h
+++ b/include/crypto/ecx.h
@@ -42,18 +42,36 @@
# define ED448_SECURITY_BITS 224
# define ED448_SIGSIZE 114
+
+typedef enum {
+ ECX_KEY_TYPE_X25519,
+ ECX_KEY_TYPE_X448,
+ ECX_KEY_TYPE_ED25519,
+ ECX_KEY_TYPE_ED448
+} ECX_KEY_TYPE;
+
+#define KEYTYPE2NID(type) \
+ ((type) == ECX_KEY_TYPE_X25519 \
+ ? EVP_PKEY_X25519 \
+ : ((type) == ECX_KEY_TYPE_X448 \
+ ? EVP_PKEY_X448 \
+ : ((type) == ECX_KEY_TYPE_ED25519 \
+ ? EVP_PKEY_ED25519 \
+ : EVP_PKEY_ED448)))
+
struct ecx_key_st {
unsigned int haspubkey:1;
unsigned char pubkey[MAX_KEYLEN];
unsigned char *privkey;
size_t keylen;
+ ECX_KEY_TYPE type;
CRYPTO_REF_COUNT references;
CRYPTO_RWLOCK *lock;
};
typedef struct ecx_key_st ECX_KEY;
-ECX_KEY *ecx_key_new(size_t keylen, int haspubkey);
+ECX_KEY *ecx_key_new(ECX_KEY_TYPE type, int haspubkey);
unsigned char *ecx_key_allocate_privkey(ECX_KEY *key);
void ecx_key_free(ECX_KEY *key);
int ecx_key_up_ref(ECX_KEY *key);