Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:45

0001 /*
0002  * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #ifndef OPENSSL_MODES_H
0011 # define OPENSSL_MODES_H
0012 # pragma once
0013 
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 #  define HEADER_MODES_H
0017 # endif
0018 
0019 # include <stddef.h>
0020 # include <openssl/types.h>
0021 
0022 # ifdef  __cplusplus
0023 extern "C" {
0024 # endif
0025 typedef void (*block128_f) (const unsigned char in[16],
0026                             unsigned char out[16], const void *key);
0027 
0028 typedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,
0029                           size_t len, const void *key,
0030                           unsigned char ivec[16], int enc);
0031 
0032 typedef void (*ecb128_f) (const unsigned char *in, unsigned char *out,
0033                           size_t len, const void *key,
0034                           int enc);
0035 
0036 typedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,
0037                           size_t blocks, const void *key,
0038                           const unsigned char ivec[16]);
0039 
0040 typedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,
0041                           size_t blocks, const void *key,
0042                           const unsigned char ivec[16],
0043                           unsigned char cmac[16]);
0044 
0045 void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
0046                            size_t len, const void *key,
0047                            unsigned char ivec[16], block128_f block);
0048 void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
0049                            size_t len, const void *key,
0050                            unsigned char ivec[16], block128_f block);
0051 
0052 void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
0053                            size_t len, const void *key,
0054                            unsigned char ivec[16],
0055                            unsigned char ecount_buf[16], unsigned int *num,
0056                            block128_f block);
0057 
0058 void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
0059                                  size_t len, const void *key,
0060                                  unsigned char ivec[16],
0061                                  unsigned char ecount_buf[16],
0062                                  unsigned int *num, ctr128_f ctr);
0063 
0064 void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
0065                            size_t len, const void *key,
0066                            unsigned char ivec[16], int *num,
0067                            block128_f block);
0068 
0069 void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
0070                            size_t len, const void *key,
0071                            unsigned char ivec[16], int *num,
0072                            int enc, block128_f block);
0073 void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
0074                              size_t length, const void *key,
0075                              unsigned char ivec[16], int *num,
0076                              int enc, block128_f block);
0077 void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
0078                              size_t bits, const void *key,
0079                              unsigned char ivec[16], int *num,
0080                              int enc, block128_f block);
0081 
0082 size_t CRYPTO_cts128_encrypt_block(const unsigned char *in,
0083                                    unsigned char *out, size_t len,
0084                                    const void *key, unsigned char ivec[16],
0085                                    block128_f block);
0086 size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
0087                              size_t len, const void *key,
0088                              unsigned char ivec[16], cbc128_f cbc);
0089 size_t CRYPTO_cts128_decrypt_block(const unsigned char *in,
0090                                    unsigned char *out, size_t len,
0091                                    const void *key, unsigned char ivec[16],
0092                                    block128_f block);
0093 size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
0094                              size_t len, const void *key,
0095                              unsigned char ivec[16], cbc128_f cbc);
0096 
0097 size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,
0098                                        unsigned char *out, size_t len,
0099                                        const void *key,
0100                                        unsigned char ivec[16],
0101                                        block128_f block);
0102 size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
0103                                  size_t len, const void *key,
0104                                  unsigned char ivec[16], cbc128_f cbc);
0105 size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,
0106                                        unsigned char *out, size_t len,
0107                                        const void *key,
0108                                        unsigned char ivec[16],
0109                                        block128_f block);
0110 size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
0111                                  size_t len, const void *key,
0112                                  unsigned char ivec[16], cbc128_f cbc);
0113 
0114 typedef struct gcm128_context GCM128_CONTEXT;
0115 
0116 GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
0117 void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);
0118 void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
0119                          size_t len);
0120 int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
0121                       size_t len);
0122 int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
0123                           const unsigned char *in, unsigned char *out,
0124                           size_t len);
0125 int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
0126                           const unsigned char *in, unsigned char *out,
0127                           size_t len);
0128 int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
0129                                 const unsigned char *in, unsigned char *out,
0130                                 size_t len, ctr128_f stream);
0131 int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
0132                                 const unsigned char *in, unsigned char *out,
0133                                 size_t len, ctr128_f stream);
0134 int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,
0135                          size_t len);
0136 void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
0137 void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
0138 
0139 typedef struct ccm128_context CCM128_CONTEXT;
0140 
0141 void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
0142                         unsigned int M, unsigned int L, void *key,
0143                         block128_f block);
0144 int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,
0145                         size_t nlen, size_t mlen);
0146 void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,
0147                        size_t alen);
0148 int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,
0149                           unsigned char *out, size_t len);
0150 int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,
0151                           unsigned char *out, size_t len);
0152 int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
0153                                 unsigned char *out, size_t len,
0154                                 ccm128_f stream);
0155 int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
0156                                 unsigned char *out, size_t len,
0157                                 ccm128_f stream);
0158 size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
0159 
0160 typedef struct xts128_context XTS128_CONTEXT;
0161 
0162 int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
0163                           const unsigned char iv[16],
0164                           const unsigned char *inp, unsigned char *out,
0165                           size_t len, int enc);
0166 
0167 size_t CRYPTO_128_wrap(void *key, const unsigned char *iv,
0168                        unsigned char *out,
0169                        const unsigned char *in, size_t inlen,
0170                        block128_f block);
0171 
0172 size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
0173                          unsigned char *out,
0174                          const unsigned char *in, size_t inlen,
0175                          block128_f block);
0176 size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv,
0177                            unsigned char *out, const unsigned char *in,
0178                            size_t inlen, block128_f block);
0179 size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv,
0180                              unsigned char *out, const unsigned char *in,
0181                              size_t inlen, block128_f block);
0182 
0183 # ifndef OPENSSL_NO_OCB
0184 typedef struct ocb128_context OCB128_CONTEXT;
0185 
0186 typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out,
0187                           size_t blocks, const void *key,
0188                           size_t start_block_num,
0189                           unsigned char offset_i[16],
0190                           const unsigned char L_[][16],
0191                           unsigned char checksum[16]);
0192 
0193 OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
0194                                   block128_f encrypt, block128_f decrypt,
0195                                   ocb128_f stream);
0196 int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec,
0197                        block128_f encrypt, block128_f decrypt,
0198                        ocb128_f stream);
0199 int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src,
0200                            void *keyenc, void *keydec);
0201 int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
0202                         size_t len, size_t taglen);
0203 int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad,
0204                       size_t len);
0205 int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in,
0206                           unsigned char *out, size_t len);
0207 int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in,
0208                           unsigned char *out, size_t len);
0209 int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag,
0210                          size_t len);
0211 int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len);
0212 void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx);
0213 # endif                          /* OPENSSL_NO_OCB */
0214 
0215 # ifdef  __cplusplus
0216 }
0217 # endif
0218 
0219 #endif