[CRYPTO] s390: Added block cipher versions of CBC/ECB
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / s390 / crypto / crypt_s390.h
index 4d24f66..efd836c 100644 (file)
@@ -20,6 +20,9 @@
 #define CRYPT_S390_OP_MASK 0xFF00
 #define CRYPT_S390_FUNC_MASK 0x00FF
 
+#define CRYPT_S390_PRIORITY 300
+#define CRYPT_S390_COMPOSITE_PRIORITY 400
+
 /* s930 cryptographic operations */
 enum crypt_s390_operations {
        CRYPT_S390_KM   = 0x0100,
@@ -33,26 +36,38 @@ enum crypt_s390_operations {
  * 0x80 is the decipher modifier bit
  */
 enum crypt_s390_km_func {
-       KM_QUERY            = CRYPT_S390_KM | 0,
-       KM_DEA_ENCRYPT      = CRYPT_S390_KM | 1,
-       KM_DEA_DECRYPT      = CRYPT_S390_KM | 1 | 0x80,
-       KM_TDEA_128_ENCRYPT = CRYPT_S390_KM | 2,
-       KM_TDEA_128_DECRYPT = CRYPT_S390_KM | 2 | 0x80,
-       KM_TDEA_192_ENCRYPT = CRYPT_S390_KM | 3,
-       KM_TDEA_192_DECRYPT = CRYPT_S390_KM | 3 | 0x80,
+       KM_QUERY            = CRYPT_S390_KM | 0x0,
+       KM_DEA_ENCRYPT      = CRYPT_S390_KM | 0x1,
+       KM_DEA_DECRYPT      = CRYPT_S390_KM | 0x1 | 0x80,
+       KM_TDEA_128_ENCRYPT = CRYPT_S390_KM | 0x2,
+       KM_TDEA_128_DECRYPT = CRYPT_S390_KM | 0x2 | 0x80,
+       KM_TDEA_192_ENCRYPT = CRYPT_S390_KM | 0x3,
+       KM_TDEA_192_DECRYPT = CRYPT_S390_KM | 0x3 | 0x80,
+       KM_AES_128_ENCRYPT  = CRYPT_S390_KM | 0x12,
+       KM_AES_128_DECRYPT  = CRYPT_S390_KM | 0x12 | 0x80,
+       KM_AES_192_ENCRYPT  = CRYPT_S390_KM | 0x13,
+       KM_AES_192_DECRYPT  = CRYPT_S390_KM | 0x13 | 0x80,
+       KM_AES_256_ENCRYPT  = CRYPT_S390_KM | 0x14,
+       KM_AES_256_DECRYPT  = CRYPT_S390_KM | 0x14 | 0x80,
 };
 
 /* function codes for KMC (CIPHER MESSAGE WITH CHAINING)
  * instruction
  */
 enum crypt_s390_kmc_func {
-       KMC_QUERY            = CRYPT_S390_KMC | 0,
-       KMC_DEA_ENCRYPT      = CRYPT_S390_KMC | 1,
-       KMC_DEA_DECRYPT      = CRYPT_S390_KMC | 1 | 0x80,
-       KMC_TDEA_128_ENCRYPT = CRYPT_S390_KMC | 2,
-       KMC_TDEA_128_DECRYPT = CRYPT_S390_KMC | 2 | 0x80,
-       KMC_TDEA_192_ENCRYPT = CRYPT_S390_KMC | 3,
-       KMC_TDEA_192_DECRYPT = CRYPT_S390_KMC | 3 | 0x80,
+       KMC_QUERY            = CRYPT_S390_KMC | 0x0,
+       KMC_DEA_ENCRYPT      = CRYPT_S390_KMC | 0x1,
+       KMC_DEA_DECRYPT      = CRYPT_S390_KMC | 0x1 | 0x80,
+       KMC_TDEA_128_ENCRYPT = CRYPT_S390_KMC | 0x2,
+       KMC_TDEA_128_DECRYPT = CRYPT_S390_KMC | 0x2 | 0x80,
+       KMC_TDEA_192_ENCRYPT = CRYPT_S390_KMC | 0x3,
+       KMC_TDEA_192_DECRYPT = CRYPT_S390_KMC | 0x3 | 0x80,
+       KMC_AES_128_ENCRYPT  = CRYPT_S390_KMC | 0x12,
+       KMC_AES_128_DECRYPT  = CRYPT_S390_KMC | 0x12 | 0x80,
+       KMC_AES_192_ENCRYPT  = CRYPT_S390_KMC | 0x13,
+       KMC_AES_192_DECRYPT  = CRYPT_S390_KMC | 0x13 | 0x80,
+       KMC_AES_256_ENCRYPT  = CRYPT_S390_KMC | 0x14,
+       KMC_AES_256_DECRYPT  = CRYPT_S390_KMC | 0x14 | 0x80,
 };
 
 /* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST)
@@ -61,6 +76,7 @@ enum crypt_s390_kmc_func {
 enum crypt_s390_kimd_func {
        KIMD_QUERY   = CRYPT_S390_KIMD | 0,
        KIMD_SHA_1   = CRYPT_S390_KIMD | 1,
+       KIMD_SHA_256 = CRYPT_S390_KIMD | 2,
 };
 
 /* function codes for KLMD (COMPUTE LAST MESSAGE DIGEST)
@@ -69,6 +85,7 @@ enum crypt_s390_kimd_func {
 enum crypt_s390_klmd_func {
        KLMD_QUERY   = CRYPT_S390_KLMD | 0,
        KLMD_SHA_1   = CRYPT_S390_KLMD | 1,
+       KLMD_SHA_256 = CRYPT_S390_KLMD | 2,
 };
 
 /* function codes for KMAC (COMPUTE MESSAGE AUTHENTICATION CODE)
@@ -98,7 +115,7 @@ struct crypt_s390_query_status {
  * [ret] is the variable to receive the error code
  * [ERR] is the error code value
  */
-#ifndef __s390x__
+#ifndef CONFIG_64BIT
 #define __crypt_s390_fixup \
        ".section .fixup,\"ax\" \n"     \
        "7:     lhi     %0,%h[e1] \n"   \
@@ -115,7 +132,7 @@ struct crypt_s390_query_status {
        "       .long   0b,7b \n"       \
        "       .long   1b,8b \n"       \
        ".previous"
-#else /* __s390x__ */
+#else /* CONFIG_64BIT */
 #define __crypt_s390_fixup \
        ".section .fixup,\"ax\" \n"     \
        "7:     lhi     %0,%h[e1] \n"   \
@@ -128,7 +145,7 @@ struct crypt_s390_query_status {
        "       .quad   0b,7b \n"       \
        "       .quad   1b,8b \n"       \
        ".previous"
-#endif /* __s390x__ */
+#endif /* CONFIG_64BIT */
 
 /*
  * Standard code for setting the result of s390 crypto instructions.
@@ -136,10 +153,10 @@ struct crypt_s390_query_status {
  * [result]: the register containing the result (e.g. second operand length
  * to compute number of processed bytes].
  */
-#ifndef __s390x__
+#ifndef CONFIG_64BIT
 #define __crypt_s390_set_result \
        "       lr      %0,%[result] \n"
-#else /* __s390x__ */
+#else /* CONFIG_64BIT */
 #define __crypt_s390_set_result \
        "       lgr     %0,%[result] \n"
 #endif