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>
28 #include <gnutls_errors.h>
29 #include <gnutls_datum.h>
30 #include <pkcs11_int.h>
31 #include <gnutls/abstract.h>
32 #include <gnutls_pk.h>
34 #include <openpgp/openpgp_int.h>
35 #include <pkcs11_int.h>
36 #include <gnutls_num.h>
37 #include <x509/common.h>
39 #include <abstract_int.h>
41 #define PK_PEM_HEADER "PUBLIC KEY"
44 struct gnutls_pubkey_st
46 gnutls_pk_algorithm_t pk_algorithm
;
47 unsigned int bits
; /* an indication of the security parameter */
49 /* the size of params depends on the public
52 * [1] is public exponent
58 bigint_t params
[MAX_PUBLIC_PARAMS_SIZE
];
59 int params_size
; /* holds the size of MPI params */
61 unsigned int key_usage
; /* bits from GNUTLS_KEY_* */
64 static int pubkey_to_bits(gnutls_pk_algorithm_t pk
, bigint_t
* params
, int params_size
)
69 return _gnutls_mpi_get_nbits(params
[0]);
71 if (params_size
< 3) return 0;
72 return _gnutls_mpi_get_nbits(params
[3]);
79 * gnutls_pubkey_get_pk_algorithm:
80 * @key: should contain a #gnutls_pubkey_t structure
81 * @bits: If set will return the number of bits of the parameters (may be NULL)
83 * This function will return the public key algorithm of a public
84 * key and if possible will return a number of bits that indicates
85 * the security parameter of the key.
87 * Returns: a member of the #gnutls_pk_algorithm_t enumeration on
88 * success, or a negative value on error.
91 gnutls_pubkey_get_pk_algorithm (gnutls_pubkey_t key
, unsigned int *bits
)
96 return key
->pk_algorithm
;
100 * gnutls_pubkey_get_key_usage:
101 * @key: should contain a #gnutls_pubkey_t structure
102 * @usage: If set will return the number of bits of the parameters (may be NULL)
104 * This function will return the key usage of the public key.
106 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
107 * negative error value.
110 gnutls_pubkey_get_key_usage (gnutls_pubkey_t key
, unsigned int *usage
)
113 *usage
= key
->key_usage
;
119 * gnutls_pubkey_init:
120 * @key: The structure to be initialized
122 * This function will initialize an public key structure.
124 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
125 * negative error value.
128 gnutls_pubkey_init (gnutls_pubkey_t
* key
)
130 *key
= gnutls_calloc (1, sizeof (struct gnutls_pubkey_st
));
134 return GNUTLS_E_MEMORY_ERROR
;
141 * gnutls_pubkey_deinit:
142 * @key: The structure to be deinitialized
144 * This function will deinitialize a public key structure.
147 gnutls_pubkey_deinit (gnutls_pubkey_t key
)
151 for (i
= 0; i
< key
->params_size
; i
++)
153 _gnutls_mpi_release (&key
->params
[i
]);
160 * gnutls_pubkey_import_x509:
161 * @key: The public key
162 * @crt: The certificate to be imported
163 * @flags: should be zero
165 * This function will import the given public key to the abstract
166 * #gnutls_pubkey_t structure.
168 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
169 * negative error value.
172 gnutls_pubkey_import_x509 (gnutls_pubkey_t key
, gnutls_x509_crt_t crt
,
177 key
->pk_algorithm
= gnutls_x509_crt_get_pk_algorithm (crt
, &key
->bits
);
179 ret
= gnutls_x509_crt_get_key_usage (crt
, &key
->key_usage
, NULL
);
183 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
184 switch (key
->pk_algorithm
)
187 ret
= _gnutls_x509_crt_get_mpis (crt
, key
->params
, &key
->params_size
);
195 ret
= _gnutls_x509_crt_get_mpis (crt
, key
->params
, &key
->params_size
);
205 return GNUTLS_E_INVALID_REQUEST
;
212 * gnutls_pubkey_import_privkey: Imports the public key from a private
213 * @key: The public key
214 * @pkey: The private key
215 * @usage: GNUTLS_KEY_* key usage flags.
216 * @flags: should be zero
218 * This function will import the given public key to the abstract
219 * #gnutls_pubkey_t structure.
221 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
222 * negative error value.
227 gnutls_pubkey_import_privkey (gnutls_pubkey_t key
, gnutls_privkey_t pkey
,
228 unsigned int usage
, unsigned int flags
)
230 key
->pk_algorithm
= gnutls_privkey_get_pk_algorithm (pkey
, &key
->bits
);
232 key
->key_usage
= usage
;
234 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
236 return _gnutls_privkey_get_public_mpis (pkey
, key
->params
,
241 * gnutls_pubkey_get_preferred_hash_algorithm:
242 * @key: Holds the certificate
243 * @hash: The result of the call with the hash algorithm used for signature
244 * @mand: If non zero it means that the algorithm MUST use this hash. May be NULL.
246 * This function will read the certifcate and return the appropriate digest
247 * algorithm to use for signing with this certificate. Some certificates (i.e.
248 * DSA might not be able to sign without the preferred algorithm).
250 * Returns: the 0 if the hash algorithm is found. A negative value is
256 gnutls_pubkey_get_preferred_hash_algorithm (gnutls_pubkey_t key
,
257 gnutls_digest_algorithm_t
*
258 hash
, unsigned int *mand
)
265 return GNUTLS_E_INVALID_REQUEST
;
268 ret
= _gnutls_pk_get_hash_algorithm (key
->pk_algorithm
,
269 key
->params
, key
->params_size
,
277 * gnutls_pubkey_import_pkcs11: Imports a public key from a pkcs11 key
278 * @key: The public key
279 * @obj: The parameters to be imported
280 * @flags: should be zero
282 * This function will import the given public key to the abstract
283 * #gnutls_pubkey_t structure.
285 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
286 * negative error value.
289 gnutls_pubkey_import_pkcs11 (gnutls_pubkey_t key
,
290 gnutls_pkcs11_obj_t obj
, unsigned int flags
)
294 ret
= gnutls_pkcs11_obj_get_type (obj
);
295 if (ret
!= GNUTLS_PKCS11_OBJ_PUBKEY
)
298 return GNUTLS_E_INVALID_REQUEST
;
301 key
->key_usage
= obj
->key_usage
;
303 switch (obj
->pk_algorithm
)
306 ret
= gnutls_pubkey_import_rsa_raw (key
, &obj
->pubkey
[0],
310 ret
= gnutls_pubkey_import_dsa_raw (key
, &obj
->pubkey
[0],
312 &obj
->pubkey
[2], &obj
->pubkey
[3]);
316 return GNUTLS_E_UNIMPLEMENTED_FEATURE
;
328 #ifdef ENABLE_OPENPGP
330 * gnutls_pubkey_import_openpgp: Imports a public key from an openpgp key
331 * @key: The public key
332 * @crt: The certificate to be imported
333 * @flags: should be zero
335 * This function will import the given public key to the abstract
336 * #gnutls_pubkey_t structure. The subkey set as preferred will be
337 * imported or the master key otherwise.
339 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
340 * negative error value.
343 gnutls_pubkey_import_openpgp (gnutls_pubkey_t key
,
344 gnutls_openpgp_crt_t crt
,
350 uint8_t keyid
[GNUTLS_OPENPGP_KEYID_SIZE
];
352 ret
= gnutls_openpgp_crt_get_preferred_key_id (crt
, keyid
);
353 if (ret
== GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR
)
355 key
->pk_algorithm
= gnutls_openpgp_crt_get_pk_algorithm (crt
, &key
->bits
);
357 ret
= gnutls_openpgp_crt_get_key_usage (crt
, &key
->key_usage
);
371 KEYID_IMPORT (kid32
, keyid
);
374 idx
= gnutls_openpgp_crt_get_subkey_idx (crt
, keyid
);
376 ret
= gnutls_openpgp_crt_get_subkey_usage (crt
, idx
, &key
->key_usage
);
380 key
->pk_algorithm
= gnutls_openpgp_crt_get_subkey_pk_algorithm (crt
, idx
, NULL
);
383 switch (key
->pk_algorithm
)
387 _gnutls_openpgp_crt_get_mpis (crt
, k
, key
->params
,
397 _gnutls_openpgp_crt_get_mpis (crt
, k
, key
->params
,
407 return GNUTLS_E_INVALID_REQUEST
;
416 * gnutls_pubkey_export:
417 * @key: Holds the certificate
418 * @format: the format of output params. One of PEM or DER.
419 * @output_data: will contain a certificate PEM or DER encoded
420 * @output_data_size: holds the size of output_data (and will be
421 * replaced by the actual size of parameters)
423 * This function will export the certificate to DER or PEM format.
425 * If the buffer provided is not long enough to hold the output, then
426 * *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
429 * If the structure is PEM encoded, it will have a header
430 * of "BEGIN CERTIFICATE".
432 * Return value: In case of failure a negative value will be
433 * returned, and 0 on success.
436 gnutls_pubkey_export (gnutls_pubkey_t key
,
437 gnutls_x509_crt_fmt_t format
, void *output_data
,
438 size_t * output_data_size
)
441 ASN1_TYPE spk
= ASN1_TYPE_EMPTY
;
446 return GNUTLS_E_INVALID_REQUEST
;
449 if ((result
= asn1_create_element
450 (_gnutls_get_pkix (), "PKIX1.SubjectPublicKeyInfo", &spk
))
454 return _gnutls_asn2err (result
);
458 _gnutls_x509_encode_and_copy_PKI_params (spk
, "",
460 key
->params
, key
->params_size
);
467 result
= _gnutls_x509_export_int_named (spk
, "",
468 format
, PK_PEM_HEADER
,
469 output_data
, output_data_size
);
479 asn1_delete_structure (&spk
);
486 * gnutls_pubkey_get_key_id:
487 * @key: Holds the public key
488 * @flags: should be 0 for now
489 * @output_data: will contain the key ID
490 * @output_data_size: holds the size of output_data (and will be
491 * replaced by the actual size of parameters)
493 * This function will return a unique ID the depends on the public
494 * key parameters. This ID can be used in checking whether a
495 * certificate corresponds to the given public key.
497 * If the buffer provided is not long enough to hold the output, then
498 * *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
499 * be returned. The output will normally be a SHA-1 hash output,
502 * Return value: In case of failure a negative value will be
503 * returned, and 0 on success.
506 gnutls_pubkey_get_key_id (gnutls_pubkey_t key
, unsigned int flags
,
507 unsigned char *output_data
,
508 size_t * output_data_size
)
515 return GNUTLS_E_INVALID_REQUEST
;
519 _gnutls_get_key_id (key
->pk_algorithm
, key
->params
,
520 key
->params_size
, output_data
, output_data_size
);
531 * gnutls_pubkey_get_pk_rsa_raw:
532 * @key: Holds the certificate
533 * @m: will hold the modulus
534 * @e: will hold the public exponent
536 * This function will export the RSA public key's parameters found in
537 * the given structure. The new parameters will be allocated using
538 * gnutls_malloc() and will be stored in the appropriate datum.
540 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error.
543 gnutls_pubkey_get_pk_rsa_raw (gnutls_pubkey_t key
,
544 gnutls_datum_t
* m
, gnutls_datum_t
* e
)
551 return GNUTLS_E_INVALID_REQUEST
;
554 if (key
->pk_algorithm
!= GNUTLS_PK_RSA
)
557 return GNUTLS_E_INVALID_REQUEST
;
560 ret
= _gnutls_mpi_dprint_lz (key
->params
[0], m
);
567 ret
= _gnutls_mpi_dprint_lz (key
->params
[1], e
);
571 _gnutls_free_datum (m
);
579 * gnutls_pubkey_get_pk_dsa_raw:
580 * @key: Holds the public key
581 * @p: will hold the p
582 * @q: will hold the q
583 * @g: will hold the g
584 * @y: will hold the y
586 * This function will export the DSA public key's parameters found in
587 * the given certificate. The new parameters will be allocated using
588 * gnutls_malloc() and will be stored in the appropriate datum.
590 * Returns: %GNUTLS_E_SUCCESS on success, otherwise an error.
593 gnutls_pubkey_get_pk_dsa_raw (gnutls_pubkey_t key
,
594 gnutls_datum_t
* p
, gnutls_datum_t
* q
,
595 gnutls_datum_t
* g
, gnutls_datum_t
* y
)
602 return GNUTLS_E_INVALID_REQUEST
;
605 if (key
->pk_algorithm
!= GNUTLS_PK_DSA
)
608 return GNUTLS_E_INVALID_REQUEST
;
612 ret
= _gnutls_mpi_dprint_lz (key
->params
[0], p
);
620 ret
= _gnutls_mpi_dprint_lz (key
->params
[1], q
);
624 _gnutls_free_datum (p
);
630 ret
= _gnutls_mpi_dprint_lz (key
->params
[2], g
);
634 _gnutls_free_datum (p
);
635 _gnutls_free_datum (q
);
641 ret
= _gnutls_mpi_dprint_lz (key
->params
[3], y
);
645 _gnutls_free_datum (p
);
646 _gnutls_free_datum (g
);
647 _gnutls_free_datum (q
);
655 * gnutls_pubkey_import:
656 * @key: The structure to store the parsed public key.
657 * @data: The DER or PEM encoded certificate.
658 * @format: One of DER or PEM
660 * This function will convert the given DER or PEM encoded Public key
661 * to the native gnutls_pubkey_t format.The output will be stored * in @ key.
662 * If the Certificate is PEM encoded it should have a header of "PUBLIC KEY".
664 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
665 * negative error value.
668 gnutls_pubkey_import (gnutls_pubkey_t key
,
669 const gnutls_datum_t
* data
,
670 gnutls_x509_crt_fmt_t format
)
672 int result
= 0, need_free
= 0;
673 gnutls_datum_t _data
;
679 return GNUTLS_E_INVALID_REQUEST
;
682 _data
.data
= data
->data
;
683 _data
.size
= data
->size
;
685 /* If the Certificate is in PEM format then decode it
687 if (format
== GNUTLS_X509_FMT_PEM
)
691 /* Try the first header */
693 _gnutls_fbase64_decode (PK_PEM_HEADER
, data
->data
, data
->size
, &out
);
698 result
= GNUTLS_E_INTERNAL_ERROR
;
709 if ((result
= asn1_create_element
710 (_gnutls_get_pkix (), "PKIX1.SubjectPublicKeyInfo", &spk
))
714 result
= _gnutls_asn2err (result
);
718 result
= asn1_der_decoding (&spk
, _data
.data
, _data
.size
, NULL
);
719 if (result
!= ASN1_SUCCESS
)
722 result
= _gnutls_asn2err (result
);
726 key
->params_size
= sizeof (key
->params
) / sizeof (key
->params
[0]);
727 result
= _gnutls_get_asn_mpis (spk
, "", key
->params
, &key
->params_size
);
734 /* this has already been called by get_asn_mpis() thus it cannot
737 key
->pk_algorithm
= _gnutls_x509_get_pk_algorithm (spk
, "", NULL
);
738 key
->bits
= pubkey_to_bits(key
->pk_algorithm
, key
->params
, key
->params_size
);
743 asn1_delete_structure (&spk
);
746 _gnutls_free_datum (&_data
);
751 * gnutls_x509_crt_set_pubkey:
752 * @crt: should contain a #gnutls_x509_crt_t structure
753 * @key: holds a public key
755 * This function will set the public parameters from the given public
756 * key to the request.
758 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
759 * negative error value.
762 gnutls_x509_crt_set_pubkey (gnutls_x509_crt_t crt
, gnutls_pubkey_t key
)
769 return GNUTLS_E_INVALID_REQUEST
;
772 result
= _gnutls_x509_encode_and_copy_PKI_params (crt
->cert
,
773 "tbsCertificate.subjectPublicKeyInfo",
785 gnutls_x509_crt_set_key_usage (crt
, key
->key_usage
);
791 * gnutls_x509_crq_set_pubkey:
792 * @crq: should contain a #gnutls_x509_crq_t structure
793 * @key: holds a public key
795 * This function will set the public parameters from the given public
796 * key to the request.
798 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
799 * negative error value.
802 gnutls_x509_crq_set_pubkey (gnutls_x509_crq_t crq
, gnutls_pubkey_t key
)
809 return GNUTLS_E_INVALID_REQUEST
;
812 result
= _gnutls_x509_encode_and_copy_PKI_params
814 "certificationRequestInfo.subjectPKInfo",
815 key
->pk_algorithm
, key
->params
, key
->params_size
);
824 gnutls_x509_crq_set_key_usage (crq
, key
->key_usage
);
830 * gnutls_pubkey_set_key_usage:
831 * @key: a certificate of type #gnutls_x509_crt_t
832 * @usage: an ORed sequence of the GNUTLS_KEY_* elements.
834 * This function will set the key usage flags of the public key. This
835 * is only useful if the key is to be exported to a certificate or
836 * certificate request.
838 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
839 * negative error value.
842 gnutls_pubkey_set_key_usage (gnutls_pubkey_t key
, unsigned int usage
)
844 key
->key_usage
= usage
;
850 * gnutls_pubkey_import_pkcs11_url:
851 * @key: A key of type #gnutls_pubkey_t
852 * @url: A PKCS 11 url
853 * @flags: One of GNUTLS_PKCS11_OBJ_* flags
855 * This function will import a PKCS 11 certificate to a #gnutls_pubkey_t
858 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
859 * negative error value.
863 gnutls_pubkey_import_pkcs11_url (gnutls_pubkey_t key
, const char *url
,
866 gnutls_pkcs11_obj_t pcrt
;
869 ret
= gnutls_pkcs11_obj_init (&pcrt
);
876 ret
= gnutls_pkcs11_obj_import_url (pcrt
, url
, flags
);
883 ret
= gnutls_pubkey_import_pkcs11 (key
, pcrt
, 0);
893 gnutls_pkcs11_obj_deinit (pcrt
);
899 * gnutls_pubkey_import_rsa_raw:
900 * @key: Is a structure will hold the parameters
901 * @m: holds the modulus
902 * @e: holds the public exponent
904 * This function will replace the parameters in the given structure.
905 * The new parameters should be stored in the appropriate
908 * Returns: %GNUTLS_E_SUCCESS on success, or an negative error code.
911 gnutls_pubkey_import_rsa_raw (gnutls_pubkey_t key
,
912 const gnutls_datum_t
* m
,
913 const gnutls_datum_t
* e
)
920 return GNUTLS_E_INVALID_REQUEST
;
924 if (_gnutls_mpi_scan_nz (&key
->params
[0], m
->data
, siz
))
927 return GNUTLS_E_MPI_SCAN_FAILED
;
931 if (_gnutls_mpi_scan_nz (&key
->params
[1], e
->data
, siz
))
934 _gnutls_mpi_release (&key
->params
[0]);
935 return GNUTLS_E_MPI_SCAN_FAILED
;
938 key
->params_size
= RSA_PUBLIC_PARAMS
;
939 key
->pk_algorithm
= GNUTLS_PK_RSA
;
940 key
->bits
= pubkey_to_bits(GNUTLS_PK_RSA
, key
->params
, key
->params_size
);
946 * gnutls_pubkey_import_dsa_raw:
947 * @key: The structure to store the parsed key
953 * This function will convert the given DSA raw parameters to the
954 * native #gnutls_pubkey_t format. The output will be stored
957 * Returns: On success, %GNUTLS_E_SUCCESS is returned, otherwise a
958 * negative error value.
961 gnutls_pubkey_import_dsa_raw (gnutls_pubkey_t key
,
962 const gnutls_datum_t
* p
,
963 const gnutls_datum_t
* q
,
964 const gnutls_datum_t
* g
,
965 const gnutls_datum_t
* y
)
972 return GNUTLS_E_INVALID_REQUEST
;
976 if (_gnutls_mpi_scan_nz (&key
->params
[0], p
->data
, siz
))
979 return GNUTLS_E_MPI_SCAN_FAILED
;
983 if (_gnutls_mpi_scan_nz (&key
->params
[1], q
->data
, siz
))
986 _gnutls_mpi_release (&key
->params
[0]);
987 return GNUTLS_E_MPI_SCAN_FAILED
;
991 if (_gnutls_mpi_scan_nz (&key
->params
[2], g
->data
, siz
))
994 _gnutls_mpi_release (&key
->params
[1]);
995 _gnutls_mpi_release (&key
->params
[0]);
996 return GNUTLS_E_MPI_SCAN_FAILED
;
1000 if (_gnutls_mpi_scan_nz (&key
->params
[3], y
->data
, siz
))
1003 _gnutls_mpi_release (&key
->params
[2]);
1004 _gnutls_mpi_release (&key
->params
[1]);
1005 _gnutls_mpi_release (&key
->params
[0]);
1006 return GNUTLS_E_MPI_SCAN_FAILED
;
1009 key
->params_size
= DSA_PUBLIC_PARAMS
;
1010 key
->pk_algorithm
= GNUTLS_PK_DSA
;
1011 key
->bits
= pubkey_to_bits(GNUTLS_PK_DSA
, key
->params
, key
->params_size
);
1018 * gnutls_pubkey_verify_data:
1019 * @pubkey: Holds the public key
1020 * @flags: should be 0 for now
1021 * @data: holds the data to be signed
1022 * @signature: contains the signature
1024 * This function will verify the given signed data, using the
1025 * parameters from the certificate.
1027 * Returns: In case of a verification failure
1028 * %GNUTLS_E_PK_SIG_VERIFY_FAILED is returned, and a positive code
1034 gnutls_pubkey_verify_data (gnutls_pubkey_t pubkey
, unsigned int flags
,
1035 const gnutls_datum_t
* data
,
1036 const gnutls_datum_t
* signature
)
1043 return GNUTLS_E_INVALID_REQUEST
;
1046 ret
= pubkey_verify_sig( data
, NULL
, signature
, pubkey
->pk_algorithm
,
1047 pubkey
->params
, pubkey
->params_size
);
1058 * gnutls_pubkey_verify_hash:
1059 * @key: Holds the certificate
1060 * @flags: should be 0 for now
1061 * @hash: holds the hash digest to be verified
1062 * @signature: contains the signature
1064 * This function will verify the given signed digest, using the
1065 * parameters from the certificate.
1067 * Returns: In case of a verification failure %GNUTLS_E_PK_SIG_VERIFY_FAILED
1068 * is returned, and a positive code on success.
1071 gnutls_pubkey_verify_hash (gnutls_pubkey_t key
, unsigned int flags
,
1072 const gnutls_datum_t
* hash
,
1073 const gnutls_datum_t
* signature
)
1080 return GNUTLS_E_INVALID_REQUEST
;
1084 pubkey_verify_sig (NULL
, hash
, signature
, key
->pk_algorithm
,
1085 key
->params
, key
->params_size
);
1091 * gnutls_pubkey_get_verify_algorithm:
1092 * @key: Holds the certificate
1093 * @signature: contains the signature
1094 * @hash: The result of the call with the hash algorithm used for signature
1096 * This function will read the certifcate and the signed data to
1097 * determine the hash algorithm used to generate the signature.
1099 * Returns: the 0 if the hash algorithm is found. A negative value is
1100 * returned on error.
1103 gnutls_pubkey_get_verify_algorithm (gnutls_pubkey_t key
,
1104 const gnutls_datum_t
* signature
,
1105 gnutls_digest_algorithm_t
* hash
)
1110 return GNUTLS_E_INVALID_REQUEST
;
1113 return _gnutls_x509_verify_algorithm ((gnutls_mac_algorithm_t
*)
1116 key
->params
, key
->params_size
);