/* * Upon completion, desc points to a buffer containing a CAAM job * descriptor which encapsulates data into an externally-storable * blob.
*/
complete(&res->completion);
}
int caam_process_blob(struct caam_blob_priv *priv, struct caam_blob_info *info, bool encap)
{ conststruct caam_drv_private *ctrlpriv; struct caam_blob_job_result testres; struct device *jrdev = &priv->jrdev;
dma_addr_t dma_in, dma_out; int op = OP_PCLID_BLOB;
size_t output_len;
u32 *desc;
u32 moo; int ret;
if (info->key_mod_len > CAAM_BLOB_KEYMOD_LENGTH) return -EINVAL;
if (encap) {
op |= OP_TYPE_ENCAP_PROTOCOL;
output_len = info->input_len + CAAM_BLOB_OVERHEAD;
} else {
op |= OP_TYPE_DECAP_PROTOCOL;
output_len = info->input_len - CAAM_BLOB_OVERHEAD;
}
desc = kzalloc(CAAM_BLOB_DESC_BYTES_MAX, GFP_KERNEL); if (!desc) return -ENOMEM;
dma_in = dma_map_single(jrdev, info->input, info->input_len,
DMA_TO_DEVICE); if (dma_mapping_error(jrdev, dma_in)) {
dev_err(jrdev, "unable to map input DMA buffer\n");
ret = -ENOMEM; goto out_free;
}
dma_out = dma_map_single(jrdev, info->output, output_len,
DMA_FROM_DEVICE); if (dma_mapping_error(jrdev, dma_out)) {
dev_err(jrdev, "unable to map output DMA buffer\n");
ret = -ENOMEM; goto out_unmap_in;
}
ctrlpriv = dev_get_drvdata(jrdev->parent);
moo = FIELD_GET(CSTA_MOO, rd_reg32(&ctrlpriv->jr[0]->perfmon.status)); if (moo != CSTA_MOO_SECURE && moo != CSTA_MOO_TRUSTED)
dev_warn(jrdev, "using insecure test key, enable HAB to use unique device key!\n");
/* * A data blob is encrypted using a blob key (BK); a random number. * The BK is used as an AES-CCM key. The initial block (B0) and the * initial counter (Ctr0) are generated automatically and stored in * Class 1 Context DWords 0+1+2+3. The random BK is stored in the * Class 1 Key Register. Operation Mode is set to AES-CCM.
*/
/* * caam_blob_gen_init() may expectedly fail with -ENODEV, e.g. when * CAAM driver didn't probe or when SoC lacks BLOB support. An * error would be harsh in this case, so we stick to info level.
*/
jrdev = caam_jr_alloc(); if (IS_ERR(jrdev)) {
pr_info("job ring requested, but none currently available\n"); return ERR_PTR(-ENODEV);
}
ctrlpriv = dev_get_drvdata(jrdev->parent); if (!ctrlpriv->blob_present) {
dev_info(jrdev, "no hardware blob generation support\n");
caam_jr_free(jrdev); return ERR_PTR(-ENODEV);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.