s390x_arch.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (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. #ifndef S390X_ARCH_H
  10. # define S390X_ARCH_H
  11. # ifndef __ASSEMBLER__
  12. void s390x_km(const unsigned char *in, size_t len, unsigned char *out,
  13. unsigned int fc, void *param);
  14. void s390x_kmac(const unsigned char *in, size_t len, unsigned int fc,
  15. void *param);
  16. void s390x_kmo(const unsigned char *in, size_t len, unsigned char *out,
  17. unsigned int fc, void *param);
  18. void s390x_kmf(const unsigned char *in, size_t len, unsigned char *out,
  19. unsigned int fc, void *param);
  20. void s390x_kma(const unsigned char *aad, size_t alen, const unsigned char *in,
  21. size_t len, unsigned char *out, unsigned int fc, void *param);
  22. /*
  23. * The field elements of OPENSSL_s390xcap_P are the 64-bit words returned by
  24. * the STFLE instruction followed by the 64-bit word pairs returned by
  25. * instructions' QUERY functions. If STFLE returns fewer data or an instruction
  26. * is not supported, the corresponding field elements are zero.
  27. */
  28. struct OPENSSL_s390xcap_st {
  29. unsigned long long stfle[4];
  30. unsigned long long kimd[2];
  31. unsigned long long klmd[2];
  32. unsigned long long km[2];
  33. unsigned long long kmc[2];
  34. unsigned long long kmac[2];
  35. unsigned long long kmctr[2];
  36. unsigned long long kmo[2];
  37. unsigned long long kmf[2];
  38. unsigned long long prno[2];
  39. unsigned long long kma[2];
  40. };
  41. extern struct OPENSSL_s390xcap_st OPENSSL_s390xcap_P;
  42. /* convert facility bit number or function code to bit mask */
  43. # define S390X_CAPBIT(i) (1ULL << (63 - (i) % 64))
  44. # endif
  45. /* OPENSSL_s390xcap_P offsets [bytes] */
  46. # define S390X_STFLE 0x00
  47. # define S390X_KIMD 0x20
  48. # define S390X_KLMD 0x30
  49. # define S390X_KM 0x40
  50. # define S390X_KMC 0x50
  51. # define S390X_KMAC 0x60
  52. # define S390X_KMCTR 0x70
  53. # define S390X_KMO 0x80
  54. # define S390X_KMF 0x90
  55. # define S390X_PRNO 0xa0
  56. # define S390X_KMA 0xb0
  57. /* Facility Bit Numbers */
  58. # define S390X_VX 129
  59. # define S390X_VXD 134
  60. # define S390X_VXE 135
  61. /* Function Codes */
  62. /* all instructions */
  63. # define S390X_QUERY 0
  64. /* kimd/klmd */
  65. # define S390X_SHA3_224 32
  66. # define S390X_SHA3_256 33
  67. # define S390X_SHA3_384 34
  68. # define S390X_SHA3_512 35
  69. # define S390X_SHAKE_128 36
  70. # define S390X_SHAKE_256 37
  71. # define S390X_GHASH 65
  72. /* km/kmc/kmac/kmctr/kmo/kmf/kma */
  73. # define S390X_AES_128 18
  74. # define S390X_AES_192 19
  75. # define S390X_AES_256 20
  76. /* prno */
  77. # define S390X_TRNG 114
  78. /* Register 0 Flags */
  79. # define S390X_DECRYPT 0x80
  80. # define S390X_KMA_LPC 0x100
  81. # define S390X_KMA_LAAD 0x200
  82. # define S390X_KMA_HS 0x400
  83. #endif