diff options
Diffstat (limited to 'ssh-pkcs11.c')
-rw-r--r-- | ssh-pkcs11.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c index b49034952..2b65010ce 100644 --- a/ssh-pkcs11.c +++ b/ssh-pkcs11.c | |||
@@ -409,6 +409,7 @@ pkcs11_rsa_wrap(struct pkcs11_provider *provider, CK_ULONG slotidx, | |||
409 | return (0); | 409 | return (0); |
410 | } | 410 | } |
411 | 411 | ||
412 | #ifdef HAVE_EC_KEY_METHOD_NEW | ||
412 | /* openssl callback doing the actual signing operation */ | 413 | /* openssl callback doing the actual signing operation */ |
413 | static ECDSA_SIG * | 414 | static ECDSA_SIG * |
414 | ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, | 415 | ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *inv, |
@@ -512,6 +513,7 @@ pkcs11_ecdsa_wrap(struct pkcs11_provider *provider, CK_ULONG slotidx, | |||
512 | 513 | ||
513 | return (0); | 514 | return (0); |
514 | } | 515 | } |
516 | #endif /* HAVE_EC_KEY_METHOD_NEW */ | ||
515 | 517 | ||
516 | /* remove trailing spaces */ | 518 | /* remove trailing spaces */ |
517 | static void | 519 | static void |
@@ -582,6 +584,7 @@ pkcs11_key_included(struct sshkey ***keysp, int *nkeys, struct sshkey *key) | |||
582 | return (0); | 584 | return (0); |
583 | } | 585 | } |
584 | 586 | ||
587 | #ifdef HAVE_EC_KEY_METHOD_NEW | ||
585 | static struct sshkey * | 588 | static struct sshkey * |
586 | pkcs11_fetch_ecdsa_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, | 589 | pkcs11_fetch_ecdsa_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, |
587 | CK_OBJECT_HANDLE *obj) | 590 | CK_OBJECT_HANDLE *obj) |
@@ -704,6 +707,7 @@ fail: | |||
704 | 707 | ||
705 | return (key); | 708 | return (key); |
706 | } | 709 | } |
710 | #endif /* HAVE_EC_KEY_METHOD_NEW */ | ||
707 | 711 | ||
708 | static struct sshkey * | 712 | static struct sshkey * |
709 | pkcs11_fetch_rsa_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, | 713 | pkcs11_fetch_rsa_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, |
@@ -808,7 +812,9 @@ pkcs11_fetch_x509_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, | |||
808 | EC_KEY *ec = NULL; | 812 | EC_KEY *ec = NULL; |
809 | struct sshkey *key = NULL; | 813 | struct sshkey *key = NULL; |
810 | int i; | 814 | int i; |
815 | #ifdef HAVE_EC_KEY_METHOD_NEW | ||
811 | int nid; | 816 | int nid; |
817 | #endif | ||
812 | const u_char *cp; | 818 | const u_char *cp; |
813 | 819 | ||
814 | memset(&cert_attr, 0, sizeof(cert_attr)); | 820 | memset(&cert_attr, 0, sizeof(cert_attr)); |
@@ -890,6 +896,7 @@ pkcs11_fetch_x509_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, | |||
890 | key->type = KEY_RSA; | 896 | key->type = KEY_RSA; |
891 | key->flags |= SSHKEY_FLAG_EXT; | 897 | key->flags |= SSHKEY_FLAG_EXT; |
892 | rsa = NULL; /* now owned by key */ | 898 | rsa = NULL; /* now owned by key */ |
899 | #ifdef HAVE_EC_KEY_METHOD_NEW | ||
893 | } else if (EVP_PKEY_base_id(evp) == EVP_PKEY_EC) { | 900 | } else if (EVP_PKEY_base_id(evp) == EVP_PKEY_EC) { |
894 | if (EVP_PKEY_get0_EC_KEY(evp) == NULL) { | 901 | if (EVP_PKEY_get0_EC_KEY(evp) == NULL) { |
895 | error("invalid x509; no ec key"); | 902 | error("invalid x509; no ec key"); |
@@ -920,6 +927,7 @@ pkcs11_fetch_x509_pubkey(struct pkcs11_provider *p, CK_ULONG slotidx, | |||
920 | key->type = KEY_ECDSA; | 927 | key->type = KEY_ECDSA; |
921 | key->flags |= SSHKEY_FLAG_EXT; | 928 | key->flags |= SSHKEY_FLAG_EXT; |
922 | ec = NULL; /* now owned by key */ | 929 | ec = NULL; /* now owned by key */ |
930 | #endif /* HAVE_EC_KEY_METHOD_NEW */ | ||
923 | } else | 931 | } else |
924 | error("unknown certificate key type"); | 932 | error("unknown certificate key type"); |
925 | 933 | ||
@@ -1103,9 +1111,11 @@ pkcs11_fetch_keys(struct pkcs11_provider *p, CK_ULONG slotidx, | |||
1103 | case CKK_RSA: | 1111 | case CKK_RSA: |
1104 | key = pkcs11_fetch_rsa_pubkey(p, slotidx, &obj); | 1112 | key = pkcs11_fetch_rsa_pubkey(p, slotidx, &obj); |
1105 | break; | 1113 | break; |
1114 | #ifdef HAVE_EC_KEY_METHOD_NEW | ||
1106 | case CKK_ECDSA: | 1115 | case CKK_ECDSA: |
1107 | key = pkcs11_fetch_ecdsa_pubkey(p, slotidx, &obj); | 1116 | key = pkcs11_fetch_ecdsa_pubkey(p, slotidx, &obj); |
1108 | break; | 1117 | break; |
1118 | #endif /* HAVE_EC_KEY_METHOD_NEW */ | ||
1109 | default: | 1119 | default: |
1110 | /* XXX print key type? */ | 1120 | /* XXX print key type? */ |
1111 | error("skipping unsupported key type"); | 1121 | error("skipping unsupported key type"); |