File: key_derivation.h

package info (click to toggle)
aws-crt-python 0.20.4%2Bdfsg-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 72,656 kB
  • sloc: ansic: 381,805; python: 23,008; makefile: 6,251; sh: 4,536; cpp: 699; ruby: 208; java: 77; perl: 73; javascript: 46; xml: 11
file content (51 lines) | stat: -rw-r--r-- 1,495 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef AWS_AUTH_KEY_DERIVATION_H
#define AWS_AUTH_KEY_DERIVATION_H

/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include <aws/auth/auth.h>

struct aws_byte_buf;

AWS_EXTERN_C_BEGIN

/*
 * Some utility functions used while deriving an ecc key from aws credentials.
 *
 * The functions operate on the raw bytes of a buffer, treating them as a (base 255) big-endian
 * integer.
 */

/**
 * Compares two byte buffers lexically.  The buffers must be of equal size.  Lexical comparison from front-to-back
 * corresponds to arithmetic comparison when the byte sequences are considered to be big-endian large integers.
 * The output parameter comparison_result is set to:
 *   -1 if lhs_raw_be_bigint < rhs_raw_be_bigint
 *    0 if lhs_raw_be_bigint == rhs_raw_be_bigint
 *    1 if lhs_raw_be_bigint > rhs_raw_be_bigint
 *
 * @return AWS_OP_SUCCESS or AWS_OP_ERR
 *
 * This is a constant-time operation.
 */
AWS_AUTH_API
int aws_be_bytes_compare_constant_time(
    const struct aws_byte_buf *lhs_raw_be_bigint,
    const struct aws_byte_buf *rhs_raw_be_bigint,
    int *comparison_result);

/**
 * Adds one to a big integer represented as a sequence of bytes (in big-endian order).  A maximal (unsigned) value
 * will roll over to 0.
 *
 * This is a constant-time operation.
 */
AWS_AUTH_API
void aws_be_bytes_add_one_constant_time(struct aws_byte_buf *raw_be_bigint);

AWS_EXTERN_C_END

#endif /* AWS_AUTH_KEY_DERIVATION_H */