cpacf.h (edc63a3785b48455e05793e848f0174e21f38d09) | cpacf.h (0177db01adf26cf9c5dfe1feaf17087de4b9e40e) |
---|---|
1/* 2 * CP Assist for Cryptographic Functions (CPACF) 3 * 4 * Copyright IBM Corp. 2003, 2016 5 * Author(s): Thomas Spatzier 6 * Jan Glauber 7 * Harald Freudenberger (freude@de.ibm.com) 8 * Martin Schwidefsky <schwidefsky@de.ibm.com> --- 220 unchanged lines hidden (view full) --- 229 230/** 231 * cpacf_kimd() - executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) 232 * instruction 233 * @func: the function code passed to KM; see CPACF_KIMD_xxx defines 234 * @param: address of parameter block; see POP for details on each func 235 * @src: address of source memory area 236 * @src_len: length of src operand in bytes | 1/* 2 * CP Assist for Cryptographic Functions (CPACF) 3 * 4 * Copyright IBM Corp. 2003, 2016 5 * Author(s): Thomas Spatzier 6 * Jan Glauber 7 * Harald Freudenberger (freude@de.ibm.com) 8 * Martin Schwidefsky <schwidefsky@de.ibm.com> --- 220 unchanged lines hidden (view full) --- 229 230/** 231 * cpacf_kimd() - executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) 232 * instruction 233 * @func: the function code passed to KM; see CPACF_KIMD_xxx defines 234 * @param: address of parameter block; see POP for details on each func 235 * @src: address of source memory area 236 * @src_len: length of src operand in bytes |
237 * 238 * Returns 0 for the query func, number of processed bytes for digest funcs | |
239 */ | 237 */ |
240static inline int cpacf_kimd(unsigned long func, void *param, 241 const u8 *src, long src_len) | 238static inline void cpacf_kimd(unsigned long func, void *param, 239 const u8 *src, long src_len) |
242{ 243 register unsigned long r0 asm("0") = (unsigned long) func; 244 register unsigned long r1 asm("1") = (unsigned long) param; 245 register unsigned long r2 asm("2") = (unsigned long) src; 246 register unsigned long r3 asm("3") = (unsigned long) src_len; 247 248 asm volatile( 249 "0: .insn rre,%[opc] << 16,0,%[src]\n" 250 " brc 1,0b\n" /* handle partial completion */ 251 : [src] "+a" (r2), [len] "+d" (r3) 252 : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KIMD) 253 : "cc", "memory"); | 240{ 241 register unsigned long r0 asm("0") = (unsigned long) func; 242 register unsigned long r1 asm("1") = (unsigned long) param; 243 register unsigned long r2 asm("2") = (unsigned long) src; 244 register unsigned long r3 asm("3") = (unsigned long) src_len; 245 246 asm volatile( 247 "0: .insn rre,%[opc] << 16,0,%[src]\n" 248 " brc 1,0b\n" /* handle partial completion */ 249 : [src] "+a" (r2), [len] "+d" (r3) 250 : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KIMD) 251 : "cc", "memory"); |
254 255 return src_len - r3; | |
256} 257 258/** 259 * cpacf_klmd() - executes the KLMD (COMPUTE LAST MESSAGE DIGEST) instruction 260 * @func: the function code passed to KM; see CPACF_KLMD_xxx defines 261 * @param: address of parameter block; see POP for details on each func 262 * @src: address of source memory area 263 * @src_len: length of src operand in bytes | 252} 253 254/** 255 * cpacf_klmd() - executes the KLMD (COMPUTE LAST MESSAGE DIGEST) instruction 256 * @func: the function code passed to KM; see CPACF_KLMD_xxx defines 257 * @param: address of parameter block; see POP for details on each func 258 * @src: address of source memory area 259 * @src_len: length of src operand in bytes |
264 * 265 * Returns 0 for the query func, number of processed bytes for digest funcs | |
266 */ | 260 */ |
267static inline int cpacf_klmd(unsigned long func, void *param, 268 const u8 *src, long src_len) | 261static inline void cpacf_klmd(unsigned long func, void *param, 262 const u8 *src, long src_len) |
269{ 270 register unsigned long r0 asm("0") = (unsigned long) func; 271 register unsigned long r1 asm("1") = (unsigned long) param; 272 register unsigned long r2 asm("2") = (unsigned long) src; 273 register unsigned long r3 asm("3") = (unsigned long) src_len; 274 275 asm volatile( 276 "0: .insn rre,%[opc] << 16,0,%[src]\n" 277 " brc 1,0b\n" /* handle partial completion */ 278 : [src] "+a" (r2), [len] "+d" (r3) 279 : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KLMD) 280 : "cc", "memory"); | 263{ 264 register unsigned long r0 asm("0") = (unsigned long) func; 265 register unsigned long r1 asm("1") = (unsigned long) param; 266 register unsigned long r2 asm("2") = (unsigned long) src; 267 register unsigned long r3 asm("3") = (unsigned long) src_len; 268 269 asm volatile( 270 "0: .insn rre,%[opc] << 16,0,%[src]\n" 271 " brc 1,0b\n" /* handle partial completion */ 272 : [src] "+a" (r2), [len] "+d" (r3) 273 : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_KLMD) 274 : "cc", "memory"); |
281 282 return src_len - r3; | |
283} 284 285/** 286 * cpacf_kmac() - executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) 287 * instruction 288 * @func: the function code passed to KM; see CPACF_KMAC_xxx defines 289 * @param: address of parameter block; see POP for details on each func 290 * @src: address of source memory area --- 56 unchanged lines hidden (view full) --- 347 * cpacf_ppno() - executes the PPNO (PERFORM PSEUDORANDOM NUMBER OPERATION) 348 * instruction 349 * @func: the function code passed to PPNO; see CPACF_PPNO_xxx defines 350 * @param: address of parameter block; see POP for details on each func 351 * @dest: address of destination memory area 352 * @dest_len: size of destination memory area in bytes 353 * @seed: address of seed data 354 * @seed_len: size of seed data in bytes | 275} 276 277/** 278 * cpacf_kmac() - executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) 279 * instruction 280 * @func: the function code passed to KM; see CPACF_KMAC_xxx defines 281 * @param: address of parameter block; see POP for details on each func 282 * @src: address of source memory area --- 56 unchanged lines hidden (view full) --- 339 * cpacf_ppno() - executes the PPNO (PERFORM PSEUDORANDOM NUMBER OPERATION) 340 * instruction 341 * @func: the function code passed to PPNO; see CPACF_PPNO_xxx defines 342 * @param: address of parameter block; see POP for details on each func 343 * @dest: address of destination memory area 344 * @dest_len: size of destination memory area in bytes 345 * @seed: address of seed data 346 * @seed_len: size of seed data in bytes |
355 * 356 * Returns 0 for the query func, number of random bytes stored in 357 * dest buffer for generate function | |
358 */ | 347 */ |
359static inline int cpacf_ppno(unsigned long func, void *param, 360 u8 *dest, long dest_len, 361 const u8 *seed, long seed_len) | 348static inline void cpacf_ppno(unsigned long func, void *param, 349 u8 *dest, long dest_len, 350 const u8 *seed, long seed_len) |
362{ 363 register unsigned long r0 asm("0") = (unsigned long) func; 364 register unsigned long r1 asm("1") = (unsigned long) param; 365 register unsigned long r2 asm("2") = (unsigned long) dest; 366 register unsigned long r3 asm("3") = (unsigned long) dest_len; 367 register unsigned long r4 asm("4") = (unsigned long) seed; 368 register unsigned long r5 asm("5") = (unsigned long) seed_len; 369 370 asm volatile ( 371 "0: .insn rre,%[opc] << 16,%[dst],%[seed]\n" 372 " brc 1,0b\n" /* handle partial completion */ 373 : [dst] "+a" (r2), [dlen] "+d" (r3) 374 : [fc] "d" (r0), [pba] "a" (r1), 375 [seed] "a" (r4), [slen] "d" (r5), [opc] "i" (CPACF_PPNO) 376 : "cc", "memory"); | 351{ 352 register unsigned long r0 asm("0") = (unsigned long) func; 353 register unsigned long r1 asm("1") = (unsigned long) param; 354 register unsigned long r2 asm("2") = (unsigned long) dest; 355 register unsigned long r3 asm("3") = (unsigned long) dest_len; 356 register unsigned long r4 asm("4") = (unsigned long) seed; 357 register unsigned long r5 asm("5") = (unsigned long) seed_len; 358 359 asm volatile ( 360 "0: .insn rre,%[opc] << 16,%[dst],%[seed]\n" 361 " brc 1,0b\n" /* handle partial completion */ 362 : [dst] "+a" (r2), [dlen] "+d" (r3) 363 : [fc] "d" (r0), [pba] "a" (r1), 364 [seed] "a" (r4), [slen] "d" (r5), [opc] "i" (CPACF_PPNO) 365 : "cc", "memory"); |
377 378 return dest_len - r3; | |
379} 380 381/** 382 * cpacf_pcc() - executes the PCC (PERFORM CRYPTOGRAPHIC COMPUTATION) 383 * instruction 384 * @func: the function code passed to PCC; see CPACF_KM_xxx defines 385 * @param: address of parameter block; see POP for details on each func | 366} 367 368/** 369 * cpacf_pcc() - executes the PCC (PERFORM CRYPTOGRAPHIC COMPUTATION) 370 * instruction 371 * @func: the function code passed to PCC; see CPACF_KM_xxx defines 372 * @param: address of parameter block; see POP for details on each func |
386 * 387 * Returns 0. | |
388 */ | 373 */ |
389static inline int cpacf_pcc(unsigned long func, void *param) | 374static inline void cpacf_pcc(unsigned long func, void *param) |
390{ 391 register unsigned long r0 asm("0") = (unsigned long) func; 392 register unsigned long r1 asm("1") = (unsigned long) param; 393 394 asm volatile( 395 "0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */ 396 " brc 1,0b\n" /* handle partial completion */ 397 : 398 : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_PCC) 399 : "cc", "memory"); | 375{ 376 register unsigned long r0 asm("0") = (unsigned long) func; 377 register unsigned long r1 asm("1") = (unsigned long) param; 378 379 asm volatile( 380 "0: .insn rre,%[opc] << 16,0,0\n" /* PCC opcode */ 381 " brc 1,0b\n" /* handle partial completion */ 382 : 383 : [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (CPACF_PCC) 384 : "cc", "memory"); |
400 401 return 0; | |
402} 403 404#endif /* _ASM_S390_CPACF_H */ | 385} 386 387#endif /* _ASM_S390_CPACF_H */ |