Debian Codegraph @

src/lib/crypto/BotanUtil.h

raw
1 /*
2 * Copyright (c) 2010 .SE (The Internet Infrastructure Foundation)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 /*****************************************************************************
28 BotanUtil.h
29
30 Botan convenience functions
31 *****************************************************************************/
32
33 #ifndef _SOFTHSM_V2_BOTANUTIL_H
34 #define _SOFTHSM_V2_BOTANUTIL_H
35
36 #include "config.h"
37 #include "ByteString.h"
38 #include <botan/bigint.h>
39 #include <botan/asn1_obj.h>
40 #include <botan/oids.h>
41 #if defined(WITH_ECC) || defined(WITH_GOST)
42 #include <botan/ec_group.h>
43 #endif
44
45 namespace BotanUtil
46 {
47 const Botan::OID x25519_oid("1.3.101.110");
48 // const Botan::OID x448_oid("1.3.101.111");
49 const Botan::OID ed25519_oid("1.3.101.112");
50 // const Botan::OID ed448_oid("1.3.101.113");
51
52 // Convert a Botan BigInt to a ByteString
53 ByteString bigInt2ByteString(const Botan::BigInt& bigInt);
54 ByteString bigInt2ByteStringPrefix(const Botan::BigInt& bigInt, size_t size);
55
56 // Convert a ByteString to a Botan BigInt
57 Botan::BigInt byteString2bigInt(const ByteString& byteString);
58
59 #if defined(WITH_ECC) || defined(WITH_GOST)
60 // Convert a Botan EC group to a ByteString
61 ByteString ecGroup2ByteString(const Botan::EC_Group& ecGroup);
62
63 // Convert a ByteString to a Botan EC group
64 Botan::EC_Group byteString2ECGroup(const ByteString& byteString);
65
66 // Convert a Botan EC point to a ByteString
67 ByteString ecPoint2ByteString(const Botan::PointGFp& ecPoint);
68
69 // Convert a ByteString to a Botan EC point in the given EC group
70 Botan::PointGFp byteString2ECPoint(const ByteString& byteString, const Botan::EC_Group& ecGroup);
71 #endif
72 #ifdef WITH_EDDSA
73 // Convert a Botan OID to a ByteString
74 ByteString oid2ByteString(const Botan::OID& oid);
75
76 // Convert a ByteString to a Botan OID
77 Botan::OID byteString2Oid(const ByteString& byteString);
78 #endif
79 }
80
81 #endif // !_SOFTHSM_V2_BOTANUTIL_H
82