Skip to content

Commit 70d4017

Browse files
committed
Use shims for two getters, and add a comment.
1 parent 9e1579e commit 70d4017

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/c/shim.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
// Copyright 2020 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
// This file is needed to provide linkable versions of certain
5+
// PSA Crypto functions that may be declared static inline.
6+
// See: https://github.com/ARMmbed/mbedtls/issues/3230
7+
48
#include "shim.h"
59

10+
size_t
11+
shim_get_key_bits(const psa_key_attributes_t *attributes)
12+
{
13+
return psa_get_key_bits(attributes);
14+
}
15+
16+
psa_key_type_t
17+
shim_get_key_type(const psa_key_attributes_t *attributes)
18+
{
19+
return psa_get_key_type(attributes);
20+
}
21+
622
psa_key_attributes_t
723
shim_key_attributes_init(void)
824
{

src/c/shim.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ const psa_key_usage_t shim_PSA_KEY_USAGE_SIGN = PSA_KEY_USAGE_SIGN;
143143
const psa_key_usage_t shim_PSA_KEY_USAGE_VERIFY = PSA_KEY_USAGE_VERIFY;
144144
const psa_key_usage_t shim_PSA_KEY_USAGE_DERIVE = PSA_KEY_USAGE_DERIVE;
145145

146+
size_t
147+
shim_get_key_bits(const psa_key_attributes_t *attributes);
148+
149+
psa_key_type_t
150+
shim_get_key_type(const psa_key_attributes_t *attributes);
151+
146152
psa_key_attributes_t
147153
shim_key_attributes_init(void);
148154

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,6 @@ pub fn psa_get_key_attributes(
229229
))
230230
}
231231

232-
pub fn psa_get_key_bits(attributes: &psa_key_attributes_t) -> usize {
233-
wrap_any!((*attributes).x.core.bits as usize)
234-
}
235-
236-
pub fn psa_get_key_type(attributes: &psa_key_attributes_t) -> psa_key_type_t {
237-
wrap_any!((*attributes).x.core.type_)
238-
}
239-
240232
pub fn psa_import_key(
241233
attributes: *const psa_key_attributes_t,
242234
data: *const u8,
@@ -263,6 +255,14 @@ pub fn psa_reset_key_attributes(attributes: *mut psa_key_attributes_t) {
263255

264256
// Wrapped shims:
265257

258+
pub fn psa_get_key_bits(attributes: &psa_key_attributes_t) -> usize {
259+
wrap_any!(psa_crypto_binding::shim_get_key_bits(&attributes.x))
260+
}
261+
262+
pub fn psa_get_key_type(attributes: &psa_key_attributes_t) -> psa_key_type_t {
263+
wrap_any!(psa_crypto_binding::shim_get_key_type(&attributes.x))
264+
}
265+
266266
pub fn psa_key_attributes_init() -> psa_key_attributes_t {
267267
let attr = wrap_any!(psa_crypto_binding::shim_key_attributes_init());
268268
psa_key_attributes_t { x: attr }

0 commit comments

Comments
 (0)