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 authored and moidx committed Jun 3, 2024
1 parent dd0b538 commit 15ed2ec
Show file tree
Hide file tree
Showing 20 changed files with 2 additions and 43 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
1 change: 1 addition & 0 deletions sw/device/silicon_creator/manuf/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ cc_library(
"//hw/top_earlgrey/sw/autogen:top_earlgrey",
"//sw/device/lib/base:macros",
"//sw/device/lib/base:status",
"//sw/device/lib/crypto/impl:hash",
"//sw/device/lib/dif:flash_ctrl",
"//sw/device/lib/dif:otp_ctrl",
"//sw/device/lib/testing:flash_ctrl_testutils",
Expand Down
2 changes: 1 addition & 1 deletion sw/device/silicon_creator/manuf/lib/individualize_sw_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#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/crypto/include/hash.h"
#include "sw/device/lib/dif/dif_flash_ctrl.h"
#include "sw/device/lib/dif/dif_otp_ctrl.h"
#include "sw/device/lib/testing/flash_ctrl_testutils.h"
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 @@ -17,8 +17,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
2 changes: 0 additions & 2 deletions sw/device/tests/crypto/ecdsa_p384_sideload_functest.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#define MODULE_ID MAKE_MODULE_ID('t', 's', 't')

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 15ed2ec

Please sign in to comment.