/src/openssh/crypto_api.h
Line | Count | Source |
1 | | /* $OpenBSD: crypto_api.h,v 1.10 2025/10/30 23:19:33 djm Exp $ */ |
2 | | |
3 | | /* |
4 | | * Assembled from generated headers and source files by Markus Friedl. |
5 | | * Placed in the public domain. |
6 | | */ |
7 | | |
8 | | #ifndef crypto_api_h |
9 | | #define crypto_api_h |
10 | | |
11 | | #include "includes.h" |
12 | | |
13 | | #include <stdint.h> |
14 | | #include <stdlib.h> |
15 | | |
16 | | typedef int8_t crypto_int8; |
17 | | typedef uint8_t crypto_uint8; |
18 | | typedef int16_t crypto_int16; |
19 | | typedef uint16_t crypto_uint16; |
20 | | typedef int32_t crypto_int32; |
21 | | typedef uint32_t crypto_uint32; |
22 | | typedef int64_t crypto_int64; |
23 | | typedef uint64_t crypto_uint64; |
24 | | |
25 | | #define randombytes(buf, buf_len) arc4random_buf((buf), (buf_len)) |
26 | | #define small_random32() arc4random() |
27 | | |
28 | 0 | #define crypto_hash_sha512_BYTES 64U |
29 | | |
30 | | #ifdef WITH_OPENSSL |
31 | | #include <openssl/evp.h> |
32 | | static inline int |
33 | | crypto_hash_sha512(unsigned char *out, const unsigned char *in, |
34 | | unsigned long long inlen) |
35 | 0 | { |
36 | |
|
37 | 0 | if (!EVP_Digest(in, inlen, out, NULL, EVP_sha512(), NULL)) |
38 | 0 | return -1; |
39 | 0 | return 0; |
40 | 0 | } Unexecuted instantiation: sshkey.c:crypto_hash_sha512 Unexecuted instantiation: ssh-ed25519-sk.c:crypto_hash_sha512 Unexecuted instantiation: ssh-ed25519.c:crypto_hash_sha512 Unexecuted instantiation: ed25519-openssl.c:crypto_hash_sha512 Unexecuted instantiation: bcrypt_pbkdf.c:crypto_hash_sha512 |
41 | | #else /* WITH_OPENSSL */ |
42 | | # ifdef HAVE_SHA2_H |
43 | | # include <sha2.h> |
44 | | # endif |
45 | | static inline int |
46 | | crypto_hash_sha512(unsigned char *out, const unsigned char *in, |
47 | | unsigned long long inlen) |
48 | | { |
49 | | |
50 | | SHA2_CTX ctx; |
51 | | |
52 | | SHA512Init(&ctx); |
53 | | SHA512Update(&ctx, in, inlen); |
54 | | SHA512Final(out, &ctx); |
55 | | return 0; |
56 | | } |
57 | | #endif /* WITH_OPENSSL */ |
58 | | |
59 | 3 | #define crypto_sign_ed25519_SECRETKEYBYTES 64U |
60 | 18 | #define crypto_sign_ed25519_PUBLICKEYBYTES 32U |
61 | 2.26k | #define crypto_sign_ed25519_BYTES 64U |
62 | | |
63 | | int crypto_sign_ed25519(unsigned char *, unsigned long long *, |
64 | | const unsigned char *, unsigned long long, const unsigned char *); |
65 | | int crypto_sign_ed25519_open(unsigned char *, unsigned long long *, |
66 | | const unsigned char *, unsigned long long, const unsigned char *); |
67 | | int crypto_sign_ed25519_keypair(unsigned char *, unsigned char *); |
68 | | |
69 | | #define crypto_kem_sntrup761_PUBLICKEYBYTES 1158 |
70 | | #define crypto_kem_sntrup761_SECRETKEYBYTES 1763 |
71 | | #define crypto_kem_sntrup761_CIPHERTEXTBYTES 1039 |
72 | | #define crypto_kem_sntrup761_BYTES 32 |
73 | | |
74 | | int crypto_kem_sntrup761_enc(unsigned char *cstr, unsigned char *k, |
75 | | const unsigned char *pk); |
76 | | int crypto_kem_sntrup761_dec(unsigned char *k, |
77 | | const unsigned char *cstr, const unsigned char *sk); |
78 | | int crypto_kem_sntrup761_keypair(unsigned char *pk, unsigned char *sk); |
79 | | |
80 | | #define crypto_kem_mlkem768_PUBLICKEYBYTES 1184 |
81 | | #define crypto_kem_mlkem768_SECRETKEYBYTES 2400 |
82 | | #define crypto_kem_mlkem768_CIPHERTEXTBYTES 1088 |
83 | | #define crypto_kem_mlkem768_BYTES 32 |
84 | | |
85 | | #endif /* crypto_api_h */ |