Skip to content

Commit

Permalink
Update bindgen and cbindgen to latest versions. (#593)
Browse files Browse the repository at this point in the history
Verified that `aziot-keys.h` generated by cbindgen has only formatting changes and that `keys.generated.rs` generated by bindgen is identical.

Also move `/aziotctl/.cargo/` to `/.cargo/` so that other crates that need the env vars also get them.
  • Loading branch information
arsing authored Mar 6, 2024
1 parent 5d0c44e commit 82936fb
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 48 deletions.
File renamed without changes.
44 changes: 22 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ci/install-build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ rustup self update
# Ref: https://github.com/rust-lang/rustup/issues/2579
rustup set profile minimal

BINDGEN_VERSION='0.60.0'
CBINDGEN_VERSION='0.24.2'
BINDGEN_VERSION='0.69.4'
CBINDGEN_VERSION='0.26.0'

case "$ARCH" in
'amd64')
Expand All @@ -311,7 +311,7 @@ esac

# Mariner build installs the following as part of the specfile.
if [ "${OS#mariner}" = "$OS" ]; then
cargo install bindgen --version "=$BINDGEN_VERSION" --locked
cargo install bindgen-cli --version "=$BINDGEN_VERSION" --locked

cargo install cbindgen --version "=$CBINDGEN_VERSION" --locked

Expand Down
2 changes: 1 addition & 1 deletion contrib/mariner/aziot-identity-service.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pushd ~
tar xf %{SOURCE1} --no-same-owner
tar xf %{SOURCE2} --no-same-owner
popd
cargo install bindgen --path ~/rust-bindgen-@@BINDGEN_VERSION@@ --offline
cargo install bindgen-cli --path ~/rust-bindgen-@@BINDGEN_VERSION@@/bindgen-cli --offline
cargo install cbindgen --path ~/cbindgen-@@CBINDGEN_VERSION@@ --offline

# locate openssl lib directory for Makefile
Expand Down
98 changes: 84 additions & 14 deletions key/aziot-keys/aziot-keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*get_key_pair_parameter)(const char *id, AZIOT_KEYS_KEY_PAIR_PARAMETER_TYPE type_, unsigned char *value, uintptr_t *value_len);
AZIOT_KEYS_RC (*get_key_pair_parameter)(const char *id,
AZIOT_KEYS_KEY_PAIR_PARAMETER_TYPE type_,
unsigned char *value,
uintptr_t *value_len);
/**
* Create or load a key identified by the specified `id`.
*
Expand Down Expand Up @@ -292,7 +295,10 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*import_key)(const char *id, const uint8_t *bytes, uintptr_t bytes_len, AZIOT_KEYS_KEY_USAGE usage);
AZIOT_KEYS_RC (*import_key)(const char *id,
const uint8_t *bytes,
uintptr_t bytes_len,
AZIOT_KEYS_KEY_USAGE usage);
/**
* Derive a key with a given base key using some derivation data, and return the derived key.
*
Expand Down Expand Up @@ -328,7 +334,11 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*derive_key)(const char *base_id, const uint8_t *derivation_data, uintptr_t derivation_data_len, unsigned char *derived_key, uintptr_t *derived_key_len);
AZIOT_KEYS_RC (*derive_key)(const char *base_id,
const uint8_t *derivation_data,
uintptr_t derivation_data_len,
unsigned char *derived_key,
uintptr_t *derived_key_len);
/**
* Sign the given digest using the key or key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -359,7 +369,13 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*sign)(const char *id, AZIOT_KEYS_SIGN_MECHANISM mechanism, const void *parameters, const unsigned char *digest, uintptr_t digest_len, unsigned char *signature, uintptr_t *signature_len);
AZIOT_KEYS_RC (*sign)(const char *id,
AZIOT_KEYS_SIGN_MECHANISM mechanism,
const void *parameters,
const unsigned char *digest,
uintptr_t digest_len,
unsigned char *signature,
uintptr_t *signature_len);
/**
* Verify the signature of the given digest using the key or key pair (but see note below) identified by the specified `id`.
*
Expand Down Expand Up @@ -394,7 +410,14 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*verify)(const char *id, AZIOT_KEYS_SIGN_MECHANISM mechanism, const void *parameters, const unsigned char *digest, uintptr_t digest_len, const unsigned char *signature, uintptr_t signature_len, int *ok);
AZIOT_KEYS_RC (*verify)(const char *id,
AZIOT_KEYS_SIGN_MECHANISM mechanism,
const void *parameters,
const unsigned char *digest,
uintptr_t digest_len,
const unsigned char *signature,
uintptr_t signature_len,
int *ok);
/**
* Encrypt the given plaintext using the key or key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -425,7 +448,13 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*encrypt)(const char *id, AZIOT_KEYS_ENCRYPT_MECHANISM mechanism, const void *parameters, const unsigned char *plaintext, uintptr_t plaintext_len, unsigned char *ciphertext, uintptr_t *ciphertext_len);
AZIOT_KEYS_RC (*encrypt)(const char *id,
AZIOT_KEYS_ENCRYPT_MECHANISM mechanism,
const void *parameters,
const unsigned char *plaintext,
uintptr_t plaintext_len,
unsigned char *ciphertext,
uintptr_t *ciphertext_len);
/**
* Decrypt the given plaintext using the key or key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -456,7 +485,13 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_0_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*decrypt)(const char *id, AZIOT_KEYS_ENCRYPT_MECHANISM mechanism, const void *parameters, const unsigned char *ciphertext, uintptr_t ciphertext_len, unsigned char *plaintext, uintptr_t *plaintext_len);
AZIOT_KEYS_RC (*decrypt)(const char *id,
AZIOT_KEYS_ENCRYPT_MECHANISM mechanism,
const void *parameters,
const unsigned char *ciphertext,
uintptr_t ciphertext_len,
unsigned char *plaintext,
uintptr_t *plaintext_len);
} AZIOT_KEYS_FUNCTION_LIST_2_0_0_0;

/**
Expand Down Expand Up @@ -573,7 +608,10 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*get_key_pair_parameter)(const char *id, AZIOT_KEYS_KEY_PAIR_PARAMETER_TYPE type_, unsigned char *value, uintptr_t *value_len);
AZIOT_KEYS_RC (*get_key_pair_parameter)(const char *id,
AZIOT_KEYS_KEY_PAIR_PARAMETER_TYPE type_,
unsigned char *value,
uintptr_t *value_len);
/**
* Delete an existing key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -637,7 +675,10 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*import_key)(const char *id, const uint8_t *bytes, uintptr_t bytes_len, AZIOT_KEYS_KEY_USAGE usage);
AZIOT_KEYS_RC (*import_key)(const char *id,
const uint8_t *bytes,
uintptr_t bytes_len,
AZIOT_KEYS_KEY_USAGE usage);
/**
* Delete an existing key identified by the specified `id`.
*
Expand Down Expand Up @@ -687,7 +728,11 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*derive_key)(const char *base_id, const uint8_t *derivation_data, uintptr_t derivation_data_len, unsigned char *derived_key, uintptr_t *derived_key_len);
AZIOT_KEYS_RC (*derive_key)(const char *base_id,
const uint8_t *derivation_data,
uintptr_t derivation_data_len,
unsigned char *derived_key,
uintptr_t *derived_key_len);
/**
* Sign the given digest using the key or key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -718,7 +763,13 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*sign)(const char *id, AZIOT_KEYS_SIGN_MECHANISM mechanism, const void *parameters, const unsigned char *digest, uintptr_t digest_len, unsigned char *signature, uintptr_t *signature_len);
AZIOT_KEYS_RC (*sign)(const char *id,
AZIOT_KEYS_SIGN_MECHANISM mechanism,
const void *parameters,
const unsigned char *digest,
uintptr_t digest_len,
unsigned char *signature,
uintptr_t *signature_len);
/**
* Verify the signature of the given digest using the key or key pair (but see note below) identified by the specified `id`.
*
Expand Down Expand Up @@ -753,7 +804,14 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*verify)(const char *id, AZIOT_KEYS_SIGN_MECHANISM mechanism, const void *parameters, const unsigned char *digest, uintptr_t digest_len, const unsigned char *signature, uintptr_t signature_len, int *ok);
AZIOT_KEYS_RC (*verify)(const char *id,
AZIOT_KEYS_SIGN_MECHANISM mechanism,
const void *parameters,
const unsigned char *digest,
uintptr_t digest_len,
const unsigned char *signature,
uintptr_t signature_len,
int *ok);
/**
* Encrypt the given plaintext using the key or key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -784,7 +842,13 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*encrypt)(const char *id, AZIOT_KEYS_ENCRYPT_MECHANISM mechanism, const void *parameters, const unsigned char *plaintext, uintptr_t plaintext_len, unsigned char *ciphertext, uintptr_t *ciphertext_len);
AZIOT_KEYS_RC (*encrypt)(const char *id,
AZIOT_KEYS_ENCRYPT_MECHANISM mechanism,
const void *parameters,
const unsigned char *plaintext,
uintptr_t plaintext_len,
unsigned char *ciphertext,
uintptr_t *ciphertext_len);
/**
* Decrypt the given plaintext using the key or key pair identified by the specified `id`.
*
Expand Down Expand Up @@ -815,7 +879,13 @@ typedef struct AZIOT_KEYS_FUNCTION_LIST_2_1_0_0 {
*
* - `AZIOT_KEYS_RC_ERR_EXTERNAL`
*/
AZIOT_KEYS_RC (*decrypt)(const char *id, AZIOT_KEYS_ENCRYPT_MECHANISM mechanism, const void *parameters, const unsigned char *ciphertext, uintptr_t ciphertext_len, unsigned char *plaintext, uintptr_t *plaintext_len);
AZIOT_KEYS_RC (*decrypt)(const char *id,
AZIOT_KEYS_ENCRYPT_MECHANISM mechanism,
const void *parameters,
const unsigned char *ciphertext,
uintptr_t ciphertext_len,
unsigned char *plaintext,
uintptr_t *plaintext_len);
} AZIOT_KEYS_FUNCTION_LIST_2_1_0_0;

/**
Expand Down
6 changes: 3 additions & 3 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ parts:
build-packages:
- curl
build-environment:
- BINDGEN_VERSION: '0.60.0'
- CBINDGEN_VERSION: '0.24.2'
- BINDGEN_VERSION: '0.69.4'
- CBINDGEN_VERSION: '0.26.0'
- PATH: "$PATH:$HOME/.cargo/bin"
override-build: |
mkdir -p $HOME/.cargo/bin
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path --profile minimal -y
cargo install bindgen --version "=$BINDGEN_VERSION"
cargo install bindgen-cli --version "=$BINDGEN_VERSION"
cargo install cbindgen --version "=$CBINDGEN_VERSION"
iot-identity-services:
build-environment:
Expand Down
Loading

0 comments on commit 82936fb

Please sign in to comment.