source: EcnlProtoTool/trunk/openssl-1.1.0e/crypto/evp/e_rc5.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.1 KB
Line 
1/*
2 * Copyright 1995-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 <stdio.h>
11#include "internal/cryptlib.h"
12
13#ifndef OPENSSL_NO_RC5
14
15# include <openssl/evp.h>
16# include <internal/evp_int.h>
17# include <openssl/objects.h>
18# include "evp_locl.h"
19# include <openssl/rc5.h>
20
21static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
22 const unsigned char *iv, int enc);
23static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr);
24
25typedef struct {
26 int rounds; /* number of rounds */
27 RC5_32_KEY ks; /* key schedule */
28} EVP_RC5_KEY;
29
30# define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx)
31
32IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5,
33 8, RC5_32_KEY_LENGTH, 8, 64,
34 EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
35 r_32_12_16_init_key, NULL, NULL, NULL, rc5_ctrl)
36
37static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
38{
39 switch (type) {
40 case EVP_CTRL_INIT:
41 data(c)->rounds = RC5_12_ROUNDS;
42 return 1;
43
44 case EVP_CTRL_GET_RC5_ROUNDS:
45 *(int *)ptr = data(c)->rounds;
46 return 1;
47
48 case EVP_CTRL_SET_RC5_ROUNDS:
49 switch (arg) {
50 case RC5_8_ROUNDS:
51 case RC5_12_ROUNDS:
52 case RC5_16_ROUNDS:
53 data(c)->rounds = arg;
54 return 1;
55
56 default:
57 EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS);
58 return 0;
59 }
60
61 default:
62 return -1;
63 }
64}
65
66static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 const unsigned char *iv, int enc)
68{
69 RC5_32_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx),
70 key, data(ctx)->rounds);
71 return 1;
72}
73
74#endif
Note: See TracBrowser for help on using the repository browser.