Driver added for RSA Modular Exponentiation using Freescale Hardware Accelerator CAAM. The driver uses UCLASS_MOD_EXP Signed-off-by: Ruchika Gupta <ruchika.gupta@freescale.com> CC: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>master
parent
c937ff6dc2
commit
34276478f7
@ -0,0 +1 @@ |
|||||||
|
source drivers/crypto/fsl/Kconfig |
@ -0,0 +1,6 @@ |
|||||||
|
config FSL_CAAM |
||||||
|
bool "Freescale Crypto Driver Support" |
||||||
|
help |
||||||
|
Enables the Freescale's Cryptographic Accelerator and Assurance |
||||||
|
Module (CAAM), also known as the SEC version 4 (SEC4). The driver uses |
||||||
|
Job Ring as interface to communicate with CAAM. |
@ -0,0 +1,60 @@ |
|||||||
|
/*
|
||||||
|
* (C) Copyright 2014 Freescale Semiconductor, Inc. |
||||||
|
* Author: Ruchika Gupta <ruchika.gupta@freescale.com> |
||||||
|
* |
||||||
|
* SPDX-License-Identifier: GPL-2.0+ |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <config.h> |
||||||
|
#include <common.h> |
||||||
|
#include <dm.h> |
||||||
|
#include <asm/types.h> |
||||||
|
#include <malloc.h> |
||||||
|
#include "jobdesc.h" |
||||||
|
#include "desc.h" |
||||||
|
#include "jr.h" |
||||||
|
#include "rsa_caam.h" |
||||||
|
#include <u-boot/rsa-mod-exp.h> |
||||||
|
|
||||||
|
int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len, |
||||||
|
struct key_prop *prop, uint8_t *out) |
||||||
|
{ |
||||||
|
uint32_t keylen; |
||||||
|
struct pk_in_params pkin; |
||||||
|
uint32_t desc[MAX_CAAM_DESCSIZE]; |
||||||
|
int ret; |
||||||
|
|
||||||
|
/* Length in bytes */ |
||||||
|
keylen = prop->num_bits / 8; |
||||||
|
|
||||||
|
pkin.a = sig; |
||||||
|
pkin.a_siz = sig_len; |
||||||
|
pkin.n = prop->modulus; |
||||||
|
pkin.n_siz = keylen; |
||||||
|
pkin.e = prop->public_exponent; |
||||||
|
pkin.e_siz = prop->exp_len; |
||||||
|
|
||||||
|
inline_cnstr_jobdesc_pkha_rsaexp(desc, &pkin, out, sig_len); |
||||||
|
|
||||||
|
ret = run_descriptor_jr(desc); |
||||||
|
if (ret) { |
||||||
|
debug("%s: RSA failed to verify: %d\n", __func__, ret); |
||||||
|
return -EFAULT; |
||||||
|
} |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
static const struct mod_exp_ops fsl_mod_exp_ops = { |
||||||
|
.mod_exp = fsl_mod_exp, |
||||||
|
}; |
||||||
|
|
||||||
|
U_BOOT_DRIVER(fsl_rsa_mod_exp) = { |
||||||
|
.name = "fsl_rsa_mod_exp", |
||||||
|
.id = UCLASS_MOD_EXP, |
||||||
|
.ops = &fsl_mod_exp_ops, |
||||||
|
}; |
||||||
|
|
||||||
|
U_BOOT_DEVICE(fsl_rsa) = { |
||||||
|
.name = "fsl_rsa_mod_exp", |
||||||
|
}; |
@ -0,0 +1,28 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2014 Freescale Semiconductor, Inc. |
||||||
|
* |
||||||
|
* SPDX-License-Identifier: GPL-2.0+ |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef __RSA_CAAM_H |
||||||
|
#define __RSA_CAAM_H |
||||||
|
|
||||||
|
#include <common.h> |
||||||
|
|
||||||
|
/**
|
||||||
|
* struct pk_in_params - holder for input to PKHA block in CAAM |
||||||
|
* These parameters are required to perform Modular Exponentiation |
||||||
|
* using PKHA Block in CAAM |
||||||
|
*/ |
||||||
|
struct pk_in_params { |
||||||
|
const uint8_t *e; /* public exponent as byte array */ |
||||||
|
uint32_t e_siz; /* size of e[] in number of bytes */ |
||||||
|
const uint8_t *n; /* modulus as byte array */ |
||||||
|
uint32_t n_siz; /* size of n[] in number of bytes */ |
||||||
|
const uint8_t *a; /* Signature as byte array */ |
||||||
|
uint32_t a_siz; /* size of a[] in number of bytes */ |
||||||
|
uint8_t *b; /* Result exp. modulus in number of bytes */ |
||||||
|
uint32_t b_siz; /* size of b[] in number of bytes */ |
||||||
|
}; |
||||||
|
|
||||||
|
#endif |
Loading…
Reference in new issue