aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/crypto/aes_s390.c112
-rw-r--r--arch/s390/crypto/des_s390.c203
2 files changed, 0 insertions, 315 deletions
diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index 8f04b4e41b55..15c9eec02928 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -113,114 +113,6 @@ static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
113 } 113 }
114} 114}
115 115
116static unsigned int aes_encrypt_ecb(const struct cipher_desc *desc, u8 *out,
117 const u8 *in, unsigned int nbytes)
118{
119 struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm);
120 int ret;
121
122 /* only use complete blocks */
123 nbytes &= ~(AES_BLOCK_SIZE - 1);
124
125 switch (sctx->key_len) {
126 case 16:
127 ret = crypt_s390_km(KM_AES_128_ENCRYPT, &sctx->key, out, in, nbytes);
128 BUG_ON((ret < 0) || (ret != nbytes));
129 break;
130 case 24:
131 ret = crypt_s390_km(KM_AES_192_ENCRYPT, &sctx->key, out, in, nbytes);
132 BUG_ON((ret < 0) || (ret != nbytes));
133 break;
134 case 32:
135 ret = crypt_s390_km(KM_AES_256_ENCRYPT, &sctx->key, out, in, nbytes);
136 BUG_ON((ret < 0) || (ret != nbytes));
137 break;
138 }
139 return nbytes;
140}
141
142static unsigned int aes_decrypt_ecb(const struct cipher_desc *desc, u8 *out,
143 const u8 *in, unsigned int nbytes)
144{
145 struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm);
146 int ret;
147
148 /* only use complete blocks */
149 nbytes &= ~(AES_BLOCK_SIZE - 1);
150
151 switch (sctx->key_len) {
152 case 16:
153 ret = crypt_s390_km(KM_AES_128_DECRYPT, &sctx->key, out, in, nbytes);
154 BUG_ON((ret < 0) || (ret != nbytes));
155 break;
156 case 24:
157 ret = crypt_s390_km(KM_AES_192_DECRYPT, &sctx->key, out, in, nbytes);
158 BUG_ON((ret < 0) || (ret != nbytes));
159 break;
160 case 32:
161 ret = crypt_s390_km(KM_AES_256_DECRYPT, &sctx->key, out, in, nbytes);
162 BUG_ON((ret < 0) || (ret != nbytes));
163 break;
164 }
165 return nbytes;
166}
167
168static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out,
169 const u8 *in, unsigned int nbytes)
170{
171 struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm);
172 int ret;
173
174 /* only use complete blocks */
175 nbytes &= ~(AES_BLOCK_SIZE - 1);
176
177 memcpy(&sctx->iv, desc->info, AES_BLOCK_SIZE);
178 switch (sctx->key_len) {
179 case 16:
180 ret = crypt_s390_kmc(KMC_AES_128_ENCRYPT, &sctx->iv, out, in, nbytes);
181 BUG_ON((ret < 0) || (ret != nbytes));
182 break;
183 case 24:
184 ret = crypt_s390_kmc(KMC_AES_192_ENCRYPT, &sctx->iv, out, in, nbytes);
185 BUG_ON((ret < 0) || (ret != nbytes));
186 break;
187 case 32:
188 ret = crypt_s390_kmc(KMC_AES_256_ENCRYPT, &sctx->iv, out, in, nbytes);
189 BUG_ON((ret < 0) || (ret != nbytes));
190 break;
191 }
192 memcpy(desc->info, &sctx->iv, AES_BLOCK_SIZE);
193
194 return nbytes;
195}
196
197static unsigned int aes_decrypt_cbc(const struct cipher_desc *desc, u8 *out,
198 const u8 *in, unsigned int nbytes)
199{
200 struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm);
201 int ret;
202
203 /* only use complete blocks */
204 nbytes &= ~(AES_BLOCK_SIZE - 1);
205
206 memcpy(&sctx->iv, desc->info, AES_BLOCK_SIZE);
207 switch (sctx->key_len) {
208 case 16:
209 ret = crypt_s390_kmc(KMC_AES_128_DECRYPT, &sctx->iv, out, in, nbytes);
210 BUG_ON((ret < 0) || (ret != nbytes));
211 break;
212 case 24:
213 ret = crypt_s390_kmc(KMC_AES_192_DECRYPT, &sctx->iv, out, in, nbytes);
214 BUG_ON((ret < 0) || (ret != nbytes));
215 break;
216 case 32:
217 ret = crypt_s390_kmc(KMC_AES_256_DECRYPT, &sctx->iv, out, in, nbytes);
218 BUG_ON((ret < 0) || (ret != nbytes));
219 break;
220 }
221 return nbytes;
222}
223
224 116
225static struct crypto_alg aes_alg = { 117static struct crypto_alg aes_alg = {
226 .cra_name = "aes", 118 .cra_name = "aes",
@@ -238,10 +130,6 @@ static struct crypto_alg aes_alg = {
238 .cia_setkey = aes_set_key, 130 .cia_setkey = aes_set_key,
239 .cia_encrypt = aes_encrypt, 131 .cia_encrypt = aes_encrypt,
240 .cia_decrypt = aes_decrypt, 132 .cia_decrypt = aes_decrypt,
241 .cia_encrypt_ecb = aes_encrypt_ecb,
242 .cia_decrypt_ecb = aes_decrypt_ecb,
243 .cia_encrypt_cbc = aes_encrypt_cbc,
244 .cia_decrypt_cbc = aes_decrypt_cbc,
245 } 133 }
246 } 134 }
247}; 135};
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c
index a6d2385ccb7a..2aba04852fe3 100644
--- a/arch/s390/crypto/des_s390.c
+++ b/arch/s390/crypto/des_s390.c
@@ -73,67 +73,6 @@ static void des_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
73 crypt_s390_km(KM_DEA_DECRYPT, dctx->key, out, in, DES_BLOCK_SIZE); 73 crypt_s390_km(KM_DEA_DECRYPT, dctx->key, out, in, DES_BLOCK_SIZE);
74} 74}
75 75
76static unsigned int des_encrypt_ecb(const struct cipher_desc *desc, u8 *out,
77 const u8 *in, unsigned int nbytes)
78{
79 struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm);
80 int ret;
81
82 /* only use complete blocks */
83 nbytes &= ~(DES_BLOCK_SIZE - 1);
84 ret = crypt_s390_km(KM_DEA_ENCRYPT, sctx->key, out, in, nbytes);
85 BUG_ON((ret < 0) || (ret != nbytes));
86
87 return nbytes;
88}
89
90static unsigned int des_decrypt_ecb(const struct cipher_desc *desc, u8 *out,
91 const u8 *in, unsigned int nbytes)
92{
93 struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm);
94 int ret;
95
96 /* only use complete blocks */
97 nbytes &= ~(DES_BLOCK_SIZE - 1);
98 ret = crypt_s390_km(KM_DEA_DECRYPT, sctx->key, out, in, nbytes);
99 BUG_ON((ret < 0) || (ret != nbytes));
100
101 return nbytes;
102}
103
104static unsigned int des_encrypt_cbc(const struct cipher_desc *desc, u8 *out,
105 const u8 *in, unsigned int nbytes)
106{
107 struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm);
108 int ret;
109
110 /* only use complete blocks */
111 nbytes &= ~(DES_BLOCK_SIZE - 1);
112
113 memcpy(sctx->iv, desc->info, DES_BLOCK_SIZE);
114 ret = crypt_s390_kmc(KMC_DEA_ENCRYPT, &sctx->iv, out, in, nbytes);
115 BUG_ON((ret < 0) || (ret != nbytes));
116
117 memcpy(desc->info, sctx->iv, DES_BLOCK_SIZE);
118 return nbytes;
119}
120
121static unsigned int des_decrypt_cbc(const struct cipher_desc *desc, u8 *out,
122 const u8 *in, unsigned int nbytes)
123{
124 struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm);
125 int ret;
126
127 /* only use complete blocks */
128 nbytes &= ~(DES_BLOCK_SIZE - 1);
129
130 memcpy(&sctx->iv, desc->info, DES_BLOCK_SIZE);
131 ret = crypt_s390_kmc(KMC_DEA_DECRYPT, &sctx->iv, out, in, nbytes);
132 BUG_ON((ret < 0) || (ret != nbytes));
133
134 return nbytes;
135}
136
137static struct crypto_alg des_alg = { 76static struct crypto_alg des_alg = {
138 .cra_name = "des", 77 .cra_name = "des",
139 .cra_driver_name = "des-s390", 78 .cra_driver_name = "des-s390",
@@ -150,10 +89,6 @@ static struct crypto_alg des_alg = {
150 .cia_setkey = des_setkey, 89 .cia_setkey = des_setkey,
151 .cia_encrypt = des_encrypt, 90 .cia_encrypt = des_encrypt,
152 .cia_decrypt = des_decrypt, 91 .cia_decrypt = des_decrypt,
153 .cia_encrypt_ecb = des_encrypt_ecb,
154 .cia_decrypt_ecb = des_decrypt_ecb,
155 .cia_encrypt_cbc = des_encrypt_cbc,
156 .cia_decrypt_cbc = des_decrypt_cbc,
157 } 92 }
158 } 93 }
159}; 94};
@@ -344,71 +279,6 @@ static void des3_128_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
344 DES3_128_BLOCK_SIZE); 279 DES3_128_BLOCK_SIZE);
345} 280}
346 281
347static unsigned int des3_128_encrypt_ecb(const struct cipher_desc *desc,
348 u8 *out, const u8 *in,
349 unsigned int nbytes)
350{
351 struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm);
352 int ret;
353
354 /* only use complete blocks */
355 nbytes &= ~(DES3_128_BLOCK_SIZE - 1);
356 ret = crypt_s390_km(KM_TDEA_128_ENCRYPT, sctx->key, out, in, nbytes);
357 BUG_ON((ret < 0) || (ret != nbytes));
358
359 return nbytes;
360}
361
362static unsigned int des3_128_decrypt_ecb(const struct cipher_desc *desc,
363 u8 *out, const u8 *in,
364 unsigned int nbytes)
365{
366 struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm);
367 int ret;
368
369 /* only use complete blocks */
370 nbytes &= ~(DES3_128_BLOCK_SIZE - 1);
371 ret = crypt_s390_km(KM_TDEA_128_DECRYPT, sctx->key, out, in, nbytes);
372 BUG_ON((ret < 0) || (ret != nbytes));
373
374 return nbytes;
375}
376
377static unsigned int des3_128_encrypt_cbc(const struct cipher_desc *desc,
378 u8 *out, const u8 *in,
379 unsigned int nbytes)
380{
381 struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm);
382 int ret;
383
384 /* only use complete blocks */
385 nbytes &= ~(DES3_128_BLOCK_SIZE - 1);
386
387 memcpy(sctx->iv, desc->info, DES3_128_BLOCK_SIZE);
388 ret = crypt_s390_kmc(KMC_TDEA_128_ENCRYPT, &sctx->iv, out, in, nbytes);
389 BUG_ON((ret < 0) || (ret != nbytes));
390
391 memcpy(desc->info, sctx->iv, DES3_128_BLOCK_SIZE);
392 return nbytes;
393}
394
395static unsigned int des3_128_decrypt_cbc(const struct cipher_desc *desc,
396 u8 *out, const u8 *in,
397 unsigned int nbytes)
398{
399 struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm);
400 int ret;
401
402 /* only use complete blocks */
403 nbytes &= ~(DES3_128_BLOCK_SIZE - 1);
404
405 memcpy(&sctx->iv, desc->info, DES3_128_BLOCK_SIZE);
406 ret = crypt_s390_kmc(KMC_TDEA_128_DECRYPT, &sctx->iv, out, in, nbytes);
407 BUG_ON((ret < 0) || (ret != nbytes));
408
409 return nbytes;
410}
411
412static struct crypto_alg des3_128_alg = { 282static struct crypto_alg des3_128_alg = {
413 .cra_name = "des3_ede128", 283 .cra_name = "des3_ede128",
414 .cra_driver_name = "des3_ede128-s390", 284 .cra_driver_name = "des3_ede128-s390",
@@ -425,10 +295,6 @@ static struct crypto_alg des3_128_alg = {
425 .cia_setkey = des3_128_setkey, 295 .cia_setkey = des3_128_setkey,
426 .cia_encrypt = des3_128_encrypt, 296 .cia_encrypt = des3_128_encrypt,
427 .cia_decrypt = des3_128_decrypt, 297 .cia_decrypt = des3_128_decrypt,
428 .cia_encrypt_ecb = des3_128_encrypt_ecb,
429 .cia_decrypt_ecb = des3_128_decrypt_ecb,
430 .cia_encrypt_cbc = des3_128_encrypt_cbc,
431 .cia_decrypt_cbc = des3_128_decrypt_cbc,
432 } 298 }
433 } 299 }
434}; 300};
@@ -575,71 +441,6 @@ static void des3_192_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
575 DES3_192_BLOCK_SIZE); 441 DES3_192_BLOCK_SIZE);
576} 442}
577 443
578static unsigned int des3_192_encrypt_ecb(const struct cipher_desc *desc,
579 u8 *out, const u8 *in,
580 unsigned int nbytes)
581{
582 struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm);
583 int ret;
584
585 /* only use complete blocks */
586 nbytes &= ~(DES3_192_BLOCK_SIZE - 1);
587 ret = crypt_s390_km(KM_TDEA_192_ENCRYPT, sctx->key, out, in, nbytes);
588 BUG_ON((ret < 0) || (ret != nbytes));
589
590 return nbytes;
591}
592
593static unsigned int des3_192_decrypt_ecb(const struct cipher_desc *desc,
594 u8 *out, const u8 *in,
595 unsigned int nbytes)
596{
597 struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm);
598 int ret;
599
600 /* only use complete blocks */
601 nbytes &= ~(DES3_192_BLOCK_SIZE - 1);
602 ret = crypt_s390_km(KM_TDEA_192_DECRYPT, sctx->key, out, in, nbytes);
603 BUG_ON((ret < 0) || (ret != nbytes));
604
605 return nbytes;
606}
607
608static unsigned int des3_192_encrypt_cbc(const struct cipher_desc *desc,
609 u8 *out, const u8 *in,
610 unsigned int nbytes)
611{
612 struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm);
613 int ret;
614
615 /* only use complete blocks */
616 nbytes &= ~(DES3_192_BLOCK_SIZE - 1);
617
618 memcpy(sctx->iv, desc->info, DES3_192_BLOCK_SIZE);
619 ret = crypt_s390_kmc(KMC_TDEA_192_ENCRYPT, &sctx->iv, out, in, nbytes);
620 BUG_ON((ret < 0) || (ret != nbytes));
621
622 memcpy(desc->info, sctx->iv, DES3_192_BLOCK_SIZE);
623 return nbytes;
624}
625
626static unsigned int des3_192_decrypt_cbc(const struct cipher_desc *desc,
627 u8 *out, const u8 *in,
628 unsigned int nbytes)
629{
630 struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm);
631 int ret;
632
633 /* only use complete blocks */
634 nbytes &= ~(DES3_192_BLOCK_SIZE - 1);
635
636 memcpy(&sctx->iv, desc->info, DES3_192_BLOCK_SIZE);
637 ret = crypt_s390_kmc(KMC_TDEA_192_DECRYPT, &sctx->iv, out, in, nbytes);
638 BUG_ON((ret < 0) || (ret != nbytes));
639
640 return nbytes;
641}
642
643static struct crypto_alg des3_192_alg = { 444static struct crypto_alg des3_192_alg = {
644 .cra_name = "des3_ede", 445 .cra_name = "des3_ede",
645 .cra_driver_name = "des3_ede-s390", 446 .cra_driver_name = "des3_ede-s390",
@@ -656,10 +457,6 @@ static struct crypto_alg des3_192_alg = {
656 .cia_setkey = des3_192_setkey, 457 .cia_setkey = des3_192_setkey,
657 .cia_encrypt = des3_192_encrypt, 458 .cia_encrypt = des3_192_encrypt,
658 .cia_decrypt = des3_192_decrypt, 459 .cia_decrypt = des3_192_decrypt,
659 .cia_encrypt_ecb = des3_192_encrypt_ecb,
660 .cia_decrypt_ecb = des3_192_decrypt_ecb,
661 .cia_encrypt_cbc = des3_192_encrypt_cbc,
662 .cia_decrypt_cbc = des3_192_decrypt_cbc,
663 } 460 }
664 } 461 }
665}; 462};