VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1g/crypto/blake2/blake2_local.h@ 85201

最後變更 在這個檔案從85201是 83916,由 vboxsync 提交於 5 年 前

openssl-1.1.1g: Applied and adjusted our OpenSSL changes to 1.1.1g. bugref:9719

檔案大小: 2.6 KB
 
1/*
2 * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10/*
11 * Derived from the BLAKE2 reference implementation written by Samuel Neves.
12 * Copyright 2012, Samuel Neves <[email protected]>
13 * More information about the BLAKE2 hash function and its implementations
14 * can be found at https://blake2.net.
15 */
16
17#include <stddef.h>
18
19#define BLAKE2S_BLOCKBYTES 64
20#define BLAKE2S_OUTBYTES 32
21#define BLAKE2S_KEYBYTES 32
22#define BLAKE2S_SALTBYTES 8
23#define BLAKE2S_PERSONALBYTES 8
24
25#define BLAKE2B_BLOCKBYTES 128
26#define BLAKE2B_OUTBYTES 64
27#define BLAKE2B_KEYBYTES 64
28#define BLAKE2B_SALTBYTES 16
29#define BLAKE2B_PERSONALBYTES 16
30
31struct blake2s_param_st {
32 uint8_t digest_length; /* 1 */
33 uint8_t key_length; /* 2 */
34 uint8_t fanout; /* 3 */
35 uint8_t depth; /* 4 */
36 uint8_t leaf_length[4];/* 8 */
37 uint8_t node_offset[6];/* 14 */
38 uint8_t node_depth; /* 15 */
39 uint8_t inner_length; /* 16 */
40 uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */
41 uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */
42};
43
44typedef struct blake2s_param_st BLAKE2S_PARAM;
45
46struct blake2s_ctx_st {
47 uint32_t h[8];
48 uint32_t t[2];
49 uint32_t f[2];
50 uint8_t buf[BLAKE2S_BLOCKBYTES];
51 size_t buflen;
52};
53
54struct blake2b_param_st {
55 uint8_t digest_length; /* 1 */
56 uint8_t key_length; /* 2 */
57 uint8_t fanout; /* 3 */
58 uint8_t depth; /* 4 */
59 uint8_t leaf_length[4];/* 8 */
60 uint8_t node_offset[8];/* 16 */
61 uint8_t node_depth; /* 17 */
62 uint8_t inner_length; /* 18 */
63 uint8_t reserved[14]; /* 32 */
64 uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
65 uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
66};
67
68typedef struct blake2b_param_st BLAKE2B_PARAM;
69
70struct blake2b_ctx_st {
71 uint64_t h[8];
72 uint64_t t[2];
73 uint64_t f[2];
74 uint8_t buf[BLAKE2B_BLOCKBYTES];
75 size_t buflen;
76};
77
78#define BLAKE2B_DIGEST_LENGTH 64
79#define BLAKE2S_DIGEST_LENGTH 32
80
81typedef struct blake2s_ctx_st BLAKE2S_CTX;
82typedef struct blake2b_ctx_st BLAKE2B_CTX;
83
84int BLAKE2b_Init(BLAKE2B_CTX *c);
85int BLAKE2b_Update(BLAKE2B_CTX *c, const void *data, size_t datalen);
86int BLAKE2b_Final(unsigned char *md, BLAKE2B_CTX *c);
87
88int BLAKE2s_Init(BLAKE2S_CTX *c);
89int BLAKE2s_Update(BLAKE2S_CTX *c, const void *data, size_t datalen);
90int BLAKE2s_Final(unsigned char *md, BLAKE2S_CTX *c);
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette