source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/evp/cmeth_lib.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: 4.6 KB
Line 
1/*
2 * Copyright 2015-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 <string.h>
11
12#include <openssl/evp.h>
13#include "internal/evp_int.h"
14#include "evp_locl.h"
15
16EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
17{
18 EVP_CIPHER *cipher = OPENSSL_zalloc(sizeof(EVP_CIPHER));
19
20 if (cipher != NULL) {
21 cipher->nid = cipher_type;
22 cipher->block_size = block_size;
23 cipher->key_len = key_len;
24 }
25 return cipher;
26}
27
28EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
29{
30 EVP_CIPHER *to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
31 cipher->key_len);
32
33 if (to != NULL)
34 memcpy(to, cipher, sizeof(*to));
35 return to;
36}
37
38void EVP_CIPHER_meth_free(EVP_CIPHER *cipher)
39{
40 OPENSSL_free(cipher);
41}
42
43int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len)
44{
45 cipher->iv_len = iv_len;
46 return 1;
47}
48
49int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags)
50{
51 cipher->flags = flags;
52 return 1;
53}
54
55int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size)
56{
57 cipher->ctx_size = ctx_size;
58 return 1;
59}
60
61int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,
62 int (*init) (EVP_CIPHER_CTX *ctx,
63 const unsigned char *key,
64 const unsigned char *iv,
65 int enc))
66{
67 cipher->init = init;
68 return 1;
69}
70
71int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,
72 int (*do_cipher) (EVP_CIPHER_CTX *ctx,
73 unsigned char *out,
74 const unsigned char *in,
75 size_t inl))
76{
77 cipher->do_cipher = do_cipher;
78 return 1;
79}
80
81int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,
82 int (*cleanup) (EVP_CIPHER_CTX *))
83{
84 cipher->cleanup = cleanup;
85 return 1;
86}
87
88int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,
89 int (*set_asn1_parameters) (EVP_CIPHER_CTX *,
90 ASN1_TYPE *))
91{
92 cipher->set_asn1_parameters = set_asn1_parameters;
93 return 1;
94}
95
96int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,
97 int (*get_asn1_parameters) (EVP_CIPHER_CTX *,
98 ASN1_TYPE *))
99{
100 cipher->get_asn1_parameters = get_asn1_parameters;
101 return 1;
102}
103
104int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,
105 int (*ctrl) (EVP_CIPHER_CTX *, int type,
106 int arg, void *ptr))
107{
108 cipher->ctrl = ctrl;
109 return 1;
110}
111
112
113int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
114 const unsigned char *key,
115 const unsigned char *iv,
116 int enc)
117{
118 return cipher->init;
119}
120int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
121 unsigned char *out,
122 const unsigned char *in,
123 size_t inl)
124{
125 return cipher->do_cipher;
126}
127
128int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *)
129{
130 return cipher->cleanup;
131}
132
133int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
134 ASN1_TYPE *)
135{
136 return cipher->set_asn1_parameters;
137}
138
139int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
140 ASN1_TYPE *)
141{
142 return cipher->get_asn1_parameters;
143}
144
145int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
146 int type, int arg,
147 void *ptr)
148{
149 return cipher->ctrl;
150}
151
Note: See TracBrowser for help on using the repository browser.