diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-08-18 05:30:26 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-08-24 23:49:31 +0200 |
commit | 650b6caa69d41753d6ad61f20dc6d46bc24b96ea (patch) | |
tree | 1585d6d01f7f8dfe86a236051df7137ddd4b5b88 | |
parent | fd2e58ac4f74dcaab4a91c5280408bd6049df5c2 (diff) | |
download | cryptodev-linux-650b6caa69d41753d6ad61f20dc6d46bc24b96ea.tar.gz cryptodev-linux-650b6caa69d41753d6ad61f20dc6d46bc24b96ea.tar.xz cryptodev-linux-650b6caa69d41753d6ad61f20dc6d46bc24b96ea.zip |
Add version ID to key storage wrapping format
-rw-r--r-- | ncr-key-storage.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ncr-key-storage.c b/ncr-key-storage.c index f00bce8..149c45a 100644 --- a/ncr-key-storage.c +++ b/ncr-key-storage.c @@ -32,6 +32,7 @@ #include "cryptodev_int.h" struct packed_key { + uint32_t version; uint8_t type; uint32_t flags; uint16_t algorithm; /* valid for public/private keys */ @@ -42,6 +43,8 @@ struct packed_key { uint32_t raw_size; } __attribute__((__packed__)); +#define THIS_VERSION 1 + int key_to_storage_data( uint8_t** sdata, size_t * sdata_size, const struct key_item_st *key) { struct packed_key * pkey; @@ -53,6 +56,7 @@ int key_to_storage_data( uint8_t** sdata, size_t * sdata_size, const struct key_ return -ENOMEM; } + pkey->version = THIS_VERSION; pkey->type = key->type; pkey->flags = key->flags; pkey->algorithm = key->algorithm->algo; @@ -90,7 +94,8 @@ int key_from_storage_data(struct key_item_st* key, const void* data, size_t data const struct packed_key * pkey = data; int ret; - if (data_size != sizeof(*pkey) || pkey->key_id_size > MAX_KEY_ID_SIZE) { + if (data_size != sizeof(*pkey) || pkey->version != THIS_VERSION + || pkey->key_id_size > MAX_KEY_ID_SIZE) { err(); return -EINVAL; } |