summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2019-01-20 23:12:35 +0000
committerDamien Miller <djm@mindrot.org>2019-01-21 10:57:03 +1100
commitfcb1b0937182d0137a3c357c89735d0dc5869d54 (patch)
tree8cd1915d0cce0ec1a700fb3905d20bcfe713983e
parent6529409e85890cd6df7e5e81d04e393b1d2e4b0b (diff)
upstream: we use singleton pkcs#11 RSA_METHOD and EC_KEY_METHOD
now, so there is no need to keep a copy of each in the pkcs11_key object. work by markus@, ok djm@ OpenBSD-Commit-ID: 43b4856516e45c0595f17a8e95b2daee05f12faa
-rw-r--r--ssh-pkcs11.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c
index 1a6e9806e..b49034952 100644
--- a/ssh-pkcs11.c
+++ b/ssh-pkcs11.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11.c,v 1.35 2019/01/20 23:11:11 djm Exp $ */ 1/* $OpenBSD: ssh-pkcs11.c,v 1.36 2019/01/20 23:12:35 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * Copyright (c) 2014 Pedro Martelletto. All rights reserved. 4 * Copyright (c) 2014 Pedro Martelletto. All rights reserved.
@@ -72,8 +72,6 @@ TAILQ_HEAD(, pkcs11_provider) pkcs11_providers;
72struct pkcs11_key { 72struct pkcs11_key {
73 struct pkcs11_provider *provider; 73 struct pkcs11_provider *provider;
74 CK_ULONG slotidx; 74 CK_ULONG slotidx;
75 RSA_METHOD *rsa_method;
76 EC_KEY_METHOD *ec_key_method;
77 char *keyid; 75 char *keyid;
78 int keyid_len; 76 int keyid_len;
79}; 77};
@@ -406,8 +404,7 @@ pkcs11_rsa_wrap(struct pkcs11_provider *provider, CK_ULONG slotidx,
406 memcpy(k11->keyid, keyid_attrib->pValue, k11->keyid_len); 404 memcpy(k11->keyid, keyid_attrib->pValue, k11->keyid_len);
407 } 405 }
408 406
409 k11->rsa_method = rsa_method; 407 RSA_set_method(rsa, rsa_method);
410 RSA_set_method(rsa, k11->rsa_method);
411 RSA_set_ex_data(rsa, rsa_idx, k11); 408 RSA_set_ex_data(rsa, rsa_idx, k11);
412 return (0); 409 return (0);
413} 410}
@@ -509,9 +506,8 @@ pkcs11_ecdsa_wrap(struct pkcs11_provider *provider, CK_ULONG slotidx,
509 k11->keyid_len = keyid_attrib->ulValueLen; 506 k11->keyid_len = keyid_attrib->ulValueLen;
510 k11->keyid = xmalloc(k11->keyid_len); 507 k11->keyid = xmalloc(k11->keyid_len);
511 memcpy(k11->keyid, keyid_attrib->pValue, k11->keyid_len); 508 memcpy(k11->keyid, keyid_attrib->pValue, k11->keyid_len);
512 k11->ec_key_method = ec_key_method;
513 509
514 EC_KEY_set_method(ec, k11->ec_key_method); 510 EC_KEY_set_method(ec, ec_key_method);
515 EC_KEY_set_ex_data(ec, ec_key_idx, k11); 511 EC_KEY_set_ex_data(ec, ec_key_idx, k11);
516 512
517 return (0); 513 return (0);