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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* Copyright (C) 2018 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* Copyright (C) 2018 René Korthaus
* Rohde & Schwarz Cybersecurity GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @defgroup botan_util botan_util
* @{ @ingroup botan_p
*/
#ifndef BOTAN_UTIL_H_
#define BOTAN_UTIL_H_
#include <library.h>
#include <botan/ffi.h>
/**
* Converts chunk_t to botan_mp_t.
*
* @param value chunk to convert
* @param mp allocated botan_mp_t
* @return TRUE if conversion successful
*/
bool chunk_to_botan_mp(chunk_t value, botan_mp_t *mp);
/**
* Get the Botan string identifier for the given hash algorithm.
*
* @param hash hash algorithm
* @return Botan string identifier, NULL if not found
*/
const char *botan_get_hash(hash_algorithm_t hash);
/**
* Get the encoding of a botan_pubkey_t.
*
* @param pubkey public key object
* @param type encoding type
* @param encoding allocated encoding
* @return TRUE if encoding successful
*/
bool botan_get_encoding(botan_pubkey_t pubkey, cred_encoding_type_t type,
chunk_t *encoding);
/**
* Get the encoding of a botan_privkey_t.
*
* @param key private key object
* @param type encoding type
* @param encoding allocated encoding
* @return TRUE if encoding successful
*/
bool botan_get_privkey_encoding(botan_privkey_t key, cred_encoding_type_t type,
chunk_t *encoding);
/**
* Get the fingerprint of a botan_pubkey_t.
*
* @param pubkey public key object
* @param cache key to use for caching, NULL to not cache
* @param type fingerprint type
* @param fp allocated fingerprint
* @return TRUE if fingerprinting successful
*/
bool botan_get_fingerprint(botan_pubkey_t pubkey, void *cache,
cred_encoding_type_t type, chunk_t *fp);
/**
* Sign the given data using the provided key with the specified signature
* scheme (hash/padding).
*
* @param key private key object
* @param scheme hash/padding algorithm
* @param data data to sign
* @param signature allocated signature
* @return TRUE if signature successfully created
*/
bool botan_get_signature(botan_privkey_t key, const char *scheme,
chunk_t data, chunk_t *signature);
/**
* Do the Diffie-Hellman key derivation using the given private key and public
* value.
*
* Note that the public value is not verified in this function.
*
* @param key DH private key
* @param pub other's public value
* @param secret the derived secret (allocated on success)
* @return TRUE if derivation was successful
*/
bool botan_dh_key_derivation(botan_privkey_t key, chunk_t pub, chunk_t *secret);
#endif /** BOTAN_UTIL_H_ @}*/
|