1 | /* |
---|---|
2 | * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
5 | * You may not use this file except in compliance with the License. |
6 | * A copy of the License is located at |
7 | * |
8 | * http://aws.amazon.com/apache2.0 |
9 | * |
10 | * or in the "license" file accompanying this file. This file is distributed |
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
12 | * express or implied. See the License for the specific language governing |
13 | * permissions and limitations under the License. |
14 | */ |
15 | #include <aws/common/device_random.h> |
16 | |
17 | #include <aws/common/byte_buf.h> |
18 | |
19 | #ifdef _MSC_VER |
20 | /* disables warning non const declared initializers for Microsoft compilers */ |
21 | # pragma warning(disable : 4204) |
22 | # pragma warning(disable : 4706) |
23 | #endif |
24 | |
25 | int aws_device_random_u64(uint64_t *output) { |
26 | struct aws_byte_buf buf = aws_byte_buf_from_empty_array((uint8_t *)output, sizeof(uint64_t)); |
27 | |
28 | return aws_device_random_buffer(&buf); |
29 | } |
30 | |
31 | int aws_device_random_u32(uint32_t *output) { |
32 | struct aws_byte_buf buf = aws_byte_buf_from_empty_array((uint8_t *)output, sizeof(uint32_t)); |
33 | |
34 | return aws_device_random_buffer(&buf); |
35 | } |
36 | |
37 | int aws_device_random_u16(uint16_t *output) { |
38 | struct aws_byte_buf buf = aws_byte_buf_from_empty_array((uint8_t *)output, sizeof(uint16_t)); |
39 | |
40 | return aws_device_random_buffer(&buf); |
41 | } |
42 | |
43 | int aws_device_random_u8(uint8_t *output) { |
44 | struct aws_byte_buf buf = aws_byte_buf_from_empty_array((uint8_t *)output, sizeof(uint8_t)); |
45 | |
46 | return aws_device_random_buffer(&buf); |
47 | } |
48 |