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