2 * GnuTLS PKCS#11 support
3 * Copyright (C) 2010 Free Software Foundation
5 * Author: Nikos Mavrogiannopoulos
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 #include <gnutls_int.h>
24 #include <pakchois/pakchois.h>
25 #include <gnutls/pkcs11.h>
29 #include <gnutls_errors.h>
30 #include <gnutls_datum.h>
31 #include <pkcs11_int.h>
32 #include <gnutls/abstract.h>
33 #include <gnutls_pk.h>
35 #include <openpgp/openpgp_int.h>
36 #include <pkcs11_int.h>
37 #include <gnutls_num.h>
38 #include <x509/common.h>
40 #include <abstract_int.h>
42 #define PK_PEM_HEADER "PUBLIC KEY"
45 struct gnutls_pubkey_st
47 gnutls_pk_algorithm_t pk_algorithm
;
48 unsigned int bits
; /* an indication of the security parameter */
50 /* the size of params depends on the public
53 * [1] is public exponent
59 bigint_t params
[MAX_PUBLIC_PARAMS_SIZE
];
60 int params_size
; /* holds the size of MPI params */
62 unsigned int key_usage
; /* bits from GNUTLS_KEY_* */
65 static int pubkey_to_bits(gnutls_pk_algorithm_t pk
, bigint_t
* params
, int params_size
)
70 return _gnutls_mpi_get_nbits(params
[0]);
72 if (params_size
< 3) return 0;
73 return _gnutls_mpi_get_nbits(params
[3]);
80 * gnutls_pubkey_get_pk_algorithm:
81 * @key: should contain a #gnutls_pubkey_t structure
82 * @bits: If set will return the number of bits of the parameters (may be NULL)
84 * This function will return the public key algorithm of a public
85 * key and if possible will return a number of bits that indicates
86 * the security parameter of the key.
88 * Returns: a member of the #gnutls_pk_algorithm_t enumeration on
89 * success, or a negative value on error.
92 gnutls_pubkey_get_pk_algorithm (gnutls_pubkey_t key
, unsigned int *bits
)
97 return key
->pk_algorithm
;
101 * gnutls_pubkey_get_key_usage:
102 * @key: should contain a #gnutls_pubkey_t structure
103 * @usage: If set will return the number of bits of the parameters (may be NULL)
105 * This function will return the key usage of the public key.
107 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
108 * negative error value.
111 gnutls_pubkey_get_key_usage (gnutls_pubkey_t key
, unsigned int *usage
)
114 *usage
= key
->key_usage
;
120 * gnutls_pubkey_init:
121 * @key: The structure to be initialized
123 * This function will initialize an public key structure.
125 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
126 * negative error value.
129 gnutls_pubkey_init (gnutls_pubkey_t
* key
)
131 *key
= gnutls_calloc (1, sizeof (struct gnutls_pubkey_st
));
135 return GNUTLS_E_MEMORY_ERROR
;
142 * gnutls_pubkey_deinit:
143 * @key: The structure to be deinitialized
145 * This function will deinitialize a public key structure.
148 gnutls_pubkey_deinit (gnutls_pubkey_t key
)
152 for (i
= 0; i
< key
->params_size
; i
++)
154 _gnutls_mpi_release (&key
->params
[i
]);
161 * gnutls_pubkey_import_x509:
162 * @key: The public key
163 * @crt: The certificate to be imported
164 * @flags: should be zero
166 * This function will import the given public key to the abstract
167 * #gnutls_pubkey_t structure.
169 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
170 * negative error value.
173 gnutls_pubkey_import_x509 (gnutls_pubkey_t key
, gnutls_x509_crt_t crt
,
178 key
->pk_algorithm
= gnutls_x509_crt_get_pk_algorithm (crt
, &key
->bits
);
180 ret
= gnutls_x509_crt_get_key_usage (crt
, &key
->key_usage
, NULL
);
184 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
185 switch (key
->pk_algorithm
)
188 ret
= _gnutls_x509_crt_get_mpis (crt
, key
->params
, &key
->params_size
);
196 ret
= _gnutls_x509_crt_get_mpis (crt
, key
->params
, &key
->params_size
);
206 return GNUTLS_E_INVALID_REQUEST
;
213 * gnutls_pubkey_import_privkey: Imports the public key from a private
214 * @key: The public key
215 * @pkey: The private key
216 * @usage: GNUTLS_KEY_* key usage flags.
217 * @flags: should be zero
219 * This function will import the given public key to the abstract
220 * #gnutls_pubkey_t structure.
222 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
223 * negative error value.
228 gnutls_pubkey_import_privkey (gnutls_pubkey_t key
, gnutls_privkey_t pkey
,
229 unsigned int usage
, unsigned int flags
)
231 key
->pk_algorithm
= gnutls_privkey_get_pk_algorithm (pkey
, &key
->bits
);
233 key
->key_usage
= usage
;
235 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
237 return _gnutls_privkey_get_public_mpis (pkey
, key
->params
,
242 * gnutls_pubkey_get_preferred_hash_algorithm:
243 * @key: Holds the certificate
244 * @hash: The result of the call with the hash algorithm used for signature
245 * @mand: If non zero it means that the algorithm MUST use this hash. May be NULL.
247 * This function will read the certifcate and return the appropriate digest
248 * algorithm to use for signing with this certificate. Some certificates (i.e.
249 * DSA might not be able to sign without the preferred algorithm).
251 * Returns: the 0 if the hash algorithm is found. A negative value is
257 gnutls_pubkey_get_preferred_hash_algorithm (gnutls_pubkey_t key
,
258 gnutls_digest_algorithm_t
*
259 hash
, unsigned int *mand
)
266 return GNUTLS_E_INVALID_REQUEST
;
269 ret
= _gnutls_pk_get_hash_algorithm (key
->pk_algorithm
,
270 key
->params
, key
->params_size
,
278 * gnutls_pubkey_import_pkcs11: Imports a public key from a pkcs11 key
279 * @key: The public key
280 * @obj: The parameters to be imported
281 * @flags: should be zero
283 * This function will import the given public key to the abstract
284 * #gnutls_pubkey_t structure.
286 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
287 * negative error value.
290 gnutls_pubkey_import_pkcs11 (gnutls_pubkey_t key
,
291 gnutls_pkcs11_obj_t obj
, unsigned int flags
)
295 ret
= gnutls_pkcs11_obj_get_type (obj
);
296 if (ret
!= GNUTLS_PKCS11_OBJ_PUBKEY
)
299 return GNUTLS_E_INVALID_REQUEST
;
302 key
->key_usage
= obj
->key_usage
;
304 switch (obj
->pk_algorithm
)
307 ret
= gnutls_pubkey_import_rsa_raw (key
, &obj
->pubkey
[0],
311 ret
= gnutls_pubkey_import_dsa_raw (key
, &obj
->pubkey
[0],
313 &obj
->pubkey
[2], &obj
->pubkey
[3]);
317 return GNUTLS_E_UNIMPLEMENTED_FEATURE
;
329 #ifdef ENABLE_OPENPGP
331 * gnutls_pubkey_import_openpgp: Imports a public key from an openpgp key
332 * @key: The public key
333 * @crt: The certificate to be imported
334 * @flags: should be zero
336 * This function will import the given public key to the abstract
337 * #gnutls_pubkey_t structure. The subkey set as preferred will be
338 * imported or the master key otherwise.
340 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
341 * negative error value.
344 gnutls_pubkey_import_openpgp (gnutls_pubkey_t key
,
345 gnutls_openpgp_crt_t crt
,
351 uint8_t keyid
[GNUTLS_OPENPGP_KEYID_SIZE
];
353 ret
= gnutls_openpgp_crt_get_preferred_key_id (crt
, keyid
);
354 if (ret
== GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR
)
356 key
->pk_algorithm
= gnutls_openpgp_crt_get_pk_algorithm (crt
, &key
->bits
);
358 ret
= gnutls_openpgp_crt_get_key_usage (crt
, &key
->key_usage
);
372 KEYID_IMPORT (kid32
, keyid
);
375 idx
= gnutls_openpgp_crt_get_subkey_idx (crt
, keyid
);
377 ret
= gnutls_openpgp_crt_get_subkey_usage (crt
, idx
, &key
->key_usage
);
381 key
->pk_algorithm
= gnutls_openpgp_crt_get_subkey_pk_algorithm (crt
, idx
, NULL
);
384 switch (key
->pk_algorithm
)
388 _gnutls_openpgp_crt_get_mpis (crt
, k
, key
->params
,
398 _gnutls_openpgp_crt_get_mpis (crt
, k
, key
->params
,
408 return GNUTLS_E_INVALID_REQUEST
;
417 * gnutls_pubkey_export:
418 * @key: Holds the certificate
419 * @format: the format of output params. One of PEM or DER.
420 * @output_data: will contain a certificate PEM or DER encoded
421 * @output_data_size: holds the size of output_data (and will be
422 * replaced by the actual size of parameters)
424 * This function will export the certificate to DER or PEM format.
426 * If the buffer provided is not long enough to hold the output, then
427 * *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
430 * If the structure is PEM encoded, it will have a header
431 * of "BEGIN CERTIFICATE".
433 * Return value: In case of failure a negative value will be
434 * returned, and 0 on success.
437 gnutls_pubkey_export (gnutls_pubkey_t key
,
438 gnutls_x509_crt_fmt_t format
, void *output_data
,
439 size_t * output_data_size
)
442 ASN1_TYPE spk
= ASN1_TYPE_EMPTY
;
447 return GNUTLS_E_INVALID_REQUEST
;
450 if ((result
= asn1_create_element
451 (_gnutls_get_pkix (), "PKIX1.SubjectPublicKeyInfo", &spk
))
455 return _gnutls_asn2err (result
);
459 _gnutls_x509_encode_and_copy_PKI_params (spk
, "",
461 key
->params
, key
->params_size
);
468 result
= _gnutls_x509_export_int_named (spk
, "",
469 format
, PK_PEM_HEADER
,
470 output_data
, output_data_size
);
480 asn1_delete_structure (&spk
);
487 * gnutls_pubkey_get_key_id:
488 * @key: Holds the public key
489 * @flags: should be 0 for now
490 * @output_data: will contain the key ID
491 * @output_data_size: holds the size of output_data (and will be
492 * replaced by the actual size of parameters)
494 * This function will return a unique ID the depends on the public
495 * key parameters. This ID can be used in checking whether a
496 * certificate corresponds to the given public key.
498 * If the buffer provided is not long enough to hold the output, then
499 * *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
500 * be returned. The output will normally be a SHA-1 hash output,
503 * Return value: In case of failure a negative value will be
504 * returned, and 0 on success.
507 gnutls_pubkey_get_key_id (gnutls_pubkey_t key
, unsigned int flags
,
508 unsigned char *output_data
,
509 size_t * output_data_size
)
516 return GNUTLS_E_INVALID_REQUEST
;
520 _gnutls_get_key_id (key
->pk_algorithm
, key
->params
,
521 key
->params_size
, output_data
, output_data_size
);
532 * gnutls_pubkey_get_pk_rsa_raw:
533 * @key: Holds the certificate
534 * @m: will hold the modulus
535 * @e: will hold the public exponent
537 * This function will export the RSA public key's parameters found in
538 * the given structure. The new parameters will be allocated using
539 * gnutls_malloc() and will be stored in the appropriate datum.
541 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error.
544 gnutls_pubkey_get_pk_rsa_raw (gnutls_pubkey_t key
,
545 gnutls_datum_t
* m
, gnutls_datum_t
* e
)
552 return GNUTLS_E_INVALID_REQUEST
;
555 if (key
->pk_algorithm
!= GNUTLS_PK_RSA
)
558 return GNUTLS_E_INVALID_REQUEST
;
561 ret
= _gnutls_mpi_dprint (key
->params
[0], m
);
568 ret
= _gnutls_mpi_dprint (key
->params
[1], e
);
572 _gnutls_free_datum (m
);
580 * gnutls_pubkey_get_pk_dsa_raw:
581 * @key: Holds the public key
582 * @p: will hold the p
583 * @q: will hold the q
584 * @g: will hold the g
585 * @y: will hold the y
587 * This function will export the DSA public key's parameters found in
588 * the given certificate. The new parameters will be allocated using
589 * gnutls_malloc() and will be stored in the appropriate datum.
591 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error.
594 gnutls_pubkey_get_pk_dsa_raw (gnutls_pubkey_t key
,
595 gnutls_datum_t
* p
, gnutls_datum_t
* q
,
596 gnutls_datum_t
* g
, gnutls_datum_t
* y
)
603 return GNUTLS_E_INVALID_REQUEST
;
606 if (key
->pk_algorithm
!= GNUTLS_PK_DSA
)
609 return GNUTLS_E_INVALID_REQUEST
;
613 ret
= _gnutls_mpi_dprint (key
->params
[0], p
);
621 ret
= _gnutls_mpi_dprint (key
->params
[1], q
);
625 _gnutls_free_datum (p
);
631 ret
= _gnutls_mpi_dprint (key
->params
[2], g
);
635 _gnutls_free_datum (p
);
636 _gnutls_free_datum (q
);
642 ret
= _gnutls_mpi_dprint (key
->params
[3], y
);
646 _gnutls_free_datum (p
);
647 _gnutls_free_datum (g
);
648 _gnutls_free_datum (q
);
656 * gnutls_pubkey_import:
657 * @key: The structure to store the parsed public key.
658 * @data: The DER or PEM encoded certificate.
659 * @format: One of DER or PEM
661 * This function will convert the given DER or PEM encoded Public key
662 * to the native gnutls_pubkey_t format.The output will be stored * in @ key.
663 * If the Certificate is PEM encoded it should have a header of "PUBLIC KEY".
665 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
666 * negative error value.
669 gnutls_pubkey_import (gnutls_pubkey_t key
,
670 const gnutls_datum_t
* data
,
671 gnutls_x509_crt_fmt_t format
)
673 int result
= 0, need_free
= 0;
674 gnutls_datum_t _data
;
680 return GNUTLS_E_INVALID_REQUEST
;
683 _data
.data
= data
->data
;
684 _data
.size
= data
->size
;
686 /* If the Certificate is in PEM format then decode it
688 if (format
== GNUTLS_X509_FMT_PEM
)
692 /* Try the first header */
694 _gnutls_fbase64_decode (PK_PEM_HEADER
, data
->data
, data
->size
, &out
);
699 result
= GNUTLS_E_INTERNAL_ERROR
;
710 if ((result
= asn1_create_element
711 (_gnutls_get_pkix (), "PKIX1.SubjectPublicKeyInfo", &spk
))
715 result
= _gnutls_asn2err (result
);
719 result
= asn1_der_decoding (&spk
, _data
.data
, _data
.size
, NULL
);
720 if (result
!= ASN1_SUCCESS
)
723 result
= _gnutls_asn2err (result
);
727 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
728 result
= _gnutls_get_asn_mpis (spk
, "", key
->params
, &key
->params_size
);
735 /* this has already been called by get_asn_mpis() thus it cannot
738 key
->pk_algorithm
= _gnutls_x509_get_pk_algorithm (spk
, "", NULL
);
739 key
->bits
= pubkey_to_bits(key
->pk_algorithm
, key
->params
, key
->params_size
);
744 asn1_delete_structure (&spk
);
747 _gnutls_free_datum (&_data
);
752 * gnutls_x509_crt_set_pubkey:
753 * @crt: should contain a #gnutls_x509_crt_t structure
754 * @key: holds a public key
756 * This function will set the public parameters from the given public
757 * key to the request.
759 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
760 * negative error value.
763 gnutls_x509_crt_set_pubkey (gnutls_x509_crt_t crt
, gnutls_pubkey_t key
)
770 return GNUTLS_E_INVALID_REQUEST
;
773 result
= _gnutls_x509_encode_and_copy_PKI_params (crt
->cert
,
774 "tbsCertificate.subjectPublicKeyInfo",
786 gnutls_x509_crt_set_key_usage (crt
, key
->key_usage
);
792 * gnutls_x509_crq_set_pubkey:
793 * @crq: should contain a #gnutls_x509_crq_t structure
794 * @key: holds a public key
796 * This function will set the public parameters from the given public
797 * key to the request.
799 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
800 * negative error value.
803 gnutls_x509_crq_set_pubkey (gnutls_x509_crq_t crq
, gnutls_pubkey_t key
)
810 return GNUTLS_E_INVALID_REQUEST
;
813 result
= _gnutls_x509_encode_and_copy_PKI_params
815 "certificationRequestInfo.subjectPKInfo",
816 key
->pk_algorithm
, key
->params
, key
->params_size
);
825 gnutls_x509_crq_set_key_usage (crq
, key
->key_usage
);
831 * gnutls_pubkey_set_key_usage:
832 * @key: a certificate of type #gnutls_x509_crt_t
833 * @usage: an ORed sequence of the GNUTLS_KEY_* elements.
835 * This function will set the key usage flags of the public key. This
836 * is only useful if the key is to be exported to a certificate or
837 * certificate request.
839 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
840 * negative error value.
843 gnutls_pubkey_set_key_usage (gnutls_pubkey_t key
, unsigned int usage
)
845 key
->key_usage
= usage
;
851 * gnutls_pubkey_import_pkcs11_url:
852 * @key: A key of type #gnutls_pubkey_t
853 * @url: A PKCS 11 url
854 * @flags: One of GNUTLS_PKCS11_OBJ_* flags
856 * This function will import a PKCS 11 certificate to a #gnutls_pubkey_t
859 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
860 * negative error value.
864 gnutls_pubkey_import_pkcs11_url (gnutls_pubkey_t key
, const char *url
,
867 gnutls_pkcs11_obj_t pcrt
;
870 ret
= gnutls_pkcs11_obj_init (&pcrt
);
877 ret
= gnutls_pkcs11_obj_import_url (pcrt
, url
, flags
);
884 ret
= gnutls_pubkey_import_pkcs11 (key
, pcrt
, 0);
894 gnutls_pkcs11_obj_deinit (pcrt
);
900 * gnutls_pubkey_import_rsa_raw:
901 * @key: Is a structure will hold the parameters
902 * @m: holds the modulus
903 * @e: holds the public exponent
905 * This function will replace the parameters in the given structure.
906 * The new parameters should be stored in the appropriate
909 * Returns: %GNUTLS_E_SUCCESS on success, or an negative error code.
912 gnutls_pubkey_import_rsa_raw (gnutls_pubkey_t key
,
913 const gnutls_datum_t
* m
,
914 const gnutls_datum_t
* e
)
921 return GNUTLS_E_INVALID_REQUEST
;
925 if (_gnutls_mpi_scan_nz (&key
->params
[0], m
->data
, siz
))
928 return GNUTLS_E_MPI_SCAN_FAILED
;
932 if (_gnutls_mpi_scan_nz (&key
->params
[1], e
->data
, siz
))
935 _gnutls_mpi_release (&key
->params
[0]);
936 return GNUTLS_E_MPI_SCAN_FAILED
;
939 key
->params_size
= RSA_PUBLIC_PARAMS
;
940 key
->pk_algorithm
= GNUTLS_PK_RSA
;
941 key
->bits
= pubkey_to_bits(GNUTLS_PK_RSA
, key
->params
, key
->params_size
);
947 * gnutls_pubkey_import_dsa_raw:
948 * @key: The structure to store the parsed key
954 * This function will convert the given DSA raw parameters to the
955 * native #gnutls_pubkey_t format. The output will be stored
958 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
959 * negative error value.
962 gnutls_pubkey_import_dsa_raw (gnutls_pubkey_t key
,
963 const gnutls_datum_t
* p
,
964 const gnutls_datum_t
* q
,
965 const gnutls_datum_t
* g
,
966 const gnutls_datum_t
* y
)
973 return GNUTLS_E_INVALID_REQUEST
;
977 if (_gnutls_mpi_scan_nz (&key
->params
[0], p
->data
, siz
))
980 return GNUTLS_E_MPI_SCAN_FAILED
;
984 if (_gnutls_mpi_scan_nz (&key
->params
[1], q
->data
, siz
))
987 _gnutls_mpi_release (&key
->params
[0]);
988 return GNUTLS_E_MPI_SCAN_FAILED
;
992 if (_gnutls_mpi_scan_nz (&key
->params
[2], g
->data
, siz
))
995 _gnutls_mpi_release (&key
->params
[1]);
996 _gnutls_mpi_release (&key
->params
[0]);
997 return GNUTLS_E_MPI_SCAN_FAILED
;
1001 if (_gnutls_mpi_scan_nz (&key
->params
[3], y
->data
, siz
))
1004 _gnutls_mpi_release (&key
->params
[2]);
1005 _gnutls_mpi_release (&key
->params
[1]);
1006 _gnutls_mpi_release (&key
->params
[0]);
1007 return GNUTLS_E_MPI_SCAN_FAILED
;
1010 key
->params_size
= DSA_PUBLIC_PARAMS
;
1011 key
->pk_algorithm
= GNUTLS_PK_DSA
;
1012 key
->bits
= pubkey_to_bits(GNUTLS_PK_DSA
, key
->params
, key
->params_size
);
1019 * gnutls_pubkey_verify_data:
1020 * @pubkey: Holds the public key
1021 * @flags: should be 0 for now
1022 * @data: holds the data to be signed
1023 * @signature: contains the signature
1025 * This function will verify the given signed data, using the
1026 * parameters from the certificate.
1028 * Returns: In case of a verification failure
1029 * %GNUTLS_E_PK_SIG_VERIFY_FAILED is returned, and a positive code
1035 gnutls_pubkey_verify_data (gnutls_pubkey_t pubkey
, unsigned int flags
,
1036 const gnutls_datum_t
* data
,
1037 const gnutls_datum_t
* signature
)
1044 return GNUTLS_E_INVALID_REQUEST
;
1047 ret
= pubkey_verify_sig( data
, NULL
, signature
, pubkey
->pk_algorithm
,
1048 pubkey
->params
, pubkey
->params_size
);
1059 * gnutls_pubkey_verify_hash:
1060 * @key: Holds the certificate
1061 * @flags: should be 0 for now
1062 * @hash: holds the hash digest to be verified
1063 * @signature: contains the signature
1065 * This function will verify the given signed digest, using the
1066 * parameters from the certificate.
1068 * Returns: In case of a verification failure %GNUTLS_E_PK_SIG_VERIFY_FAILED
1069 * is returned, and a positive code on success.
1072 gnutls_pubkey_verify_hash (gnutls_pubkey_t key
, unsigned int flags
,
1073 const gnutls_datum_t
* hash
,
1074 const gnutls_datum_t
* signature
)
1081 return GNUTLS_E_INVALID_REQUEST
;
1085 pubkey_verify_sig (NULL
, hash
, signature
, key
->pk_algorithm
,
1086 key
->params
, key
->params_size
);
1092 * gnutls_pubkey_get_verify_algorithm:
1093 * @key: Holds the certificate
1094 * @signature: contains the signature
1095 * @hash: The result of the call with the hash algorithm used for signature
1097 * This function will read the certifcate and the signed data to
1098 * determine the hash algorithm used to generate the signature.
1100 * Returns: the 0 if the hash algorithm is found. A negative value is
1101 * returned on error.
1104 gnutls_pubkey_get_verify_algorithm (gnutls_pubkey_t key
,
1105 const gnutls_datum_t
* signature
,
1106 gnutls_digest_algorithm_t
* hash
)
1111 return GNUTLS_E_INVALID_REQUEST
;
1114 return _gnutls_x509_verify_algorithm ((gnutls_mac_algorithm_t
*)
1117 key
->params
, key
->params_size
);