jpayne@69
|
1 /*
|
jpayne@69
|
2 * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
|
jpayne@69
|
3 *
|
jpayne@69
|
4 * Licensed under the OpenSSL license (the "License"). You may not use
|
jpayne@69
|
5 * this file except in compliance with the License. You can obtain a copy
|
jpayne@69
|
6 * in the file LICENSE in the source distribution or at
|
jpayne@69
|
7 * https://www.openssl.org/source/license.html
|
jpayne@69
|
8 */
|
jpayne@69
|
9
|
jpayne@69
|
10 /*
|
jpayne@69
|
11 * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.
|
jpayne@69
|
12 *
|
jpayne@69
|
13 * Redistribution and use in source and binary forms, with or without
|
jpayne@69
|
14 * modification, are permitted provided that the following conditions
|
jpayne@69
|
15 * are met:
|
jpayne@69
|
16 * 1. Redistributions of source code must retain the above copyright
|
jpayne@69
|
17 * notice, this list of conditions and the following disclaimer.
|
jpayne@69
|
18 * 2. Neither the name of author nor the names of its contributors may
|
jpayne@69
|
19 * be used to endorse or promote products derived from this software
|
jpayne@69
|
20 * without specific prior written permission.
|
jpayne@69
|
21 *
|
jpayne@69
|
22 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
jpayne@69
|
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
jpayne@69
|
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
jpayne@69
|
25 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
jpayne@69
|
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
jpayne@69
|
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
jpayne@69
|
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
jpayne@69
|
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
jpayne@69
|
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
jpayne@69
|
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
jpayne@69
|
32 * SUCH DAMAGE.
|
jpayne@69
|
33 */
|
jpayne@69
|
34
|
jpayne@69
|
35 #ifndef HEADER_SEED_H
|
jpayne@69
|
36 # define HEADER_SEED_H
|
jpayne@69
|
37
|
jpayne@69
|
38 # include <openssl/opensslconf.h>
|
jpayne@69
|
39
|
jpayne@69
|
40 # ifndef OPENSSL_NO_SEED
|
jpayne@69
|
41 # include <openssl/e_os2.h>
|
jpayne@69
|
42 # include <openssl/crypto.h>
|
jpayne@69
|
43
|
jpayne@69
|
44 #ifdef __cplusplus
|
jpayne@69
|
45 extern "C" {
|
jpayne@69
|
46 #endif
|
jpayne@69
|
47
|
jpayne@69
|
48 /* look whether we need 'long' to get 32 bits */
|
jpayne@69
|
49 # ifdef AES_LONG
|
jpayne@69
|
50 # ifndef SEED_LONG
|
jpayne@69
|
51 # define SEED_LONG 1
|
jpayne@69
|
52 # endif
|
jpayne@69
|
53 # endif
|
jpayne@69
|
54
|
jpayne@69
|
55 # include <sys/types.h>
|
jpayne@69
|
56
|
jpayne@69
|
57 # define SEED_BLOCK_SIZE 16
|
jpayne@69
|
58 # define SEED_KEY_LENGTH 16
|
jpayne@69
|
59
|
jpayne@69
|
60 typedef struct seed_key_st {
|
jpayne@69
|
61 # ifdef SEED_LONG
|
jpayne@69
|
62 unsigned long data[32];
|
jpayne@69
|
63 # else
|
jpayne@69
|
64 unsigned int data[32];
|
jpayne@69
|
65 # endif
|
jpayne@69
|
66 } SEED_KEY_SCHEDULE;
|
jpayne@69
|
67
|
jpayne@69
|
68 void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],
|
jpayne@69
|
69 SEED_KEY_SCHEDULE *ks);
|
jpayne@69
|
70
|
jpayne@69
|
71 void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],
|
jpayne@69
|
72 unsigned char d[SEED_BLOCK_SIZE],
|
jpayne@69
|
73 const SEED_KEY_SCHEDULE *ks);
|
jpayne@69
|
74 void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],
|
jpayne@69
|
75 unsigned char d[SEED_BLOCK_SIZE],
|
jpayne@69
|
76 const SEED_KEY_SCHEDULE *ks);
|
jpayne@69
|
77
|
jpayne@69
|
78 void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
jpayne@69
|
79 const SEED_KEY_SCHEDULE *ks, int enc);
|
jpayne@69
|
80 void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,
|
jpayne@69
|
81 const SEED_KEY_SCHEDULE *ks,
|
jpayne@69
|
82 unsigned char ivec[SEED_BLOCK_SIZE], int enc);
|
jpayne@69
|
83 void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,
|
jpayne@69
|
84 size_t len, const SEED_KEY_SCHEDULE *ks,
|
jpayne@69
|
85 unsigned char ivec[SEED_BLOCK_SIZE], int *num,
|
jpayne@69
|
86 int enc);
|
jpayne@69
|
87 void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,
|
jpayne@69
|
88 size_t len, const SEED_KEY_SCHEDULE *ks,
|
jpayne@69
|
89 unsigned char ivec[SEED_BLOCK_SIZE], int *num);
|
jpayne@69
|
90
|
jpayne@69
|
91 # ifdef __cplusplus
|
jpayne@69
|
92 }
|
jpayne@69
|
93 # endif
|
jpayne@69
|
94 # endif
|
jpayne@69
|
95
|
jpayne@69
|
96 #endif
|