X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Fsilcpkcs.c;h=8aa9d516e8867ff986e230cad3ffe098edc5533a;hb=f82024f04b73e3b80ddd6c590699206d3dc5c1eb;hp=2f2c1d16db13c2fee68848ad4a598b0eb8fe1c57;hpb=a32eecc529a135726587f17d667badb70605c405;p=silc.git diff --git a/lib/silccrypt/silcpkcs.c b/lib/silccrypt/silcpkcs.c index 2f2c1d16..8aa9d516 100644 --- a/lib/silccrypt/silcpkcs.c +++ b/lib/silccrypt/silcpkcs.c @@ -811,6 +811,25 @@ bool silc_pkcs_public_key_compare(SilcPublicKey key1, SilcPublicKey key2) return FALSE; } +/* Copies the public key indicated by `public_key' and returns new allocated + public key which is indentical to the `public_key'. */ + +SilcPublicKey silc_pkcs_public_key_copy(SilcPublicKey public_key) +{ + SilcPublicKey key = silc_calloc(1, sizeof(*key)); + if (!key) + return NULL; + + key->len = public_key->len; + key->name = silc_memdup(public_key->name, strlen(public_key->name)); + key->identifier = silc_memdup(public_key->identifier, + strlen(public_key->identifier)); + key->pk = silc_memdup(public_key->pk, public_key->pk_len); + key->pk_len = public_key->pk_len; + + return key; +} + /* Encodes SILC private key from SilcPrivateKey. Returns the encoded data. */ unsigned char *