Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Ledger PKI #490

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/bolos_syscalls_unified_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,7 @@
#define SYSCALL_cx_hash_to_field_ID_IN 0x06000104
#define SYSCALL_cx_bls12381_aggregate_ID_IN 0x05000105
#define SYSCALL_cx_bls12381_key_gen_ID_IN 0x03000108

#define SYSCALL_os_pki_load_certificate_ID_IN 0x060000aa
#define SYSCALL_os_pki_verify_ID_IN 0x040000ab
#define SYSCALL_os_pki_get_info_ID_IN 0x040000ac
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ add_library(emu
bolos/cx_hash.c
bolos/cx_math.c
bolos/default.c
bolos/os_pki.c
bolos/os_signature.c
emulate.c
emulate_1.2.c
emulate_1.5.c
Expand Down
1 change: 1 addition & 0 deletions src/bolos/cx_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const cx_hash_info_t *spec_cx_hash_get_info(cx_md_t md_type)
case CX_SHA512:
return &cx_sha512_info;
case CX_SHA3:
case CX_SHA3_256:
return &cx_sha3_info;
case CX_KECCAK:
return &cx_keccak_info;
Expand Down
3 changes: 3 additions & 0 deletions src/bolos/cx_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define CX_SHA256_SIZE 32
#define CX_SHA384_SIZE 48
#define CX_SHA512_SIZE 64
#define CX_SHA3_256_SIZE 32

#define RIPEMD_BLOCK_SIZE 64
#define SHA256_BLOCK_SIZE 64
Expand Down Expand Up @@ -44,6 +45,8 @@ enum cx_md_e {
CX_SHAKE128, // any bytes
/** SHAKE-128 Digest */
CX_SHAKE256, // any bytes
/** SHA3 256*/
CX_SHA3_256,
};
/** Convenience type. See #cx_md_e. */
typedef enum cx_md_e cx_md_t;
Expand Down
11 changes: 11 additions & 0 deletions src/bolos/cx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@ void U4BE_ENCODE(uint8_t *buf, size_t off, uint32_t value)
buf[off + 3] = value & 0xFF;
}

uint16_t U2BE(const uint8_t *buf, size_t off)
{
return (buf[off] << 8) | buf[off + 1];
}

uint32_t U4BE(const uint8_t *buf, size_t off)
{
return (((uint32_t)buf[off]) << 24) | (buf[off + 1] << 16) |
(buf[off + 2] << 8) | buf[off + 3];
}

void cx_memxor(uint8_t *buf1, const uint8_t *buf2, size_t len)
{
size_t i;
Expand Down
2 changes: 2 additions & 0 deletions src/bolos/cx_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ int get_path(const char *str_, unsigned int *path, int max_path_len);

void U2BE_ENCODE(uint8_t *buf, size_t off, uint32_t value);
void U4BE_ENCODE(uint8_t *buf, size_t off, uint32_t value);
uint16_t U2BE(const uint8_t *buf, size_t off);
uint32_t U4BE(const uint8_t *buf, size_t off);
void cx_memxor(uint8_t *buf1, const uint8_t *buf2, size_t len);
Loading
Loading