Skip to content

Commit

Permalink
PKCS11: Remove an unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
aveenismail committed Mar 21, 2024
1 parent 7be67d3 commit fe76c00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
12 changes: 2 additions & 10 deletions common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ bool read_private_key(uint8_t *buf, size_t len, yh_algorithm *algo,
}

bool read_public_key(uint8_t *buf, size_t len, yh_algorithm *algo,
uint8_t *bytes, size_t *bytes_len) {
uint8_t *bytes, size_t *bytes_len) {
BIO *bio = BIO_new(BIO_s_mem());
if (bio == NULL) {
return false;
Expand Down Expand Up @@ -421,7 +421,7 @@ bool read_public_key(uint8_t *buf, size_t len, yh_algorithm *algo,
}

size_t data_len = i2o_ECPublicKey(ec, 0);
if (data_len == 0 || data_len > *bytes_len) {
if(data_len == 0 || data_len > *bytes_len) {
EC_KEY_free(ec);
return false;
}
Expand Down Expand Up @@ -817,11 +817,3 @@ bool split_hmac_key(yh_algorithm algorithm, uint8_t *in, size_t in_len,

return true;
}

void increment_ctr(uint8_t *ctr, size_t len) {
while (len > 0) {
if (++ctr[--len]) {
break;
}
}
}
3 changes: 1 addition & 2 deletions common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool YH_INTERNAL read_private_key(uint8_t *buf, size_t len, yh_algorithm *algo,
uint8_t *bytes, size_t *bytes_len,
bool internal_repr);
bool YH_INTERNAL read_public_key(uint8_t *buf, size_t len, yh_algorithm *algo,
uint8_t *bytes, size_t *bytes_len);
uint8_t *bytes, size_t *bytes_len);
void YH_INTERNAL format_digest(uint8_t *digest, char *str, uint16_t len);
int YH_INTERNAL algo2nid(yh_algorithm algo);
bool YH_INTERNAL algo2type(yh_algorithm algorithm, yh_object_type *type);
Expand All @@ -62,6 +62,5 @@ bool YH_INTERNAL base64_decode(const char *in, uint8_t *out, size_t *len);

bool YH_INTERNAL split_hmac_key(yh_algorithm algorithm, uint8_t *in,
size_t in_len, uint8_t *out, size_t *out_len);
void YH_INTERNAL increment_ctr(uint8_t *ctr, size_t len);

#endif
9 changes: 8 additions & 1 deletion pkcs11/util_pkcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#include "util_pkcs11.h"
#include "debug_p11.h"
#include "../common/util.h"
#include "../common/openssl-compat.h"
#include "../common/insecure_memzero.h"

Expand Down Expand Up @@ -5310,6 +5309,14 @@ bool match_meta_attributes(yubihsm_pkcs11_session *session,
return true;
}

static void increment_ctr(uint8_t *ctr, size_t len) {
while (len > 0) {
if (++ctr[--len]) {
break;
}
}
}

CK_RV ecdh_with_kdf(ecdh_session_key *shared_secret, uint8_t *fixed_info,
size_t fixed_len, CK_ULONG kdf, size_t value_len) {

Expand Down

0 comments on commit fe76c00

Please sign in to comment.