• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2016, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <openssl/evp.h>
16 
17 
EVP_CIPHER_do_all_sorted(void (* callback)(const EVP_CIPHER * cipher,const char * name,const char * unused,void * arg),void * arg)18 void EVP_CIPHER_do_all_sorted(void (*callback)(const EVP_CIPHER *cipher,
19                                                const char *name,
20                                                const char *unused, void *arg),
21                               void *arg) {
22   callback(EVP_aes_128_cbc(), "AES-128-CBC", NULL, arg);
23   callback(EVP_aes_128_ctr(), "AES-128-CTR", NULL, arg);
24   callback(EVP_aes_128_ecb(), "AES-128-ECB", NULL, arg);
25   callback(EVP_aes_128_ofb(), "AES-128-OFB", NULL, arg);
26   callback(EVP_aes_256_cbc(), "AES-256-CBC", NULL, arg);
27   callback(EVP_aes_256_ctr(), "AES-256-CTR", NULL, arg);
28   callback(EVP_aes_256_ecb(), "AES-256-ECB", NULL, arg);
29   callback(EVP_aes_256_ofb(), "AES-256-OFB", NULL, arg);
30   callback(EVP_aes_256_xts(), "AES-256-XTS", NULL, arg);
31   callback(EVP_des_cbc(), "DES-CBC", NULL, arg);
32   callback(EVP_des_ecb(), "DES-ECB", NULL, arg);
33   callback(EVP_des_ede(), "DES-EDE", NULL, arg);
34   callback(EVP_des_ede_cbc(), "DES-EDE-CBC", NULL, arg);
35   callback(EVP_des_ede3_cbc(), "DES-EDE3-CBC", NULL, arg);
36   callback(EVP_rc2_cbc(), "RC2-CBC", NULL, arg);
37   callback(EVP_rc4(), "RC4", NULL, arg);
38 
39   /* OpenSSL returns everything twice, the second time in lower case. */
40   callback(EVP_aes_128_cbc(), "aes-128-cbc", NULL, arg);
41   callback(EVP_aes_128_ctr(), "aes-128-ctr", NULL, arg);
42   callback(EVP_aes_128_ecb(), "aes-128-ecb", NULL, arg);
43   callback(EVP_aes_128_ofb(), "aes-128-ofb", NULL, arg);
44   callback(EVP_aes_256_cbc(), "aes-256-cbc", NULL, arg);
45   callback(EVP_aes_256_ctr(), "aes-256-ctr", NULL, arg);
46   callback(EVP_aes_256_ecb(), "aes-256-ecb", NULL, arg);
47   callback(EVP_aes_256_ofb(), "aes-256-ofb", NULL, arg);
48   callback(EVP_aes_256_xts(), "aes-256-xts", NULL, arg);
49   callback(EVP_des_cbc(), "des-cbc", NULL, arg);
50   callback(EVP_des_ecb(), "des-ecb", NULL, arg);
51   callback(EVP_des_ede(), "des-ede", NULL, arg);
52   callback(EVP_des_ede_cbc(), "des-ede-cbc", NULL, arg);
53   callback(EVP_des_ede3_cbc(), "des-ede3-cbc", NULL, arg);
54   callback(EVP_rc2_cbc(), "rc2-cbc", NULL, arg);
55   callback(EVP_rc4(), "rc4", NULL, arg);
56 }
57 
EVP_MD_do_all_sorted(void (* callback)(const EVP_MD * cipher,const char * name,const char * unused,void * arg),void * arg)58 void EVP_MD_do_all_sorted(void (*callback)(const EVP_MD *cipher,
59                                            const char *name, const char *unused,
60                                            void *arg),
61                           void *arg) {
62   callback(EVP_md4(), "MD4", NULL, arg);
63   callback(EVP_md5(), "MD5", NULL, arg);
64   callback(EVP_sha1(), "SHA1", NULL, arg);
65   callback(EVP_sha224(), "SHA224", NULL, arg);
66   callback(EVP_sha256(), "SHA256", NULL, arg);
67   callback(EVP_sha384(), "SHA384", NULL, arg);
68   callback(EVP_sha512(), "SHA512", NULL, arg);
69 
70   callback(EVP_md4(), "md4", NULL, arg);
71   callback(EVP_md5(), "md5", NULL, arg);
72   callback(EVP_sha1(), "sha1", NULL, arg);
73   callback(EVP_sha224(), "sha224", NULL, arg);
74   callback(EVP_sha256(), "sha256", NULL, arg);
75   callback(EVP_sha384(), "sha384", NULL, arg);
76   callback(EVP_sha512(), "sha512", NULL, arg);
77 }
78