return -EINVAL;
}
- printf("\nDecapsulating blob to get data\n");
+ debug("\nDecapsulating blob to get data\n");
desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
if (!desc) {
debug("Not enough memory for descriptor allocation\n");
invalidate_dcache_range((unsigned long)dst,
(unsigned long)dst + size);
- puts("Blob decapsulation successful.\n");
+ debug("Blob decapsulation successful.\n");
}
free(desc);
return -EINVAL;
}
- printf("\nEncapsulating data to form blob\n");
+ debug("\nEncapsulating data to form blob\n");
desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
if (!desc) {
debug("Not enough memory for descriptor allocation\n");
invalidate_dcache_range((unsigned long)dst,
(unsigned long)dst + size);
- puts("Blob encapsulation successful.\n");
+ debug("Blob encapsulation successful.\n");
}
free(desc);
return -EINVAL;
}
- printf("\nBlob key encryption key(bkek)\n");
+ debug("\nBlob key encryption key(bkek)\n");
desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
if (!desc) {
printf("Not enough memory for descriptor allocation\n");
} else {
invalidate_dcache_range((unsigned long)bkek_buf,
(unsigned long)bkek_buf + size);
- puts("derive bkek successful.\n");
+ debug("derive bkek successful.\n");
}
free(desc);
u32 *desc;
if (!IS_ALIGNED((uintptr_t)dst, ARCH_DMA_MINALIGN)) {
- puts("Error: caam_hwrng_test: Address arguments are not aligned!\n");
+ puts("Error: caam_hwrng: Address arguments are not aligned!\n");
return -EINVAL;
}
- printf("\nRNG generate\n");
+ debug("\nRNG generate\n");
desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
if (!desc) {
printf("Not enough memory for descriptor allocation\n");
} else {
invalidate_dcache_range((unsigned long)dst,
(unsigned long)dst + size);
- puts("RNG generation successful.\n");
+ debug("RNG generation successful.\n");
}
free(desc);
int sec_init(void);
u8 caam_get_era(void);
+
+/**
+ * blob_decap() - Decapsulate the data from a blob
+ * @key_mod: - Key modifier address
+ * @src: - Source address (blob)
+ * @dst: - Destination address (data)
+ * @len: - Size of decapsulated data
+ *
+ * Note: Start and end of the key_mod, src and dst buffers have to be aligned to
+ * the cache line size (ARCH_DMA_MINALIGN) for the CAAM operation to succeed.
+ *
+ * Returns zero on success, negative on error.
+ */
+int blob_decap(u8 *key_mod, u8 *src, u8 *dst, u32 len);
+
+/**
+ * blob_encap() - Encapsulate the data as a blob
+ * @key_mod: - Key modifier address
+ * @src: - Source address (data)
+ * @dst: - Destination address (blob)
+ * @len: - Size of data to be encapsulated
+ *
+ * Note: Start and end of the key_mod, src and dst buffers have to be aligned to
+ * the cache line size (ARCH_DMA_MINALIGN) for the CAAM operation to succeed.
+ *
+ * Returns zero on success, negative on error.
+ */
+int blob_encap(u8 *key_mod, u8 *src, u8 *dst, u32 len);
+
+int derive_blob_kek(u8 *bkek_buf, u8 *key_mod, u32 key_sz);
+
+int hwrng_generate(u8 *dst, u32 len);
+
#endif
#endif /* __FSL_SEC_H */