source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/engine/tb_cipher.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 2.4 KB
Line 
1/*
2 * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (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
8 */
9
10#include "eng_int.h"
11
12static ENGINE_TABLE *cipher_table = NULL;
13
14void ENGINE_unregister_ciphers(ENGINE *e)
15{
16 engine_table_unregister(&cipher_table, e);
17}
18
19static void engine_unregister_all_ciphers(void)
20{
21 engine_table_cleanup(&cipher_table);
22}
23
24int ENGINE_register_ciphers(ENGINE *e)
25{
26 if (e->ciphers) {
27 const int *nids;
28 int num_nids = e->ciphers(e, NULL, &nids, 0);
29 if (num_nids > 0)
30 return engine_table_register(&cipher_table,
31 engine_unregister_all_ciphers, e,
32 nids, num_nids, 0);
33 }
34 return 1;
35}
36
37void ENGINE_register_all_ciphers()
38{
39 ENGINE *e;
40
41 for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
42 ENGINE_register_ciphers(e);
43}
44
45int ENGINE_set_default_ciphers(ENGINE *e)
46{
47 if (e->ciphers) {
48 const int *nids;
49 int num_nids = e->ciphers(e, NULL, &nids, 0);
50 if (num_nids > 0)
51 return engine_table_register(&cipher_table,
52 engine_unregister_all_ciphers, e,
53 nids, num_nids, 1);
54 }
55 return 1;
56}
57
58/*
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'
62 */
63ENGINE *ENGINE_get_cipher_engine(int nid)
64{
65 return engine_table_select(&cipher_table, nid);
66}
67
68/* Obtains a cipher implementation from an ENGINE functional reference */
69const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid)
70{
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);
75 return NULL;
76 }
77 return ret;
78}
79
80/* Gets the cipher callback from an ENGINE structure */
81ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e)
82{
83 return e->ciphers;
84}
85
86/* Sets the cipher callback in an ENGINE structure */
87int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f)
88{
89 e->ciphers = f;
90 return 1;
91}
Note: See TracBrowser for help on using the repository browser.