aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/crypto/aes_s390.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/crypto/aes_s390.c')
-rw-r--r--arch/s390/crypto/aes_s390.c112
1 files changed, 0 insertions, 112 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};