Skip to content

Commit 27560a4

Browse files
Refact: Move custom CA functions into CCA module
1 parent cb5cfae commit 27560a4

File tree

4 files changed

+48
-24
lines changed

4 files changed

+48
-24
lines changed

include/cca_public.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file cca_public.h
3+
* @brief Types and prototypes to interact with the Custom CA module from public user-land.
4+
*/
5+
6+
#ifndef CCA_PUBLIC_H_
7+
#define CCA_PUBLIC_H_
8+
9+
#ifdef HAVE_BOLOS_CUSTOMCA
10+
11+
#include "bolos_target.h"
12+
#include "decorators.h"
13+
14+
/* ----------------------------------------------------------------------- */
15+
/* - CUSTOM CERTIFICATE AUTHORITY - */
16+
/* ----------------------------------------------------------------------- */
17+
18+
// Verify the signature is issued from the custom certificate authority
19+
20+
/**
21+
* @brief Verify hash signature with custom certificate authority
22+
*
23+
* @param hash Hash to be verified (32 bytes length).
24+
* @param sign Signature to be verified
25+
* @param sign_length Signature length
26+
* @return bool
27+
* @retval Verification OK
28+
* @retval Verification not OK
29+
*
30+
*/
31+
SYSCALL unsigned int cca_verify_custom_ca(unsigned char *hash PLENGTH(32),
32+
unsigned char *sign PLENGTH(sign_length),
33+
unsigned int sign_length);
34+
35+
#endif // HAVE_BOLOS_CUSTOMCA
36+
#endif // CCA_PUBLIC_H_

include/os_customca.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

include/syscalls.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@
201201
#define SYSCALL_os_dashboard_mbx_ID 0x02000150
202202

203203
#ifdef HAVE_CUSTOM_CA_DETAILS_IN_SETTINGS
204-
#define SYSCALL_os_bolos_custom_ca_get_info_ID 0x01000CA0
205-
#define SYSCALL_os_bolos_custom_ca_revoke_ID 0x00000CA1
204+
#define SYSCALL_cca_get_custom_ca_info_ID 0x01000CA0
205+
#define SYSCALL_cca_custom_ca_revoke_ID 0x00000CA1
206206
#endif // HAVE_CUSTOM_CA_DETAILS_IN_SETTINGS
207207

208208
#define SYSCALL_os_bolos_endorsement_revoke_ID 0x010001ED
209209

210210
#ifdef HAVE_BOLOS_CUSTOMCA
211-
#define SYSCALL_os_customca_verify_ID 0x03000090
211+
#define SYSCALL_cca_verify_custom_ca_ID 0x03000090
212212
#endif // HAVE_BOLOS_CUSTOMCA
213213

214214
#ifdef HAVE_AEM_PIN

src/syscalls.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,13 +1738,15 @@ void os_registry_delete_all_apps(void)
17381738
}
17391739

17401740
#ifdef HAVE_BOLOS_CUSTOMCA
1741-
unsigned int os_customca_verify(unsigned char *hash, unsigned char *sign, unsigned int sign_length)
1741+
unsigned int cca_verify_custom_ca(unsigned char *hash,
1742+
unsigned char *sign,
1743+
unsigned int sign_length)
17421744
{
17431745
unsigned int parameters[3];
17441746
parameters[0] = (unsigned int) hash;
17451747
parameters[1] = (unsigned int) sign;
17461748
parameters[2] = (unsigned int) sign_length;
1747-
return (unsigned int) SVC_Call(SYSCALL_os_customca_verify_ID, parameters);
1749+
return (unsigned int) SVC_Call(SYSCALL_cca_verify_custom_ca_ID, parameters);
17481750
}
17491751
#endif // HAVE_BOLOS_CUSTOMCA
17501752

@@ -1929,19 +1931,20 @@ unsigned int os_deny_protected_flash(void)
19291931
}
19301932

19311933
#ifdef HAVE_CUSTOM_CA_DETAILS_IN_SETTINGS
1932-
bolos_bool_t os_bolos_custom_ca_get_info(customca_data_t *custom_ca)
1934+
1935+
bolos_bool_t cca_get_custom_ca_info(customca_data_t *custom_ca)
19331936
{
19341937
unsigned int parameters[2];
19351938
parameters[0] = (unsigned int) custom_ca;
1936-
bolos_bool_t ret = (bolos_bool_t) SVC_Call(SYSCALL_os_bolos_custom_ca_get_info_ID, parameters);
1939+
bolos_bool_t ret = (bolos_bool_t) SVC_Call(SYSCALL_cca_get_custom_ca_info_ID, parameters);
19371940
return ret;
19381941
}
19391942

1940-
void os_bolos_custom_ca_revoke(void)
1943+
void cca_custom_ca_revoke(void)
19411944
{
19421945
unsigned int parameters[1];
19431946
parameters[0] = 0;
1944-
SVC_Call(SYSCALL_os_bolos_custom_ca_revoke_ID, parameters);
1947+
SVC_Call(SYSCALL_cca_custom_ca_revoke_ID, parameters);
19451948
return;
19461949
}
19471950
#endif // HAVE_CUSTOM_CA_DETAILS_IN_SETTINGS

0 commit comments

Comments
 (0)