Skip to content

Commit

Permalink
[cryptolib, test] Remove duplicate digest size references.
Browse files Browse the repository at this point in the history
Previously, digest_len parameters were defined in individual
tests. These are now exposed through hash.h.

OTBN-based sha2 references/headers are also removed, as
necessary parameters are now exposed through hash.h.

Signed-off-by: Fatih Balli <[email protected]>
  • Loading branch information
ballifatih committed May 30, 2024
1 parent 3d5d2bf commit cb16622
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 42 deletions.
4 changes: 0 additions & 4 deletions sw/device/lib/crypto/impl/rsa/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ cc_library(
"//sw/device/lib/crypto/drivers:kmac",
"//sw/device/lib/crypto/impl:hash",
"//sw/device/lib/crypto/impl:status",
"//sw/device/lib/crypto/impl/sha2:sha256",
"//sw/device/lib/crypto/impl/sha2:sha512",
],
)

Expand All @@ -87,8 +85,6 @@ cc_library(
"//sw/device/lib/base:memory",
"//sw/device/lib/crypto/drivers:entropy",
"//sw/device/lib/crypto/impl:hash",
"//sw/device/lib/crypto/impl/sha2:sha256",
"//sw/device/lib/crypto/impl/sha2:sha512",
],
)

Expand Down
2 changes: 0 additions & 2 deletions sw/device/lib/crypto/impl/rsa/rsa_encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "sw/device/lib/crypto/drivers/entropy.h"
#include "sw/device/lib/crypto/impl/rsa/rsa_modexp.h"
#include "sw/device/lib/crypto/impl/rsa/rsa_padding.h"
#include "sw/device/lib/crypto/impl/sha2/sha256.h"
#include "sw/device/lib/crypto/impl/sha2/sha512.h"
#include "sw/device/lib/crypto/include/hash.h"

// Module ID for status codes.
Expand Down
2 changes: 0 additions & 2 deletions sw/device/lib/crypto/impl/rsa/rsa_padding.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "sw/device/lib/base/math.h"
#include "sw/device/lib/crypto/drivers/entropy.h"
#include "sw/device/lib/crypto/drivers/kmac.h"
#include "sw/device/lib/crypto/impl/sha2/sha256.h"
#include "sw/device/lib/crypto/impl/sha2/sha512.h"
#include "sw/device/lib/crypto/include/hash.h"

// Module ID for status codes.
Expand Down
2 changes: 0 additions & 2 deletions sw/device/lib/crypto/impl/rsa/rsa_signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "sw/device/lib/crypto/drivers/entropy.h"
#include "sw/device/lib/crypto/impl/rsa/rsa_modexp.h"
#include "sw/device/lib/crypto/impl/rsa/rsa_padding.h"
#include "sw/device/lib/crypto/impl/sha2/sha256.h"
#include "sw/device/lib/crypto/impl/sha2/sha512.h"
#include "sw/device/lib/crypto/include/hash.h"

// Module ID for status codes.
Expand Down
3 changes: 1 addition & 2 deletions sw/device/silicon_creator/manuf/lib/individualize_sw_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "sw/device/silicon_creator/manuf/lib/individualize_sw_cfg.h"

#include "sw/device/lib/base/macros.h"
#include "sw/device/lib/crypto/impl/sha2/sha256.h"
#include "sw/device/lib/crypto/include/datatypes.h"
#include "sw/device/lib/dif/dif_flash_ctrl.h"
#include "sw/device/lib/dif/dif_otp_ctrl.h"
Expand Down Expand Up @@ -96,7 +95,7 @@ OT_WARN_UNUSED_RESULT
static status_t lock_otp_partition(const dif_otp_ctrl_t *otp_ctrl,
dif_otp_ctrl_partition_t partition) {
// Compute SHA256 of the OTP partition.
uint32_t digest[kSha256DigestWords];
uint32_t digest[kHmacDigestNumWords];
otcrypto_word32_buf_t otp_partition_digest = {
.len = ARRAYSIZE(digest),
.data = digest,
Expand Down
1 change: 0 additions & 1 deletion sw/device/silicon_creator/manuf/lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <stdint.h>

#include "sw/device/lib/base/status.h"
#include "sw/device/lib/crypto/impl/sha2/sha256.h"
#include "sw/device/lib/crypto/include/datatypes.h"
#include "sw/device/lib/crypto/include/hash.h"
#include "sw/device/lib/dif/dif_otp_ctrl.h"
Expand Down
2 changes: 0 additions & 2 deletions sw/device/tests/crypto/cryptotest/firmware/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ cc_library(
"//sw/device/lib/crypto/impl:hash",
"//sw/device/lib/crypto/impl:integrity",
"//sw/device/lib/crypto/impl:keyblob",
"//sw/device/lib/crypto/impl/sha2:sha256",
"//sw/device/lib/crypto/impl/sha2:sha512",
"//sw/device/lib/crypto/include:datatypes",
"//sw/device/lib/runtime:log",
"//sw/device/lib/testing/test_framework:ujson_ottf",
Expand Down
2 changes: 0 additions & 2 deletions sw/device/tests/crypto/cryptotest/firmware/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "sw/device/lib/crypto/drivers/kmac.h"
#include "sw/device/lib/crypto/impl/integrity.h"
#include "sw/device/lib/crypto/impl/keyblob.h"
#include "sw/device/lib/crypto/impl/sha2/sha256.h"
#include "sw/device/lib/crypto/impl/sha2/sha512.h"
#include "sw/device/lib/crypto/include/datatypes.h"
#include "sw/device/lib/runtime/log.h"
#include "sw/device/lib/testing/test_framework/ujson_ottf.h"
Expand Down
2 changes: 0 additions & 2 deletions sw/device/tests/crypto/ecdsa_p256_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "sw/device/lib/testing/test_framework/ottf_main.h"

enum {
/* Number of 32-bit words in a SHA256 digest. */
kSha256DigestWords = 256 / 32,
/* Number of 32-bit words in a P-256 public key. */
kP256PublicKeyWords = 512 / 32,
/* Number of 32-bit words in a P-256 signature. */
Expand Down
2 changes: 0 additions & 2 deletions sw/device/tests/crypto/ecdsa_p256_sideload_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
/* Number of 32-bit words in a SHA256 digest. */
kSha256DigestWords = 256 / 32,
/* Number of 32-bit words in a P-256 public key. */
kP256PublicKeyWords = 512 / 32,
/* Number of 32-bit words in a P-256 signature. */
Expand Down
2 changes: 0 additions & 2 deletions sw/device/tests/crypto/ecdsa_p384_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "sw/device/lib/testing/test_framework/ottf_main.h"

enum {
/* Number of 32-bit words in a SHA384 digest. */
kSha384DigestWords = 384 / 32,
/* Number of 32-bit words in a P-384 public key. */
kP384PublicKeyWords = 768 / 32,
/* Number of 32-bit words in a P-384 signature. */
Expand Down
1 change: 0 additions & 1 deletion sw/device/tests/crypto/rsa_2048_encryption_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
kSha256DigestWords = 256 / 32,
kRsa2048NumBytes = 2048 / 8,
kRsa2048NumWords = kRsa2048NumBytes / sizeof(uint32_t),
};
Expand Down
5 changes: 0 additions & 5 deletions sw/device/tests/crypto/rsa_2048_keygen_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
// Module for status messages.
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
/* Number of words for a SHA-256 digest. */
kSha256DigestWords = 256 / 32,
};

// Message data for testing.
static const unsigned char kTestMessage[] = "Test message.";
static const size_t kTestMessageLen = sizeof(kTestMessage) - 1;
Expand Down
1 change: 0 additions & 1 deletion sw/device/tests/crypto/rsa_2048_signature_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
kSha256DigestWords = 256 / 32,
kRsa2048NumBytes = 2048 / 8,
kRsa2048NumWords = kRsa2048NumBytes / sizeof(uint32_t),
};
Expand Down
5 changes: 0 additions & 5 deletions sw/device/tests/crypto/rsa_3072_keygen_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
// Module for status messages.
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
/* Number of words for a SHA-512 digest. */
kSha512DigestWords = 512 / 32,
};

// Message data for testing.
static const unsigned char kTestMessage[] = "Test message.";
static const size_t kTestMessageLen = sizeof(kTestMessage) - 1;
Expand Down
1 change: 0 additions & 1 deletion sw/device/tests/crypto/rsa_3072_signature_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
kSha512DigestWords = 512 / 32,
kRsa3072NumBytes = 3072 / 8,
kRsa3072NumWords = kRsa3072NumBytes / sizeof(uint32_t),
};
Expand Down
5 changes: 0 additions & 5 deletions sw/device/tests/crypto/rsa_4096_keygen_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
// Module for status messages.
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
/* Number of words for a SHA-512 digest. */
kSha512DigestWords = 512 / 32,
};

// Message data for testing.
static const unsigned char kTestMessage[] = "Test message.";
static const size_t kTestMessageLen = sizeof(kTestMessage) - 1;
Expand Down
1 change: 0 additions & 1 deletion sw/device/tests/crypto/rsa_4096_signature_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

enum {
kSha512DigestWords = 512 / 32,
kRsa4096NumBytes = 4096 / 8,
kRsa4096NumWords = kRsa4096NumBytes / sizeof(uint32_t),
};
Expand Down

0 comments on commit cb16622

Please sign in to comment.