Ruchika Gupta | 4345a57 | 2014-10-07 15:46:20 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <malloc.h> |
| 10 | #include "jobdesc.h" |
| 11 | #include "desc.h" |
| 12 | #include "jr.h" |
| 13 | |
gaurav rana | b64308e | 2015-02-25 09:37:09 +0530 | [diff] [blame^] | 14 | int blob_decap(u8 *key_mod, u8 *src, u8 *dst, u32 len) |
Ruchika Gupta | 4345a57 | 2014-10-07 15:46:20 +0530 | [diff] [blame] | 15 | { |
| 16 | int ret, i = 0; |
| 17 | u32 *desc; |
| 18 | |
| 19 | printf("\nDecapsulating data to form blob\n"); |
| 20 | desc = malloc(sizeof(int) * MAX_CAAM_DESCSIZE); |
| 21 | if (!desc) { |
| 22 | debug("Not enough memory for descriptor allocation\n"); |
| 23 | return -1; |
| 24 | } |
| 25 | |
| 26 | inline_cnstr_jobdesc_blob_decap(desc, key_mod, src, dst, len); |
| 27 | |
| 28 | for (i = 0; i < 14; i++) |
| 29 | printf("%x\n", *(desc + i)); |
| 30 | ret = run_descriptor_jr(desc); |
| 31 | |
| 32 | if (ret) |
| 33 | printf("Error in Decapsulation %d\n", ret); |
| 34 | |
| 35 | free(desc); |
| 36 | return ret; |
| 37 | } |
| 38 | |
gaurav rana | b64308e | 2015-02-25 09:37:09 +0530 | [diff] [blame^] | 39 | int blob_encap(u8 *key_mod, u8 *src, u8 *dst, u32 len) |
Ruchika Gupta | 4345a57 | 2014-10-07 15:46:20 +0530 | [diff] [blame] | 40 | { |
| 41 | int ret, i = 0; |
| 42 | u32 *desc; |
| 43 | |
| 44 | printf("\nEncapsulating data to form blob\n"); |
| 45 | desc = malloc(sizeof(int) * MAX_CAAM_DESCSIZE); |
| 46 | if (!desc) { |
| 47 | debug("Not enough memory for descriptor allocation\n"); |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | inline_cnstr_jobdesc_blob_encap(desc, key_mod, src, dst, len); |
| 52 | for (i = 0; i < 14; i++) |
| 53 | printf("%x\n", *(desc + i)); |
| 54 | ret = run_descriptor_jr(desc); |
| 55 | |
| 56 | if (ret) |
| 57 | printf("Error in Encapsulation %d\n", ret); |
| 58 | |
| 59 | free(desc); |
| 60 | return ret; |
| 61 | } |