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 <gnutls/pkcs11.h>
27 #include <gnutls_errors.h>
28 #include <gnutls_datum.h>
29 #include <pkcs11_int.h>
30 #include <gnutls/abstract.h>
31 #include <gnutls_pk.h>
33 #include <openpgp/openpgp_int.h>
34 #include <gnutls_num.h>
35 #include <x509/common.h>
37 #include <abstract_int.h>
39 #define PK_PEM_HEADER "PUBLIC KEY"
42 struct gnutls_pubkey_st
44 gnutls_pk_algorithm_t pk_algorithm
;
45 unsigned int bits
; /* an indication of the security parameter */
47 /* the size of params depends on the public
50 * [1] is public exponent
56 bigint_t params
[MAX_PUBLIC_PARAMS_SIZE
];
57 int params_size
; /* holds the size of MPI params */
59 unsigned int key_usage
; /* bits from GNUTLS_KEY_* */
62 static int pubkey_to_bits(gnutls_pk_algorithm_t pk
, bigint_t
* params
, int params_size
)
67 return _gnutls_mpi_get_nbits(params
[0]);
69 if (params_size
< 3) return 0;
70 return _gnutls_mpi_get_nbits(params
[3]);
77 * gnutls_pubkey_get_pk_algorithm:
78 * @key: should contain a #gnutls_pubkey_t structure
79 * @bits: If set will return the number of bits of the parameters (may be NULL)
81 * This function will return the public key algorithm of a public
82 * key and if possible will return a number of bits that indicates
83 * the security parameter of the key.
85 * Returns: a member of the #gnutls_pk_algorithm_t enumeration on
86 * success, or a negative value on error.
89 gnutls_pubkey_get_pk_algorithm (gnutls_pubkey_t key
, unsigned int *bits
)
94 return key
->pk_algorithm
;
98 * gnutls_pubkey_get_key_usage:
99 * @key: should contain a #gnutls_pubkey_t structure
100 * @usage: If set will return the number of bits of the parameters (may be NULL)
102 * This function will return the key usage of the public key.
104 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
105 * negative error value.
108 gnutls_pubkey_get_key_usage (gnutls_pubkey_t key
, unsigned int *usage
)
111 *usage
= key
->key_usage
;
117 * gnutls_pubkey_init:
118 * @key: The structure to be initialized
120 * This function will initialize an public key structure.
122 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
123 * negative error value.
126 gnutls_pubkey_init (gnutls_pubkey_t
* key
)
128 *key
= gnutls_calloc (1, sizeof (struct gnutls_pubkey_st
));
132 return GNUTLS_E_MEMORY_ERROR
;
139 * gnutls_pubkey_deinit:
140 * @key: The structure to be deinitialized
142 * This function will deinitialize a public key structure.
145 gnutls_pubkey_deinit (gnutls_pubkey_t key
)
149 for (i
= 0; i
< key
->params_size
; i
++)
151 _gnutls_mpi_release (&key
->params
[i
]);
158 * gnutls_pubkey_import_x509:
159 * @key: The public key
160 * @crt: The certificate to be imported
161 * @flags: should be zero
163 * This function will import the given public key to the abstract
164 * #gnutls_pubkey_t structure.
166 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
167 * negative error value.
170 gnutls_pubkey_import_x509 (gnutls_pubkey_t key
, gnutls_x509_crt_t crt
,
175 key
->pk_algorithm
= gnutls_x509_crt_get_pk_algorithm (crt
, &key
->bits
);
177 ret
= gnutls_x509_crt_get_key_usage (crt
, &key
->key_usage
, NULL
);
181 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
182 switch (key
->pk_algorithm
)
185 ret
= _gnutls_x509_crt_get_mpis (crt
, key
->params
, &key
->params_size
);
193 ret
= _gnutls_x509_crt_get_mpis (crt
, key
->params
, &key
->params_size
);
203 return GNUTLS_E_INVALID_REQUEST
;
210 * gnutls_pubkey_import_privkey: Imports the public key from a private
211 * @key: The public key
212 * @pkey: The private key
213 * @usage: GNUTLS_KEY_* key usage flags.
214 * @flags: should be zero
216 * This function will import the given public key to the abstract
217 * #gnutls_pubkey_t structure.
219 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
220 * negative error value.
225 gnutls_pubkey_import_privkey (gnutls_pubkey_t key
, gnutls_privkey_t pkey
,
226 unsigned int usage
, unsigned int flags
)
228 key
->pk_algorithm
= gnutls_privkey_get_pk_algorithm (pkey
, &key
->bits
);
230 key
->key_usage
= usage
;
232 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
234 return _gnutls_privkey_get_public_mpis (pkey
, key
->params
,
239 * gnutls_pubkey_get_preferred_hash_algorithm:
240 * @key: Holds the certificate
241 * @hash: The result of the call with the hash algorithm used for signature
242 * @mand: If non zero it means that the algorithm MUST use this hash. May be NULL.
244 * This function will read the certifcate and return the appropriate digest
245 * algorithm to use for signing with this certificate. Some certificates (i.e.
246 * DSA might not be able to sign without the preferred algorithm).
248 * Returns: the 0 if the hash algorithm is found. A negative value is
254 gnutls_pubkey_get_preferred_hash_algorithm (gnutls_pubkey_t key
,
255 gnutls_digest_algorithm_t
*
256 hash
, unsigned int *mand
)
263 return GNUTLS_E_INVALID_REQUEST
;
266 ret
= _gnutls_pk_get_hash_algorithm (key
->pk_algorithm
,
267 key
->params
, key
->params_size
,
276 * gnutls_pubkey_import_pkcs11: Imports a public key from a pkcs11 key
277 * @key: The public key
278 * @obj: The parameters to be imported
279 * @flags: should be zero
281 * This function will import the given public key to the abstract
282 * #gnutls_pubkey_t structure.
284 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
285 * negative error value.
288 gnutls_pubkey_import_pkcs11 (gnutls_pubkey_t key
,
289 gnutls_pkcs11_obj_t obj
, unsigned int flags
)
293 ret
= gnutls_pkcs11_obj_get_type (obj
);
294 if (ret
!= GNUTLS_PKCS11_OBJ_PUBKEY
)
297 return GNUTLS_E_INVALID_REQUEST
;
300 key
->key_usage
= obj
->key_usage
;
302 switch (obj
->pk_algorithm
)
305 ret
= gnutls_pubkey_import_rsa_raw (key
, &obj
->pubkey
[0],
309 ret
= gnutls_pubkey_import_dsa_raw (key
, &obj
->pubkey
[0],
311 &obj
->pubkey
[2], &obj
->pubkey
[3]);
315 return GNUTLS_E_UNIMPLEMENTED_FEATURE
;
327 #endif /* ENABLE_PKCS11 */
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_lz (key
->params
[0], m
);
568 ret
= _gnutls_mpi_dprint_lz (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_lz (key
->params
[0], p
);
621 ret
= _gnutls_mpi_dprint_lz (key
->params
[1], q
);
625 _gnutls_free_datum (p
);
631 ret
= _gnutls_mpi_dprint_lz (key
->params
[2], g
);
635 _gnutls_free_datum (p
);
636 _gnutls_free_datum (q
);
642 ret
= _gnutls_mpi_dprint_lz (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
;
853 * gnutls_pubkey_import_pkcs11_url:
854 * @key: A key of type #gnutls_pubkey_t
855 * @url: A PKCS 11 url
856 * @flags: One of GNUTLS_PKCS11_OBJ_* flags
858 * This function will import a PKCS 11 certificate to a #gnutls_pubkey_t
861 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
862 * negative error value.
866 gnutls_pubkey_import_pkcs11_url (gnutls_pubkey_t key
, const char *url
,
869 gnutls_pkcs11_obj_t pcrt
;
872 ret
= gnutls_pkcs11_obj_init (&pcrt
);
879 ret
= gnutls_pkcs11_obj_import_url (pcrt
, url
, flags
);
886 ret
= gnutls_pubkey_import_pkcs11 (key
, pcrt
, 0);
896 gnutls_pkcs11_obj_deinit (pcrt
);
901 #endif /* ENABLE_PKCS11 */
904 * gnutls_pubkey_import_rsa_raw:
905 * @key: Is a structure will hold the parameters
906 * @m: holds the modulus
907 * @e: holds the public exponent
909 * This function will replace the parameters in the given structure.
910 * The new parameters should be stored in the appropriate
913 * Returns: %GNUTLS_E_SUCCESS on success, or an negative error code.
916 gnutls_pubkey_import_rsa_raw (gnutls_pubkey_t key
,
917 const gnutls_datum_t
* m
,
918 const gnutls_datum_t
* e
)
925 return GNUTLS_E_INVALID_REQUEST
;
929 if (_gnutls_mpi_scan_nz (&key
->params
[0], m
->data
, siz
))
932 return GNUTLS_E_MPI_SCAN_FAILED
;
936 if (_gnutls_mpi_scan_nz (&key
->params
[1], e
->data
, siz
))
939 _gnutls_mpi_release (&key
->params
[0]);
940 return GNUTLS_E_MPI_SCAN_FAILED
;
943 key
->params_size
= RSA_PUBLIC_PARAMS
;
944 key
->pk_algorithm
= GNUTLS_PK_RSA
;
945 key
->bits
= pubkey_to_bits(GNUTLS_PK_RSA
, key
->params
, key
->params_size
);
951 * gnutls_pubkey_import_dsa_raw:
952 * @key: The structure to store the parsed key
958 * This function will convert the given DSA raw parameters to the
959 * native #gnutls_pubkey_t format. The output will be stored
962 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
963 * negative error value.
966 gnutls_pubkey_import_dsa_raw (gnutls_pubkey_t key
,
967 const gnutls_datum_t
* p
,
968 const gnutls_datum_t
* q
,
969 const gnutls_datum_t
* g
,
970 const gnutls_datum_t
* y
)
977 return GNUTLS_E_INVALID_REQUEST
;
981 if (_gnutls_mpi_scan_nz (&key
->params
[0], p
->data
, siz
))
984 return GNUTLS_E_MPI_SCAN_FAILED
;
988 if (_gnutls_mpi_scan_nz (&key
->params
[1], q
->data
, siz
))
991 _gnutls_mpi_release (&key
->params
[0]);
992 return GNUTLS_E_MPI_SCAN_FAILED
;
996 if (_gnutls_mpi_scan_nz (&key
->params
[2], g
->data
, siz
))
999 _gnutls_mpi_release (&key
->params
[1]);
1000 _gnutls_mpi_release (&key
->params
[0]);
1001 return GNUTLS_E_MPI_SCAN_FAILED
;
1005 if (_gnutls_mpi_scan_nz (&key
->params
[3], y
->data
, siz
))
1008 _gnutls_mpi_release (&key
->params
[2]);
1009 _gnutls_mpi_release (&key
->params
[1]);
1010 _gnutls_mpi_release (&key
->params
[0]);
1011 return GNUTLS_E_MPI_SCAN_FAILED
;
1014 key
->params_size
= DSA_PUBLIC_PARAMS
;
1015 key
->pk_algorithm
= GNUTLS_PK_DSA
;
1016 key
->bits
= pubkey_to_bits(GNUTLS_PK_DSA
, key
->params
, key
->params_size
);
1023 * gnutls_pubkey_verify_data:
1024 * @pubkey: Holds the public key
1025 * @flags: should be 0 for now
1026 * @data: holds the data to be signed
1027 * @signature: contains the signature
1029 * This function will verify the given signed data, using the
1030 * parameters from the certificate.
1032 * Returns: In case of a verification failure
1033 * %GNUTLS_E_PK_SIG_VERIFY_FAILED is returned, and a positive code
1039 gnutls_pubkey_verify_data (gnutls_pubkey_t pubkey
, unsigned int flags
,
1040 const gnutls_datum_t
* data
,
1041 const gnutls_datum_t
* signature
)
1048 return GNUTLS_E_INVALID_REQUEST
;
1051 ret
= pubkey_verify_sig( data
, NULL
, signature
, pubkey
->pk_algorithm
,
1052 pubkey
->params
, pubkey
->params_size
);
1063 * gnutls_pubkey_verify_hash:
1064 * @key: Holds the certificate
1065 * @flags: should be 0 for now
1066 * @hash: holds the hash digest to be verified
1067 * @signature: contains the signature
1069 * This function will verify the given signed digest, using the
1070 * parameters from the certificate.
1072 * Returns: In case of a verification failure %GNUTLS_E_PK_SIG_VERIFY_FAILED
1073 * is returned, and a positive code on success.
1076 gnutls_pubkey_verify_hash (gnutls_pubkey_t key
, unsigned int flags
,
1077 const gnutls_datum_t
* hash
,
1078 const gnutls_datum_t
* signature
)
1085 return GNUTLS_E_INVALID_REQUEST
;
1089 pubkey_verify_sig (NULL
, hash
, signature
, key
->pk_algorithm
,
1090 key
->params
, key
->params_size
);
1096 * gnutls_pubkey_get_verify_algorithm:
1097 * @key: Holds the certificate
1098 * @signature: contains the signature
1099 * @hash: The result of the call with the hash algorithm used for signature
1101 * This function will read the certifcate and the signed data to
1102 * determine the hash algorithm used to generate the signature.
1104 * Returns: the 0 if the hash algorithm is found. A negative value is
1105 * returned on error.
1108 gnutls_pubkey_get_verify_algorithm (gnutls_pubkey_t key
,
1109 const gnutls_datum_t
* signature
,
1110 gnutls_digest_algorithm_t
* hash
)
1115 return GNUTLS_E_INVALID_REQUEST
;
1118 return _gnutls_x509_verify_algorithm ((gnutls_mac_algorithm_t
*)
1121 key
->params
, key
->params_size
);