1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** NetX Secure Component */
17 /** */
18 /** X.509 Digital Certificates */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define NX_SECURE_SOURCE_CODE
24
25
26 #include "nx_secure_x509.h"
27
28 /**************************************************************************/
29 /* */
30 /* FUNCTION RELEASE */
31 /* */
32 /* _nx_secure_x509_find_certificate_methods PORTABLE C */
33 /* 6.1.6 */
34 /* AUTHOR */
35 /* */
36 /* Timothy Stapko, Microsoft Corporation */
37 /* */
38 /* DESCRIPTION */
39 /* */
40 /* This function finds crypto methods specified in a certificate. */
41 /* */
42 /* INPUT */
43 /* */
44 /* cert Pointer to X509 certificate */
45 /* signature_algorithm Id for signature method */
46 /* crypto_methods Return matching table entry */
47 /* */
48 /* OUTPUT */
49 /* */
50 /* status Completion status */
51 /* */
52 /* CALLS */
53 /* */
54 /* None */
55 /* */
56 /* CALLED BY */
57 /* */
58 /* _nx_secure_x509_certificate_verify Verify a certificate */
59 /* _nx_secure_x509_crl_verify Verify revocation list */
60 /* _nx_secure_tls_process_certificate_verify */
61 /* Process CertificateVerify */
62 /* _nx_secure_tls_process_server_key_exchange */
63 /* Process ServerKeyExchange */
64 /* _nx_secure_tls_send_certificate_verify */
65 /* Send certificate verify */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
72 /* 09-30-2020 Timothy Stapko Modified comment(s), */
73 /* resulting in version 6.1 */
74 /* 04-02-2021 Timothy Stapko Modified comment(s), */
75 /* removed dependency on TLS, */
76 /* resulting in version 6.1.6 */
77 /* */
78 /**************************************************************************/
_nx_secure_x509_find_certificate_methods(NX_SECURE_X509_CERT * cert,USHORT signature_algorithm,NX_SECURE_X509_CRYPTO ** crypto_methods)79 UINT _nx_secure_x509_find_certificate_methods(NX_SECURE_X509_CERT *cert, USHORT signature_algorithm,
80 NX_SECURE_X509_CRYPTO **crypto_methods)
81 {
82 SHORT index;
83
84 /* The number of ciphersuites is very small so a linear search should be fine. */
85 for (index = 0; index < cert -> nx_secure_x509_cipher_table_size; ++index)
86 {
87 /* See if the ciphersuite is supported. */
88 if (cert -> nx_secure_x509_cipher_table[index].nx_secure_x509_crypto_identifier == signature_algorithm)
89 {
90 *crypto_methods = &cert -> nx_secure_x509_cipher_table[index];
91 return(NX_SECURE_X509_SUCCESS);
92 }
93 }
94
95 /* No entry found, crypto routines unknown. */
96 *crypto_methods = NX_CRYPTO_NULL;
97 return(NX_SECURE_X509_UNKNOWN_CERT_SIG_ALGORITHM);
98 }
99
100