Skip to content

Commit

Permalink
[Review OP-TEE#3] core: driver: generic resources for crypto device d…
Browse files Browse the repository at this point in the history
…river

Fix comment typo.

Signed-off-by: Clement Faure <clement.faure@nxp.com>
  • Loading branch information
clementfaure committed Mar 9, 2020
1 parent c07aded commit 97b2a6b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion core/crypto/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEE_Result crypto_hash_alloc_ctx(void **ctx, uint32_t algo)
struct crypto_hash_ctx *c = NULL;

/*
* Use default cryptographic implement if no matching
* Use default cryptographic implementation if no matching
* drvcrypt device.
*/
res = drvcrypt_hash_alloc_ctx(&c, algo);
Expand Down
12 changes: 6 additions & 6 deletions core/drivers/crypto/crypto_api/cipher/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static struct crypto_cipher *to_cipher_ctx(struct crypto_cipher_ctx *ctx)
}

/*
* Free the Software Cipher Context function of the algorithm
* Free cipher context
*
* @ctx Reference the API context pointer
*/
Expand All @@ -44,7 +44,7 @@ static void cipher_free_ctx(struct crypto_cipher_ctx *ctx)
}

/*
* Copy Software Cipher Context
* Copy cipher context
*
* @dst_ctx [out] Reference the API context pointer destination
* @src_ctx Reference the API context pointer source
Expand All @@ -60,7 +60,7 @@ static void cipher_copy_state(struct crypto_cipher_ctx *dst_ctx,
}

/*
* Initialization of the Cipher operation
* Initialization of the cipher operation
*
* @ctx Reference the API context pointer
* @mode Operation mode
Expand Down Expand Up @@ -98,6 +98,7 @@ static TEE_Result cipher_init(struct crypto_cipher_ctx *ctx,
dinit.key2.length = key2_len;
dinit.iv.data = (uint8_t *)iv;
dinit.iv.length = iv_len;

ret = cipher->op->init(&dinit);
}

Expand All @@ -106,7 +107,7 @@ static TEE_Result cipher_init(struct crypto_cipher_ctx *ctx,
}

/*
* Update of the Cipher operation
* Update of the cipher operation
*
* @ctx Reference the API context pointer
* @last_block True if last block to handle
Expand Down Expand Up @@ -148,7 +149,7 @@ static TEE_Result cipher_update(struct crypto_cipher_ctx *ctx, bool last_block,
}

/*
* Finalize the Cipher operation
* Finalize the cipher operation
*
* @ctx Reference the API context pointer
*/
Expand Down Expand Up @@ -188,7 +189,6 @@ TEE_Result drvcrypt_cipher_alloc_ctx(struct crypto_cipher_ctx **ctx,

if (ret != TEE_SUCCESS) {
free(cipher);
*ctx = NULL;
} else {
cipher->cipher_ctx.ops = &cipher_ops;
*ctx = &cipher->cipher_ctx;
Expand Down
37 changes: 18 additions & 19 deletions core/drivers/crypto/crypto_api/include/drvcrypt_cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Copyright 2018-2020 NXP
*
* Cipher interface calling the HW crypto driver.
* Cipher interface calling the crypto driver.
*/
#ifndef __DRVCRYPT_CIPHER_H__
#define __DRVCRYPT_CIPHER_H__
Expand All @@ -11,59 +11,58 @@
#include <tee_api_types.h>

/*
* Format the CIPHER context to keep the reference to the
* operation driver
* Cipher operation context
*/
struct crypto_cipher {
struct crypto_cipher_ctx cipher_ctx; /* Crypto Cipher API context */
void *ctx; /* Cipher Context */
struct crypto_cipher_ctx cipher_ctx; /* Crypto cipher API context */
void *ctx; /* Cipher context */
struct drvcrypt_cipher *op; /* Reference to the operation */
};

/*
* Cipher Algorithm initialization data
* Cipher algorithm initialization data
*/
struct drvcrypt_cipher_init {
void *ctx; /* Software Context */
void *ctx; /* Software context */
bool encrypt; /* Encrypt or decrypt direction */
struct drvcrypt_buf key1; /* First Key */
struct drvcrypt_buf key2; /* Second Key */
struct drvcrypt_buf iv; /* Initial Vector */
struct drvcrypt_buf key1; /* First key */
struct drvcrypt_buf key2; /* Second key */
struct drvcrypt_buf iv; /* Initial vector */
};

/*
* Cipher Algorithm update data
* Cipher algorithm update data
*/
struct drvcrypt_cipher_update {
void *ctx; /* Software Context */
void *ctx; /* Software context */
bool encrypt; /* Encrypt or decrypt direction */
bool last; /* Last block to handle */
struct drvcrypt_buf src; /* Buffer source (Message or Cipher) */
struct drvcrypt_buf dst; /* Buffer dest (Message or Cipher) */
struct drvcrypt_buf src; /* Buffer source (message or cipher) */
struct drvcrypt_buf dst; /* Buffer dest (message or cipher) */
};

/*
* Crypto Library Cipher driver operations
* Crypto library cipher driver operations
*/
struct drvcrypt_cipher {
/* Allocate of the Software context */
/* Allocate context */
TEE_Result (*alloc_ctx)(void **ctx, uint32_t algo);
/* Free of the Software context */
/* Free context */
void (*free_ctx)(void *ctx);
/* Initialize the cipher operation */
TEE_Result (*init)(struct drvcrypt_cipher_init *dinit);
/* Update the cipher operation */
TEE_Result (*update)(struct drvcrypt_cipher_update *dupdate);
/* Finalize the cipher operation */
void (*final)(void *ctx);
/* Copy Cipher context */
/* Copy cipher context */
void (*copy_state)(void *dst_ctx, void *src_ctx);
};

/*
* Register a cipher processing driver in the crypto API
*
* @ops - Driver operations in the HW layer
* @ops - Driver operations
*/
static inline TEE_Result drvcrypt_register_cipher(struct drvcrypt_cipher *ops)
{
Expand Down
1 change: 1 addition & 0 deletions core/include/crypto/crypto_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ drvcrypt_hash_alloc_ctx(struct crypto_hash_ctx **ctx __unused,
return TEE_ERROR_NOT_IMPLEMENTED;
}
#endif /* CFG_CRYPTO_DRV_HASH */

#ifdef CFG_CRYPTO_DRV_CIPHER
TEE_Result drvcrypt_cipher_alloc_ctx(struct crypto_cipher_ctx **ctx,
uint32_t algo);
Expand Down

0 comments on commit 97b2a6b

Please sign in to comment.