Skip to content

Commit 97b2a6b

Browse files
committed
[Review OP-TEE#3] core: driver: generic resources for crypto device driver
Fix comment typo. Signed-off-by: Clement Faure <clement.faure@nxp.com>
1 parent c07aded commit 97b2a6b

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

core/crypto/crypto.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TEE_Result crypto_hash_alloc_ctx(void **ctx, uint32_t algo)
1919
struct crypto_hash_ctx *c = NULL;
2020

2121
/*
22-
* Use default cryptographic implement if no matching
22+
* Use default cryptographic implementation if no matching
2323
* drvcrypt device.
2424
*/
2525
res = drvcrypt_hash_alloc_ctx(&c, algo);

core/drivers/crypto/crypto_api/cipher/cipher.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static struct crypto_cipher *to_cipher_ctx(struct crypto_cipher_ctx *ctx)
2929
}
3030

3131
/*
32-
* Free the Software Cipher Context function of the algorithm
32+
* Free cipher context
3333
*
3434
* @ctx Reference the API context pointer
3535
*/
@@ -44,7 +44,7 @@ static void cipher_free_ctx(struct crypto_cipher_ctx *ctx)
4444
}
4545

4646
/*
47-
* Copy Software Cipher Context
47+
* Copy cipher context
4848
*
4949
* @dst_ctx [out] Reference the API context pointer destination
5050
* @src_ctx Reference the API context pointer source
@@ -60,7 +60,7 @@ static void cipher_copy_state(struct crypto_cipher_ctx *dst_ctx,
6060
}
6161

6262
/*
63-
* Initialization of the Cipher operation
63+
* Initialization of the cipher operation
6464
*
6565
* @ctx Reference the API context pointer
6666
* @mode Operation mode
@@ -98,6 +98,7 @@ static TEE_Result cipher_init(struct crypto_cipher_ctx *ctx,
9898
dinit.key2.length = key2_len;
9999
dinit.iv.data = (uint8_t *)iv;
100100
dinit.iv.length = iv_len;
101+
101102
ret = cipher->op->init(&dinit);
102103
}
103104

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

108109
/*
109-
* Update of the Cipher operation
110+
* Update of the cipher operation
110111
*
111112
* @ctx Reference the API context pointer
112113
* @last_block True if last block to handle
@@ -148,7 +149,7 @@ static TEE_Result cipher_update(struct crypto_cipher_ctx *ctx, bool last_block,
148149
}
149150

150151
/*
151-
* Finalize the Cipher operation
152+
* Finalize the cipher operation
152153
*
153154
* @ctx Reference the API context pointer
154155
*/
@@ -188,7 +189,6 @@ TEE_Result drvcrypt_cipher_alloc_ctx(struct crypto_cipher_ctx **ctx,
188189

189190
if (ret != TEE_SUCCESS) {
190191
free(cipher);
191-
*ctx = NULL;
192192
} else {
193193
cipher->cipher_ctx.ops = &cipher_ops;
194194
*ctx = &cipher->cipher_ctx;

core/drivers/crypto/crypto_api/include/drvcrypt_cipher.h

+18-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Copyright 2018-2020 NXP
44
*
5-
* Cipher interface calling the HW crypto driver.
5+
* Cipher interface calling the crypto driver.
66
*/
77
#ifndef __DRVCRYPT_CIPHER_H__
88
#define __DRVCRYPT_CIPHER_H__
@@ -11,59 +11,58 @@
1111
#include <tee_api_types.h>
1212

1313
/*
14-
* Format the CIPHER context to keep the reference to the
15-
* operation driver
14+
* Cipher operation context
1615
*/
1716
struct crypto_cipher {
18-
struct crypto_cipher_ctx cipher_ctx; /* Crypto Cipher API context */
19-
void *ctx; /* Cipher Context */
17+
struct crypto_cipher_ctx cipher_ctx; /* Crypto cipher API context */
18+
void *ctx; /* Cipher context */
2019
struct drvcrypt_cipher *op; /* Reference to the operation */
2120
};
2221

2322
/*
24-
* Cipher Algorithm initialization data
23+
* Cipher algorithm initialization data
2524
*/
2625
struct drvcrypt_cipher_init {
27-
void *ctx; /* Software Context */
26+
void *ctx; /* Software context */
2827
bool encrypt; /* Encrypt or decrypt direction */
29-
struct drvcrypt_buf key1; /* First Key */
30-
struct drvcrypt_buf key2; /* Second Key */
31-
struct drvcrypt_buf iv; /* Initial Vector */
28+
struct drvcrypt_buf key1; /* First key */
29+
struct drvcrypt_buf key2; /* Second key */
30+
struct drvcrypt_buf iv; /* Initial vector */
3231
};
3332

3433
/*
35-
* Cipher Algorithm update data
34+
* Cipher algorithm update data
3635
*/
3736
struct drvcrypt_cipher_update {
38-
void *ctx; /* Software Context */
37+
void *ctx; /* Software context */
3938
bool encrypt; /* Encrypt or decrypt direction */
4039
bool last; /* Last block to handle */
41-
struct drvcrypt_buf src; /* Buffer source (Message or Cipher) */
42-
struct drvcrypt_buf dst; /* Buffer dest (Message or Cipher) */
40+
struct drvcrypt_buf src; /* Buffer source (message or cipher) */
41+
struct drvcrypt_buf dst; /* Buffer dest (message or cipher) */
4342
};
4443

4544
/*
46-
* Crypto Library Cipher driver operations
45+
* Crypto library cipher driver operations
4746
*/
4847
struct drvcrypt_cipher {
49-
/* Allocate of the Software context */
48+
/* Allocate context */
5049
TEE_Result (*alloc_ctx)(void **ctx, uint32_t algo);
51-
/* Free of the Software context */
50+
/* Free context */
5251
void (*free_ctx)(void *ctx);
5352
/* Initialize the cipher operation */
5453
TEE_Result (*init)(struct drvcrypt_cipher_init *dinit);
5554
/* Update the cipher operation */
5655
TEE_Result (*update)(struct drvcrypt_cipher_update *dupdate);
5756
/* Finalize the cipher operation */
5857
void (*final)(void *ctx);
59-
/* Copy Cipher context */
58+
/* Copy cipher context */
6059
void (*copy_state)(void *dst_ctx, void *src_ctx);
6160
};
6261

6362
/*
6463
* Register a cipher processing driver in the crypto API
6564
*
66-
* @ops - Driver operations in the HW layer
65+
* @ops - Driver operations
6766
*/
6867
static inline TEE_Result drvcrypt_register_cipher(struct drvcrypt_cipher *ops)
6968
{

core/include/crypto/crypto_impl.h

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ drvcrypt_hash_alloc_ctx(struct crypto_hash_ctx **ctx __unused,
273273
return TEE_ERROR_NOT_IMPLEMENTED;
274274
}
275275
#endif /* CFG_CRYPTO_DRV_HASH */
276+
276277
#ifdef CFG_CRYPTO_DRV_CIPHER
277278
TEE_Result drvcrypt_cipher_alloc_ctx(struct crypto_cipher_ctx **ctx,
278279
uint32_t algo);

0 commit comments

Comments
 (0)