Annotation of embedaddon/strongswan/src/libstrongswan/plugins/botan/botan_util.h, revision 1.1.1.2
1.1 misho 1: /*
2: * Copyright (C) 2018 Tobias Brunner
3: * HSR Hochschule fuer Technik Rapperswil
4: *
5: * Copyright (C) 2018 René Korthaus
6: * Rohde & Schwarz Cybersecurity GmbH
7: *
8: * Permission is hereby granted, free of charge, to any person obtaining a copy
9: * of this software and associated documentation files (the "Software"), to deal
10: * in the Software without restriction, including without limitation the rights
11: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12: * copies of the Software, and to permit persons to whom the Software is
13: * furnished to do so, subject to the following conditions:
14: *
15: * The above copyright notice and this permission notice shall be included in
16: * all copies or substantial portions of the Software.
17: *
18: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24: * THE SOFTWARE.
25: */
26:
27: /**
28: * @defgroup botan_util botan_util
29: * @{ @ingroup botan_p
30: */
31:
32: #ifndef BOTAN_UTIL_H_
33: #define BOTAN_UTIL_H_
34:
35: #include <library.h>
36:
37: #include <botan/ffi.h>
38:
39: /**
40: * Converts chunk_t to botan_mp_t.
41: *
42: * @param value chunk to convert
43: * @param mp allocated botan_mp_t
44: * @return TRUE if conversion successful
45: */
46: bool chunk_to_botan_mp(chunk_t value, botan_mp_t *mp);
47:
48: /**
49: * Get the Botan string identifier for the given hash algorithm.
50: *
51: * @param hash hash algorithm
52: * @return Botan string identifier, NULL if not found
53: */
54: const char *botan_get_hash(hash_algorithm_t hash);
55:
56: /**
57: * Get the encoding of a botan_pubkey_t.
58: *
59: * @param pubkey public key object
60: * @param type encoding type
61: * @param encoding allocated encoding
62: * @return TRUE if encoding successful
63: */
64: bool botan_get_encoding(botan_pubkey_t pubkey, cred_encoding_type_t type,
65: chunk_t *encoding);
66:
67: /**
68: * Get the encoding of a botan_privkey_t.
69: *
70: * @param key private key object
71: * @param type encoding type
72: * @param encoding allocated encoding
73: * @return TRUE if encoding successful
74: */
75: bool botan_get_privkey_encoding(botan_privkey_t key, cred_encoding_type_t type,
76: chunk_t *encoding);
77:
78: /**
79: * Get the fingerprint of a botan_pubkey_t.
80: *
81: * @param pubkey public key object
82: * @param cache key to use for caching, NULL to not cache
83: * @param type fingerprint type
84: * @param fp allocated fingerprint
85: * @return TRUE if fingerprinting successful
86: */
87: bool botan_get_fingerprint(botan_pubkey_t pubkey, void *cache,
88: cred_encoding_type_t type, chunk_t *fp);
89:
90: /**
91: * Sign the given data using the provided key with the specified signature
92: * scheme (hash/padding).
93: *
94: * @param key private key object
95: * @param scheme hash/padding algorithm
96: * @param data data to sign
97: * @param signature allocated signature
98: * @return TRUE if signature successfully created
99: */
100: bool botan_get_signature(botan_privkey_t key, const char *scheme,
101: chunk_t data, chunk_t *signature);
102:
103: /**
104: * Verify the given signature using the provided data and key with the specified
105: * signature scheme (hash/padding).
106: *
107: * @param key private key object
108: * @param scheme hash/padding algorithm
109: * @param data signed data
110: * @param signature signature to verify
111: */
112: bool botan_verify_signature(botan_pubkey_t key, const char* scheme,
113: chunk_t data, chunk_t signature);
114:
115: /**
116: * Do the Diffie-Hellman key derivation using the given private key and public
117: * value.
118: *
119: * Note that the public value is not verified in this function.
120: *
121: * @param key DH private key
122: * @param pub other's public value
123: * @param secret the derived secret (allocated on success)
124: * @return TRUE if derivation was successful
125: */
126: bool botan_dh_key_derivation(botan_privkey_t key, chunk_t pub, chunk_t *secret);
127:
1.1.1.2 ! misho 128: /**
! 129: * Map the given RNG quality to a name as used by Botan.
! 130: *
! 131: * @param quality RNG quality
! 132: * @return name of the Botan RNG
! 133: */
! 134: const char *botan_map_rng_quality(rng_quality_t quality);
! 135:
! 136: /**
! 137: * Get RNG for Botan API calls.
! 138: *
! 139: * @param botan_rng Botan RNG
! 140: * @param quality RNG quality requested
! 141: * @return TRUE if Botan RNG creation was successful
! 142: */
! 143: bool botan_get_rng(botan_rng_t *botan_rng, rng_quality_t quality);
! 144:
1.1 misho 145: #endif /** BOTAN_UTIL_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>