Skip to content

Commit b86bb73

Browse files
Vge0rgerlubos
authored andcommitted
nrf_security: Remove Cracen unused hash funcs/macros
Remove unused macros and functions. The functions sx_hash_create_(algorithm) are not used by the PSA driver, only the sx_hash_create_(engine) are used. Also the macros SX_HASH_BLOCKSZ_MAX and SX_HASH_DIGESTSZ_MAX are also unused so remove them as well. Signed-off-by: Georgios Vasilakis <[email protected]>
1 parent 9ccb5c6 commit b86bb73

File tree

6 files changed

+0
-289
lines changed

6 files changed

+0
-289
lines changed

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/include/sxsymcrypt/sha1.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,6 @@ struct sxhash;
2121
#define SX_HASH_DIGESTSZ_SHA1 20
2222
#define SX_HASH_BLOCKSZ_SHA1 64
2323

24-
25-
#if SX_HASH_DIGESTSZ_MAX < SX_HASH_DIGESTSZ_SHA1
26-
#undef SX_HASH_DIGESTSZ_MAX
27-
#define SX_HASH_DIGESTSZ_MAX SX_HASH_DIGESTSZ_SHA1
28-
#endif
29-
30-
31-
#if SX_HASH_BLOCKSZ_MAX < SX_HASH_BLOCKSZ_SHA1
32-
#undef SX_HASH_BLOCKSZ_MAX
33-
#define SX_HASH_BLOCKSZ_MAX SX_HASH_BLOCKSZ_SHA1
34-
#endif
35-
3624
/** Hash algorithm SHA-1 (Secure Hash Algorithm 1)
3725
*
3826
* Deprecated algorithm. NIST formally deprecated use of SHA-1 in 2011
@@ -41,24 +29,6 @@ struct sxhash;
4129
*/
4230
extern const struct sxhashalg sxhashalg_sha1;
4331

44-
/** Prepares a SHA1 hash operation context
45-
*
46-
* This function initializes the user allocated object \p c with a new hash
47-
* operation context and reserves the HW resource.
48-
*
49-
* After successful execution of this function, the context \p c can be passed
50-
* to any of the hashing functions.
51-
*
52-
* @param[out] c hash operation context
53-
* @param[in] csz size of the hash operation context
54-
* @return ::SX_OK
55-
* @return ::SX_ERR_INCOMPATIBLE_HW
56-
* @return ::SX_ERR_RETRY
57-
*
58-
* @remark - SHA1 digest size is 20 bytes
59-
*/
60-
int sx_hash_create_sha1(struct sxhash *c, size_t csz);
61-
6232
#ifdef __cplusplus
6333
}
6434
#endif

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/include/sxsymcrypt/sha2.h

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ struct sxhash;
2727
#define SX_HASH_BLOCKSZ_SHA2_384 128
2828
#define SX_HASH_BLOCKSZ_SHA2_512 128
2929

30-
#if SX_HASH_DIGESTSZ_MAX < SX_HASH_DIGESTSZ_SHA2_512
31-
#undef SX_HASH_DIGESTSZ_MAX
32-
#define SX_HASH_DIGESTSZ_MAX SX_HASH_DIGESTSZ_SHA2_512
33-
#endif
34-
35-
#if SX_HASH_BLOCKSZ_MAX < SX_HASH_BLOCKSZ_SHA2_512
36-
#undef SX_HASH_BLOCKSZ_MAX
37-
#define SX_HASH_BLOCKSZ_MAX SX_HASH_BLOCKSZ_SHA2_512
38-
#endif
39-
4030
/** Hash algorithm SHA-2 224
4131
*
4232
* Has only 32 bit capacity against length extension attacks.
@@ -61,79 +51,6 @@ extern const struct sxhashalg sxhashalg_sha2_384;
6151
*/
6252
extern const struct sxhashalg sxhashalg_sha2_512;
6353

64-
/** Prepares a SHA256 hash operation context
65-
*
66-
* This function initializes the user allocated object \p c with a new hash
67-
* operation context and reserves the HW resource.
68-
*
69-
* After successful execution of this function, the context \p c can be passed
70-
* to any of the hashing functions.
71-
*
72-
* @param[out] c hash operation context
73-
* @param[in] csz size of the hash operation context
74-
* @return ::SX_OK
75-
* @return ::SX_ERR_INCOMPATIBLE_HW
76-
* @return ::SX_ERR_RETRY
77-
*
78-
* @remark - SHA256 digest size is 32 bytes
79-
*/
80-
int sx_hash_create_sha256(struct sxhash *c, size_t csz);
81-
82-
/** Prepares a SHA384 hash operation context
83-
*
84-
* This function initializes the user allocated object \p c with a new hash
85-
* operation context and reserves the HW resource.
86-
*
87-
* After successful execution of this function, the context \p c can be passed
88-
* to any of the hashing functions.
89-
*
90-
* @param[out] c hash operation context
91-
* @param[in] csz size of the hash operation context
92-
* @return ::SX_OK
93-
* @return ::SX_ERR_INCOMPATIBLE_HW
94-
* @return ::SX_ERR_RETRY
95-
*
96-
* @remark - SHA384 digest size is 48 bytes
97-
*/
98-
int sx_hash_create_sha384(struct sxhash *c, size_t csz);
99-
100-
/** Prepares a SHA512 hash operation context
101-
*
102-
* This function initializes the user allocated object \p c with a new hash
103-
* operation context and reserves the HW resource.
104-
*
105-
* After successful execution of this function, the context \p c can be passed
106-
* to any of the hashing
107-
* functions.
108-
*
109-
* @param[out] c hash operation context
110-
* @param[in] csz size of the hash operation context
111-
* @return ::SX_OK
112-
* @return ::SX_ERR_INCOMPATIBLE_HW
113-
* @return ::SX_ERR_RETRY
114-
*
115-
* @remark - SHA512 digest size is 64 bytes
116-
*/
117-
int sx_hash_create_sha512(struct sxhash *c, size_t csz);
118-
119-
/** Prepares a SHA224 hash operation context
120-
*
121-
* This function initializes the user allocated object \p c with a new hash
122-
* operation context and reserves the HW resource.
123-
*
124-
* After successful execution of this function, the context \p c can be passed
125-
* to any of the hashing functions.
126-
*
127-
* @param[out] c hash operation context
128-
* @param[in] csz size of the hash operation context
129-
* @return ::SX_OK
130-
* @return ::SX_ERR_INCOMPATIBLE_HW
131-
* @return ::SX_ERR_RETRY
132-
*
133-
* @remark - SHA224 digest size is 28 bytes
134-
*/
135-
int sx_hash_create_sha224(struct sxhash *c, size_t csz);
136-
13754
#ifdef __cplusplus
13855
}
13956
#endif

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/include/sxsymcrypt/sha3.h

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ struct sxhash;
2727
#define SX_HASH_BLOCKSZ_SHA3_384 104
2828
#define SX_HASH_BLOCKSZ_SHA3_512 72
2929

30-
31-
#if SX_HASH_DIGESTSZ_MAX < SX_HASH_DIGESTSZ_SHA3_512
32-
#undef SX_HASH_DIGESTSZ_MAX
33-
#define SX_HASH_DIGESTSZ_MAX SX_HASH_DIGESTSZ_SHA3_512
34-
#endif
35-
36-
37-
#if SX_HASH_BLOCKSZ_MAX < SX_HASH_BLOCKSZ_SHA3_224
38-
#undef SX_HASH_BLOCKSZ_MAX
39-
#define SX_HASH_BLOCKSZ_MAX SX_HASH_BLOCKSZ_SHA3_224
40-
#endif
41-
4230
/** Hash algorithm SHA-3 224 */
4331
extern const struct sxhashalg sxhashalg_sha3_224;
4432

@@ -54,74 +42,6 @@ extern const struct sxhashalg sxhashalg_sha3_512;
5442
/** Hash algorithm SHAKE256, with output size fixed to 114 bytes (for Ed448). */
5543
extern const struct sxhashalg sxhashalg_shake256_114;
5644

57-
/** Creates a SHA3-224 hash operation context
58-
*
59-
* This function initializes the user allocated object \p c with a new hash
60-
* operation context and reserves the HW resource. After successful execution
61-
* of this function, the context \p c can be passed to any of the hashing
62-
* functions.
63-
*
64-
* @param[out] c hash operation context
65-
* @param[in] csz size of the hash operation context
66-
* @return ::SX_OK
67-
* @return ::SX_ERR_INCOMPATIBLE_HW
68-
* @return ::SX_ERR_RETRY
69-
*
70-
* @remark - SHA3-224 digest size is 28 bytes
71-
*/
72-
int sx_hash_create_sha3_224(struct sxhash *c, size_t csz);
73-
74-
/** Creates a SHA3-256 hash operation context
75-
*
76-
* This function initializes the user allocated object \p c with a new hash
77-
* operation context and reserves the HW resource. After successful execution
78-
* of this function, the context \p c can be passed to any of the hashing
79-
* functions.
80-
*
81-
* @param[out] c hash operation context
82-
* @param[in] csz size of the hash operation context
83-
* @return ::SX_OK
84-
* @return ::SX_ERR_INCOMPATIBLE_HW
85-
* @return ::SX_ERR_RETRY
86-
*
87-
* @remark - SHA3-256 digest size is 32 bytes
88-
*/
89-
int sx_hash_create_sha3_256(struct sxhash *c, size_t csz);
90-
91-
/** Creates a SHA3-384 hash operation context
92-
*
93-
* This function initializes the user allocated object \p c with a new hash
94-
* operation context and reserves the HW resource. After successful execution
95-
* of this function, the context \p c can be passed to any of the hashing
96-
* functions.
97-
*
98-
* @param[out] c hash operation context
99-
* @param[in] csz size of the hash operation context
100-
* @return ::SX_OK
101-
* @return ::SX_ERR_INCOMPATIBLE_HW
102-
* @return ::SX_ERR_RETRY
103-
*
104-
* @remark - SHA3-384 digest size is 48 bytes
105-
*/
106-
int sx_hash_create_sha3_384(struct sxhash *c, size_t csz);
107-
108-
/** Creates a SHA3-512 hash operation context
109-
*
110-
* This function initializes the user allocated object \p c with a new hash
111-
* operation context and reserves the HW resource. After successful execution
112-
* of this function, the context \p c can be passed to any of the hashing
113-
* functions.
114-
*
115-
* @param[out] c hash operation context
116-
* @param[in] csz size of the hash operation context
117-
* @return ::SX_OK
118-
* @return ::SX_ERR_INCOMPATIBLE_HW
119-
* @return ::SX_ERR_RETRY
120-
*
121-
* @remark - SHA3-512 digest size is 64 bytes
122-
*/
123-
int sx_hash_create_sha3_512(struct sxhash *c, size_t csz);
124-
12545
#ifdef __cplusplus
12646
}
12747
#endif

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/include/sxsymcrypt/sm3.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,9 @@ struct sxhash;
2121
#define SX_HASH_DIGESTSZ_SM3 32
2222
#define SX_HASH_BLOCKSZ_SM3 64
2323

24-
25-
#if SX_HASH_DIGESTSZ_MAX < SX_HASH_DIGESTSZ_SM3
26-
#undef SX_HASH_DIGESTSZ_MAX
27-
#define SX_HASH_DIGESTSZ_MAX SX_HASH_DIGESTSZ_SM3
28-
#endif
29-
30-
31-
#if SX_HASH_BLOCKSZ_MAX < SX_HASH_BLOCKSZ_SM3
32-
#undef SX_HASH_BLOCKSZ_MAX
33-
#define SX_HASH_BLOCKSZ_MAX SX_HASH_BLOCKSZ_SM3
34-
#endif
35-
3624
/** GM/T 0004-2012: SM3 cryptographic hash algorithm */
3725
extern const struct sxhashalg sxhashalg_sm3;
3826

39-
/** Prepares a SM3 hash operation context
40-
*
41-
* This function initializes the user allocated object \p c with a new hash
42-
* operation context and reserves the HW resource.
43-
*
44-
* After successful execution of this function, the context \p c can be passed
45-
* to any of the hashing functions.
46-
*
47-
* @param[out] c hash operation context
48-
* @param[in] csz size of the hash operation context
49-
* @return ::SX_OK
50-
* @return ::SX_ERR_INCOMPATIBLE_HW
51-
* @return ::SX_ERR_RETRY
52-
*
53-
* @remark - SM3 digest size is 32 bytes
54-
*/
55-
int sx_hash_create_sm3(struct sxhash *c, size_t csz);
56-
5727
#ifdef __cplusplus
5828
}
5929
#endif

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/src/hash.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -135,48 +135,6 @@ static int sx_hash_create_ba413(struct sxhash *c, size_t csz)
135135
return SX_OK;
136136
}
137137

138-
int sx_hash_create_sha256(struct sxhash *c, size_t csz)
139-
{
140-
c->algo = &sxhashalg_sha2_256;
141-
142-
return sx_hash_create_ba413(c, csz);
143-
}
144-
145-
int sx_hash_create_sha384(struct sxhash *c, size_t csz)
146-
{
147-
c->algo = &sxhashalg_sha2_384;
148-
149-
return sx_hash_create_ba413(c, csz);
150-
}
151-
152-
int sx_hash_create_sha512(struct sxhash *c, size_t csz)
153-
{
154-
c->algo = &sxhashalg_sha2_512;
155-
156-
return sx_hash_create_ba413(c, csz);
157-
}
158-
159-
int sx_hash_create_sha1(struct sxhash *c, size_t csz)
160-
{
161-
c->algo = &sxhashalg_sha1;
162-
163-
return sx_hash_create_ba413(c, csz);
164-
}
165-
166-
int sx_hash_create_sha224(struct sxhash *c, size_t csz)
167-
{
168-
c->algo = &sxhashalg_sha2_224;
169-
170-
return sx_hash_create_ba413(c, csz);
171-
}
172-
173-
int sx_hash_create_sm3(struct sxhash *c, size_t csz)
174-
{
175-
c->algo = &sxhashalg_sm3;
176-
177-
return sx_hash_create_ba413(c, csz);
178-
}
179-
180138
int sx_hash_create(struct sxhash *c, const struct sxhashalg *alg, size_t csz)
181139
{
182140
c->algo = alg;

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/src/sha3.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -129,45 +129,21 @@ const struct sxhashalg sxhashalg_sha3_224 = {
129129
SX_HASH_BLOCKSZ_SHA3_224, 200, 144, sx_hash_create_ba418
130130
};
131131

132-
int sx_hash_create_sha3_224(struct sxhash *c, size_t csz)
133-
{
134-
c->algo = &sxhashalg_sha3_224;
135-
return sx_hash_create_ba418(c, csz);
136-
}
137-
138132
const struct sxhashalg sxhashalg_sha3_256 = {
139133
SHA3_MODE(7), SHA3_SW_PAD, SHA3_SAVE_CONTEXT, SX_HASH_DIGESTSZ_SHA3_256,
140134
SX_HASH_BLOCKSZ_SHA3_256, 200, 136, sx_hash_create_ba418
141135
};
142136

143-
int sx_hash_create_sha3_256(struct sxhash *c, size_t csz)
144-
{
145-
c->algo = &sxhashalg_sha3_256;
146-
return sx_hash_create_ba418(c, csz);
147-
}
148-
149137
const struct sxhashalg sxhashalg_sha3_384 = {
150138
SHA3_MODE(11), SHA3_SW_PAD, SHA3_SAVE_CONTEXT, SX_HASH_DIGESTSZ_SHA3_384,
151139
SX_HASH_BLOCKSZ_SHA3_384, 200, 104, sx_hash_create_ba418
152140
};
153141

154-
int sx_hash_create_sha3_384(struct sxhash *c, size_t csz)
155-
{
156-
c->algo = &sxhashalg_sha3_384;
157-
return sx_hash_create_ba418(c, csz);
158-
}
159-
160142
const struct sxhashalg sxhashalg_sha3_512 = {
161143
SHA3_MODE(15), SHA3_SW_PAD, SHA3_SAVE_CONTEXT, SX_HASH_DIGESTSZ_SHA3_512,
162144
SX_HASH_BLOCKSZ_SHA3_512, 200, 72, sx_hash_create_ba418
163145
};
164146

165-
int sx_hash_create_sha3_512(struct sxhash *c, size_t csz)
166-
{
167-
c->algo = &sxhashalg_sha3_512;
168-
return sx_hash_create_ba418(c, csz);
169-
}
170-
171147
const struct sxhashalg sxhashalg_shake256_114 = {
172148
SHA3_MODE_SHAKE(7, 114), SHA3_SW_PAD, SHA3_SAVE_CONTEXT, 114,
173149
SX_HASH_BLOCKSZ_SHA3_256, 200, 136, sx_hash_create_ba418_shake256

0 commit comments

Comments
 (0)