| 1 | #ifndef AWS_AUTH_KEY_DERIVATION_H |
| 2 | #define AWS_AUTH_KEY_DERIVATION_H |
| 3 | |
| 4 | /** |
| 5 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 6 | * SPDX-License-Identifier: Apache-2.0. |
| 7 | */ |
| 8 | |
| 9 | #include <aws/auth/auth.h> |
| 10 | |
| 11 | struct aws_byte_buf; |
| 12 | |
| 13 | AWS_EXTERN_C_BEGIN |
| 14 | |
| 15 | /* |
| 16 | * Some utility functions used while deriving an ecc key from aws credentials. |
| 17 | * |
| 18 | * The functions operate on the raw bytes of a buffer, treating them as a (base 255) big-endian |
| 19 | * integer. |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * Compares two byte buffers lexically. The buffers must be of equal size. Lexical comparison from front-to-back |
| 24 | * corresponds to arithmetic comparison when the byte sequences are considered to be big-endian large integers. |
| 25 | * The output parameter comparison_result is set to: |
| 26 | * -1 if lhs_raw_be_bigint < rhs_raw_be_bigint |
| 27 | * 0 if lhs_raw_be_bigint == rhs_raw_be_bigint |
| 28 | * 1 if lhs_raw_be_bigint > rhs_raw_be_bigint |
| 29 | * |
| 30 | * @return AWS_OP_SUCCESS or AWS_OP_ERR |
| 31 | * |
| 32 | * This is a constant-time operation. |
| 33 | */ |
| 34 | AWS_AUTH_API |
| 35 | int aws_be_bytes_compare_constant_time( |
| 36 | const struct aws_byte_buf *lhs_raw_be_bigint, |
| 37 | const struct aws_byte_buf *rhs_raw_be_bigint, |
| 38 | int *comparison_result); |
| 39 | |
| 40 | /** |
| 41 | * Adds one to a big integer represented as a sequence of bytes (in big-endian order). A maximal (unsigned) value |
| 42 | * will roll over to 0. |
| 43 | * |
| 44 | * This is a constant-time operation. |
| 45 | */ |
| 46 | AWS_AUTH_API |
| 47 | void aws_be_bytes_add_one_constant_time(struct aws_byte_buf *raw_be_bigint); |
| 48 | |
| 49 | AWS_EXTERN_C_END |
| 50 | |
| 51 | #endif /* AWS_AUTH_KEY_DERIVATION_H */ |