Add gcm ciphers (aes and aria) to providers.
[openssl.git] / providers / common / ciphers / ciphers_locl.h
index 49248f099c823cf0e2bac7b41e844b18cd7024c3..91033eb2628b4006642ca1acf8038263f89895b5 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  *
@@ -8,12 +7,46 @@
  * https://www.openssl.org/source/license.html
  */
 
+#include <openssl/opensslconf.h>
 #include <openssl/aes.h>
-#include <openssl/modes.h>
+#include <openssl/params.h>
 #include "internal/cryptlib.h"
+#include "internal/modes_int.h"
+
+#if defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
+/*-
+ * KMA-GCM-AES parameter block - begin
+ * (see z/Architecture Principles of Operation >= SA22-7832-11)
+ */
+typedef struct S390X_kma_params_st {
+    unsigned char reserved[12];
+    union {
+        unsigned int w;
+        unsigned char b[4];
+    } cv; /* 32 bit counter value */
+    union {
+        unsigned long long g[2];
+        unsigned char b[16];
+    } t; /* tag */
+    unsigned char h[16]; /* hash subkey */
+    unsigned long long taadl; /* total AAD length */
+    unsigned long long tpcl; /* total plaintxt/ciphertxt len */
+    union {
+        unsigned long long g[2];
+        unsigned int w[4];
+    } j0;                   /* initial counter value */
+    unsigned char k[32];    /* key */
+} S390X_KMA_PARAMS;
+
+#endif
 
 typedef struct prov_aes_cipher_st PROV_AES_CIPHER;
 
+#define IV_STATE_UNINITIALISED 0  /* initial state is not initialized */
+#define IV_STATE_BUFFERED      1  /* iv has been copied to the iv buffer */
+#define IV_STATE_COPIED        2  /* iv has been copied from the iv buffer */
+#define IV_STATE_FINISHED      3  /* the iv has been used - so don't reuse it */
+
 typedef struct prov_aes_key_st {
     union {
         OSSL_UNION_ALIGN;
@@ -93,6 +126,10 @@ struct prov_aes_cipher_st {
                 size_t inl);
 };
 
+#define OSSL_CIPHER_FUNC(type, name, args) typedef type (* OSSL_##name##_fn)args
+
+#include "ciphers_gcm.h"
+
 const PROV_AES_CIPHER *PROV_AES_CIPHER_ecb(size_t keylen);
 const PROV_AES_CIPHER *PROV_AES_CIPHER_cbc(size_t keylen);
 const PROV_AES_CIPHER *PROV_AES_CIPHER_ofb(size_t keylen);
@@ -107,3 +144,5 @@ int trailingdata(unsigned char *buf, size_t *buflen, size_t blocksize,
                  const unsigned char **in, size_t *inlen);
 void padblock(unsigned char *buf, size_t *buflen, size_t blocksize);
 int unpadblock(unsigned char *buf, size_t *buflen, size_t blocksize);
+int aes_get_params(OSSL_PARAM params[], int md, unsigned long flags,
+                   int kbits, int blkbits, int ivbits);