Home | History | Annotate | Line # | Download | only in ciphers
      1 /*
      2  * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
      3  *
      4  * Licensed under the Apache License 2.0 (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 <openssl/aes.h>
     11 #include "prov/ciphercommon.h"
     12 #include "crypto/aes_platform.h"
     13 
     14 /*
     15  * Available in cipher_fips.c, and compiled with different values depending
     16  * on we're in the FIPS module or not.
     17  */
     18 extern const int ossl_aes_xts_allow_insecure_decrypt;
     19 
     20 PROV_CIPHER_FUNC(void, xts_stream,
     21     (const unsigned char *in, unsigned char *out, size_t len,
     22         const AES_KEY *key1, const AES_KEY *key2,
     23         const unsigned char iv[16]));
     24 
     25 #if defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
     26 typedef struct S390X_km_xts_params_st {
     27     unsigned char key[64];
     28     unsigned char tweak[16];
     29     unsigned char nap[16];
     30 } S390X_KM_XTS_PARAMS;
     31 #endif
     32 
     33 typedef struct prov_aes_xts_ctx_st {
     34     PROV_CIPHER_CTX base; /* Must be first */
     35     union {
     36         OSSL_UNION_ALIGN;
     37         AES_KEY ks;
     38     } ks1, ks2; /* AES key schedules to use */
     39     XTS128_CONTEXT xts;
     40     OSSL_xts_stream_fn stream;
     41 
     42     /* Platform specific data */
     43     union {
     44         int dummy;
     45 #if defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
     46         struct {
     47             union {
     48                 OSSL_UNION_ALIGN;
     49                 S390X_KM_XTS_PARAMS km;
     50             } param;
     51             size_t offset;
     52             unsigned int fc;
     53             unsigned int iv_set : 1;
     54             unsigned int key_set : 1;
     55         } s390x;
     56 #endif
     57     } plat;
     58 } PROV_AES_XTS_CTX;
     59 
     60 const PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_xts(size_t keybits);
     61