Skip to content

Commit

Permalink
fix length types
Browse files Browse the repository at this point in the history
  • Loading branch information
dangfan committed Dec 10, 2023
1 parent c2855d9 commit 7007cba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions include/algo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef CANOKEY_CRYPTO_ALGO_H
#define CANOKEY_CRYPTO_ALGO_H

#include <stddef.h>

typedef enum {
SECP256R1,
SECP256K1,
Expand All @@ -17,9 +19,9 @@ typedef enum {
AES256,
} key_type_t;

extern const int PRIVATE_KEY_LENGTH[KEY_TYPE_PKC_END];
extern const int PUBLIC_KEY_LENGTH[KEY_TYPE_PKC_END];
extern const int SIGNATURE_LENGTH[KEY_TYPE_PKC_END];
extern const size_t PRIVATE_KEY_LENGTH[KEY_TYPE_PKC_END];
extern const size_t PUBLIC_KEY_LENGTH[KEY_TYPE_PKC_END];
extern const size_t SIGNATURE_LENGTH[KEY_TYPE_PKC_END];

#define IS_ECC(type) ((type) == SECP256R1 || (type) == SECP256K1 || (type) == SECP384R1 || (type) == SM2 || (type) == ED25519 || (type) == X25519)
#define IS_SHORT_WEIERSTRASS(type) ((type) == SECP256R1 || (type) == SECP256K1 || (type) == SECP384R1 || (type) == SM2)
Expand Down
6 changes: 3 additions & 3 deletions src/algo.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
#include <algo.h>

const int PRIVATE_KEY_LENGTH[KEY_TYPE_PKC_END] = {32, 32, 48, 32, 32, 32, 128, 192, 256};
const int PUBLIC_KEY_LENGTH[KEY_TYPE_PKC_END] = {64, 64, 96, 64, 32, 32, 256, 384, 512};
const int SIGNATURE_LENGTH[KEY_TYPE_PKC_END] = {64, 64, 96, 64, 64, 64, 256, 384, 512};
const size_t PRIVATE_KEY_LENGTH[KEY_TYPE_PKC_END] = {32, 32, 48, 32, 32, 32, 128, 192, 256};
const size_t PUBLIC_KEY_LENGTH[KEY_TYPE_PKC_END] = {64, 64, 96, 64, 32, 32, 256, 384, 512};
const size_t SIGNATURE_LENGTH[KEY_TYPE_PKC_END] = {64, 64, 96, 64, 64, 64, 256, 384, 512};

0 comments on commit 7007cba

Please sign in to comment.