2 * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include "eng_local.h"
12 static ENGINE_TABLE
*cipher_table
= NULL
;
14 void ENGINE_unregister_ciphers(ENGINE
*e
)
16 engine_table_unregister(&cipher_table
, e
);
19 static void engine_unregister_all_ciphers(void)
21 engine_table_cleanup(&cipher_table
);
24 int ENGINE_register_ciphers(ENGINE
*e
)
28 int num_nids
= e
->ciphers(e
, NULL
, &nids
, 0);
30 return engine_table_register(&cipher_table
,
31 engine_unregister_all_ciphers
, e
,
37 void ENGINE_register_all_ciphers(void)
41 for (e
= ENGINE_get_first(); e
; e
= ENGINE_get_next(e
))
42 ENGINE_register_ciphers(e
);
45 int ENGINE_set_default_ciphers(ENGINE
*e
)
49 int num_nids
= e
->ciphers(e
, NULL
, &nids
, 0);
51 return engine_table_register(&cipher_table
,
52 engine_unregister_all_ciphers
, e
,
59 * Exposed API function to get a functional reference from the implementation
60 * table (ie. try to get a functional reference from the tabled structural
61 * references) for a given cipher 'nid'
63 ENGINE
*ENGINE_get_cipher_engine(int nid
)
65 return engine_table_select(&cipher_table
, nid
);
68 /* Obtains a cipher implementation from an ENGINE functional reference */
69 const EVP_CIPHER
*ENGINE_get_cipher(ENGINE
*e
, int nid
)
71 const EVP_CIPHER
*ret
;
72 ENGINE_CIPHERS_PTR fn
= ENGINE_get_ciphers(e
);
73 if (!fn
|| !fn(e
, &ret
, NULL
, nid
)) {
74 ENGINEerr(ENGINE_F_ENGINE_GET_CIPHER
, ENGINE_R_UNIMPLEMENTED_CIPHER
);
80 /* Gets the cipher callback from an ENGINE structure */
81 ENGINE_CIPHERS_PTR
ENGINE_get_ciphers(const ENGINE
*e
)
86 /* Sets the cipher callback in an ENGINE structure */
87 int ENGINE_set_ciphers(ENGINE
*e
, ENGINE_CIPHERS_PTR f
)