├── .gitignore
├── LICENSE.md
├── Makefile.am
├── README.md
├── autogen.sh
├── configure.ac
├── m4
└── placeholder.txt
└── src
├── Makefile.am
├── p11
├── Makefile.am
├── enclave_config
│ ├── p11Enclave.config.xml
│ ├── p11Enclave.edl
│ └── p11Enclave_private.pem
├── trusted
│ ├── Makefile.am
│ ├── SoftHSMv2
│ │ ├── CMakeLists.txt
│ │ ├── EnclaveSecureUtils.cpp
│ │ ├── EnclaveSecureUtils.h
│ │ ├── Makefile.am
│ │ ├── P11Attributes.cpp
│ │ ├── P11Attributes.h
│ │ ├── P11Objects.cpp
│ │ ├── P11Objects.h
│ │ ├── SoftHSM.cpp
│ │ ├── SoftHSM.h
│ │ ├── access.cpp
│ │ ├── access.h
│ │ ├── common
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Configuration.cpp
│ │ │ ├── Configuration.h
│ │ │ ├── HandleFactory.h
│ │ │ ├── Makefile.am
│ │ │ ├── MutexFactory.cpp
│ │ │ ├── MutexFactory.h
│ │ │ ├── QuoteGeneration.h
│ │ │ ├── QuoteGenerationDefs.h
│ │ │ ├── Serialisable.h
│ │ │ ├── SimpleConfigLoader.cpp
│ │ │ ├── SimpleConfigLoader.h
│ │ │ ├── cryptoki.h
│ │ │ ├── fatal.cpp
│ │ │ ├── fatal.h
│ │ │ ├── libp11sgx.h
│ │ │ ├── osmutex.cpp
│ │ │ └── osmutex.h
│ │ ├── crypto
│ │ │ ├── AESKey.cpp
│ │ │ ├── AESKey.h
│ │ │ ├── AsymmetricAlgorithm.cpp
│ │ │ ├── AsymmetricAlgorithm.h
│ │ │ ├── AsymmetricKeyPair.cpp
│ │ │ ├── AsymmetricKeyPair.h
│ │ │ ├── AsymmetricParameters.h
│ │ │ ├── CMakeLists.txt
│ │ │ ├── CryptoFactory.cpp
│ │ │ ├── CryptoFactory.h
│ │ │ ├── DESKey.cpp
│ │ │ ├── DESKey.h
│ │ │ ├── DHParameters.cpp
│ │ │ ├── DHParameters.h
│ │ │ ├── DHPrivateKey.cpp
│ │ │ ├── DHPrivateKey.h
│ │ │ ├── DHPublicKey.cpp
│ │ │ ├── DHPublicKey.h
│ │ │ ├── DSAParameters.cpp
│ │ │ ├── DSAParameters.h
│ │ │ ├── DSAPrivateKey.cpp
│ │ │ ├── DSAPrivateKey.h
│ │ │ ├── DSAPublicKey.cpp
│ │ │ ├── DSAPublicKey.h
│ │ │ ├── DerUtil.cpp
│ │ │ ├── DerUtil.h
│ │ │ ├── ECParameters.cpp
│ │ │ ├── ECParameters.h
│ │ │ ├── ECPrivateKey.cpp
│ │ │ ├── ECPrivateKey.h
│ │ │ ├── ECPublicKey.cpp
│ │ │ ├── ECPublicKey.h
│ │ │ ├── EDPrivateKey.cpp
│ │ │ ├── EDPrivateKey.h
│ │ │ ├── EDPublicKey.cpp
│ │ │ ├── EDPublicKey.h
│ │ │ ├── GOSTPrivateKey.cpp
│ │ │ ├── GOSTPrivateKey.h
│ │ │ ├── GOSTPublicKey.cpp
│ │ │ ├── GOSTPublicKey.h
│ │ │ ├── HashAlgorithm.cpp
│ │ │ ├── HashAlgorithm.h
│ │ │ ├── MacAlgorithm.cpp
│ │ │ ├── MacAlgorithm.h
│ │ │ ├── Makefile.am
│ │ │ ├── OSSLAES.cpp
│ │ │ ├── OSSLAES.h
│ │ │ ├── OSSLCMAC.cpp
│ │ │ ├── OSSLCMAC.h
│ │ │ ├── OSSLComp.cpp
│ │ │ ├── OSSLComp.h
│ │ │ ├── OSSLCryptoFactory.cpp
│ │ │ ├── OSSLCryptoFactory.h
│ │ │ ├── OSSLDES.cpp
│ │ │ ├── OSSLDES.h
│ │ │ ├── OSSLDH.cpp
│ │ │ ├── OSSLDH.h
│ │ │ ├── OSSLDHKeyPair.cpp
│ │ │ ├── OSSLDHKeyPair.h
│ │ │ ├── OSSLDHPrivateKey.cpp
│ │ │ ├── OSSLDHPrivateKey.h
│ │ │ ├── OSSLDHPublicKey.cpp
│ │ │ ├── OSSLDHPublicKey.h
│ │ │ ├── OSSLDSA.cpp
│ │ │ ├── OSSLDSA.h
│ │ │ ├── OSSLDSAKeyPair.cpp
│ │ │ ├── OSSLDSAKeyPair.h
│ │ │ ├── OSSLDSAPrivateKey.cpp
│ │ │ ├── OSSLDSAPrivateKey.h
│ │ │ ├── OSSLDSAPublicKey.cpp
│ │ │ ├── OSSLDSAPublicKey.h
│ │ │ ├── OSSLECDH.cpp
│ │ │ ├── OSSLECDH.h
│ │ │ ├── OSSLECDSA.cpp
│ │ │ ├── OSSLECDSA.h
│ │ │ ├── OSSLECKeyPair.cpp
│ │ │ ├── OSSLECKeyPair.h
│ │ │ ├── OSSLECPrivateKey.cpp
│ │ │ ├── OSSLECPrivateKey.h
│ │ │ ├── OSSLECPublicKey.cpp
│ │ │ ├── OSSLECPublicKey.h
│ │ │ ├── OSSLEDDSA.cpp
│ │ │ ├── OSSLEDDSA.h
│ │ │ ├── OSSLEDKeyPair.cpp
│ │ │ ├── OSSLEDKeyPair.h
│ │ │ ├── OSSLEDPrivateKey.cpp
│ │ │ ├── OSSLEDPrivateKey.h
│ │ │ ├── OSSLEDPublicKey.cpp
│ │ │ ├── OSSLEDPublicKey.h
│ │ │ ├── OSSLEVPCMacAlgorithm.cpp
│ │ │ ├── OSSLEVPCMacAlgorithm.h
│ │ │ ├── OSSLEVPHashAlgorithm.cpp
│ │ │ ├── OSSLEVPHashAlgorithm.h
│ │ │ ├── OSSLEVPMacAlgorithm.cpp
│ │ │ ├── OSSLEVPMacAlgorithm.h
│ │ │ ├── OSSLEVPSymmetricAlgorithm.cpp
│ │ │ ├── OSSLEVPSymmetricAlgorithm.h
│ │ │ ├── OSSLGOST.cpp
│ │ │ ├── OSSLGOST.h
│ │ │ ├── OSSLGOSTKeyPair.cpp
│ │ │ ├── OSSLGOSTKeyPair.h
│ │ │ ├── OSSLGOSTPrivateKey.cpp
│ │ │ ├── OSSLGOSTPrivateKey.h
│ │ │ ├── OSSLGOSTPublicKey.cpp
│ │ │ ├── OSSLGOSTPublicKey.h
│ │ │ ├── OSSLGOSTR3411.cpp
│ │ │ ├── OSSLGOSTR3411.h
│ │ │ ├── OSSLHMAC.cpp
│ │ │ ├── OSSLHMAC.h
│ │ │ ├── OSSLMD5.cpp
│ │ │ ├── OSSLMD5.h
│ │ │ ├── OSSLRNG.cpp
│ │ │ ├── OSSLRNG.h
│ │ │ ├── OSSLRSA.cpp
│ │ │ ├── OSSLRSA.h
│ │ │ ├── OSSLRSAKeyPair.cpp
│ │ │ ├── OSSLRSAKeyPair.h
│ │ │ ├── OSSLRSAPrivateKey.cpp
│ │ │ ├── OSSLRSAPrivateKey.h
│ │ │ ├── OSSLRSAPublicKey.cpp
│ │ │ ├── OSSLRSAPublicKey.h
│ │ │ ├── OSSLSHA1.cpp
│ │ │ ├── OSSLSHA1.h
│ │ │ ├── OSSLSHA224.cpp
│ │ │ ├── OSSLSHA224.h
│ │ │ ├── OSSLSHA256.cpp
│ │ │ ├── OSSLSHA256.h
│ │ │ ├── OSSLSHA384.cpp
│ │ │ ├── OSSLSHA384.h
│ │ │ ├── OSSLSHA512.cpp
│ │ │ ├── OSSLSHA512.h
│ │ │ ├── OSSLUtil.cpp
│ │ │ ├── OSSLUtil.h
│ │ │ ├── PrivateKey.h
│ │ │ ├── PublicKey.h
│ │ │ ├── RNG.h
│ │ │ ├── RSAParameters.cpp
│ │ │ ├── RSAParameters.h
│ │ │ ├── RSAPrivateKey.cpp
│ │ │ ├── RSAPrivateKey.h
│ │ │ ├── RSAPublicKey.cpp
│ │ │ ├── RSAPublicKey.h
│ │ │ ├── SymmetricAlgorithm.cpp
│ │ │ ├── SymmetricAlgorithm.h
│ │ │ ├── SymmetricKey.cpp
│ │ │ ├── SymmetricKey.h
│ │ │ └── odd.h
│ │ ├── data_mgr
│ │ │ ├── ByteString.cpp
│ │ │ ├── ByteString.h
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Makefile.am
│ │ │ ├── RFC4880.cpp
│ │ │ ├── RFC4880.h
│ │ │ ├── SecureAllocator.h
│ │ │ ├── SecureDataManager.cpp
│ │ │ ├── SecureDataManager.h
│ │ │ ├── SecureMemoryRegistry.cpp
│ │ │ └── SecureMemoryRegistry.h
│ │ ├── handle_mgr
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Handle.cpp
│ │ │ ├── Handle.h
│ │ │ ├── HandleManager.cpp
│ │ │ ├── HandleManager.h
│ │ │ └── Makefile.am
│ │ ├── main.cpp
│ │ ├── main.h
│ │ ├── object_store
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Directory.cpp
│ │ │ ├── Directory.h
│ │ │ ├── File.cpp
│ │ │ ├── File.h
│ │ │ ├── FindOperation.cpp
│ │ │ ├── FindOperation.h
│ │ │ ├── Generation.cpp
│ │ │ ├── Generation.h
│ │ │ ├── Makefile.am
│ │ │ ├── OSAttribute.cpp
│ │ │ ├── OSAttribute.h
│ │ │ ├── OSAttributes.h
│ │ │ ├── OSObject.h
│ │ │ ├── OSPathSep.h
│ │ │ ├── OSToken.cpp
│ │ │ ├── OSToken.h
│ │ │ ├── ObjectFile.cpp
│ │ │ ├── ObjectFile.h
│ │ │ ├── ObjectStore.cpp
│ │ │ ├── ObjectStore.h
│ │ │ ├── ObjectStoreToken.cpp
│ │ │ ├── ObjectStoreToken.h
│ │ │ ├── SessionObject.cpp
│ │ │ ├── SessionObject.h
│ │ │ ├── SessionObjectStore.cpp
│ │ │ ├── SessionObjectStore.h
│ │ │ ├── UUID.cpp
│ │ │ └── UUID.h
│ │ ├── pkcs11
│ │ │ ├── pkcs11.h
│ │ │ ├── pkcs11f.h
│ │ │ └── pkcs11t.h
│ │ ├── session_mgr
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Makefile.am
│ │ │ ├── Session.cpp
│ │ │ ├── Session.h
│ │ │ ├── SessionManager.cpp
│ │ │ └── SessionManager.h
│ │ └── slot_mgr
│ │ │ ├── CMakeLists.txt
│ │ │ ├── Makefile.am
│ │ │ ├── Slot.cpp
│ │ │ ├── Slot.h
│ │ │ ├── SlotManager.cpp
│ │ │ ├── SlotManager.h
│ │ │ ├── Token.cpp
│ │ │ └── Token.h
│ ├── e_pkcs11t.h
│ └── p11Enclave.cpp
└── untrusted
│ ├── Decryption.cpp
│ ├── Decryption.h
│ ├── Digest.cpp
│ ├── Digest.h
│ ├── Directory.cpp
│ ├── Directory.h
│ ├── DualFunctionCryptoFunctions.cpp
│ ├── DualFunctionCryptoFunctions.h
│ ├── EnclaveHelpers.cpp
│ ├── EnclaveHelpers.h
│ ├── EnclaveInterface.cpp
│ ├── EnclaveInterface.h
│ ├── Encryption.cpp
│ ├── Encryption.h
│ ├── GPFunctions.cpp
│ ├── GPFunctions.h
│ ├── KeyManagement.cpp
│ ├── KeyManagement.h
│ ├── Makefile.am
│ ├── ObjectManagement.cpp
│ ├── ObjectManagement.h
│ ├── P11Provider.cpp
│ ├── P11Provider.h
│ ├── Parallel.cpp
│ ├── Parallel.h
│ ├── QuoteGeneration.cpp
│ ├── RNG.cpp
│ ├── RNG.h
│ ├── SessionManagement.cpp
│ ├── SessionManagement.h
│ ├── SignAndMAC.cpp
│ ├── SignAndMAC.h
│ ├── SimpleConfigLoader.cpp
│ ├── SimpleConfigLoader.h
│ ├── SlotTokenManagement.cpp
│ ├── SlotTokenManagement.h
│ ├── Verify.cpp
│ ├── Verify.h
│ ├── p11Sgx.cpp
│ └── p11Sgx.h
└── test
├── AsymEncryptDecryptTests.cpp
├── AsymEncryptDecryptTests.h
├── AsymWrapUnwrapTests.cpp
├── AsymWrapUnwrapTests.h
├── CMakeLists.txt
├── DeriveTests.cpp
├── DeriveTests.h
├── DigestTests.cpp
├── DigestTests.h
├── InfoTests.cpp
├── InfoTests.h
├── InitTests.cpp
├── InitTests.h
├── Makefile.am
├── ObjectTests.cpp
├── ObjectTests.h
├── README
├── RandomTests.cpp
├── RandomTests.h
├── SessionTests.cpp
├── SessionTests.h
├── SignVerifyTests.cpp
├── SignVerifyTests.h
├── SymmetricAlgorithmTests.cpp
├── SymmetricAlgorithmTests.h
├── TestsBase.cpp
├── TestsBase.h
├── TestsNoPINInitBase.cpp
├── TestsNoPINInitBase.h
├── TokenTests.cpp
├── TokenTests.h
├── UnsupportedAPITests.cpp
├── UnsupportedAPITests.h
├── UnwrapKeyHelper.cpp
├── UnwrapKeyHelper.h
├── UserTests.cpp
├── UserTests.h
├── p11test.cpp
├── softhsm2-alt.conf
├── softhsm2-alt.conf.win32
├── softhsm2-mech.conf
├── softhsm2-mech.conf.win32
├── softhsm2.conf
├── softhsm2.conf.win32
└── tokens
├── 2b371574-9ba7-f72c-12e4-fb4f8b69a8e
├── generation
├── token.lock
└── token.object
└── dummy
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.deps
3 | *.libs
4 | *.in
5 | *.la
6 | *.lo
7 | *.m4
8 | **/build-aux
9 | **/autom4te.cache
10 | config.status
11 | config.h.in*
12 | config.log
13 | config.h
14 | *_t.h
15 | *_t.c
16 | *_u.h
17 | *_u.c
18 | libtool
19 | Makefile
20 | configure
21 | stamp-h1
22 | p11test
23 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2019-2020 Intel Corporation. All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without
5 | # modification, are permitted provided that the following conditions
6 | # are met:
7 | #
8 | # * Redistributions of source code must retain the above copyright
9 | # notice, this list of conditions and the following disclaimer.
10 | # * Redistributions in binary form must reproduce the above copyright
11 | # notice, this list of conditions and the following disclaimer in
12 | # the documentation and/or other materials provided with the
13 | # distribution.
14 | # * Neither the name of Intel Corporation nor the names of its
15 | # contributors may be used to endorse or promote products derived
16 | # from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | #
30 | #
31 |
32 | ACLOCAL_AMFLAGS = -I m4
33 |
34 | EXTRA_DIST = $(srcdir)/src/p11/trusted/SoftHSMv2/pkcs11/cryptoki.h \
35 | $(srcdir)/src/p11/trusted/SoftHSMv2/pkcs11/pkcs11.h \
36 | $(srcdir)/src/p11/trusted/SoftHSMv2/pkcs11/pkcs11f.h \
37 | $(srcdir)/src/p11/trusted/SoftHSMv2/pkcs11/pkcs11t.h \
38 | $(srcdir)/src/p11/enclave_config/p11Enclave.config.xml \
39 | $(srcdir)/src/p11/enclave_config/p11Enclave.edl \
40 | $(srcdir)/src/p11/enclave_config/p11Enclave_private.pem \
41 | $(srcdir)/autogen.sh
42 |
43 | dist-hook:
44 | rm -f $(distdir)/src/p11/trusted/p11Enclave_t*
45 | rm -f $(distdir)/src/p11/untrusted/p11Enclave_u*
46 |
47 | SUBDIRS = src
48 |
49 | install-exec-local:
50 | mkdir -p $(CATKTOKENPATH)/tokens
51 | chmod -R 1777 $(CATKTOKENPATH)/tokens
52 | mkdir -p $(prefix)/include
53 | chmod -R 1777 $(prefix)/include
54 | cp $(srcdir)/src/p11/trusted/SoftHSMv2/common/QuoteGeneration.h $(srcdir)/src/p11/trusted/SoftHSMv2/common/cryptoki.h $(srcdir)/src/p11/trusted/SoftHSMv2/common/QuoteGenerationDefs.h $(srcdir)/src/p11/trusted/SoftHSMv2/common/libp11sgx.h $(prefix)/include
55 |
56 | if !WITH_P11_KIT
57 | cp $(srcdir)/src/p11/trusted/SoftHSMv2/pkcs11/* $(prefix)/include
58 | endif
59 |
--------------------------------------------------------------------------------
/autogen.sh:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2019-2020 Intel Corporation. All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without
5 | # modification, are permitted provided that the following conditions
6 | # are met:
7 | #
8 | # * Redistributions of source code must retain the above copyright
9 | # notice, this list of conditions and the following disclaimer.
10 | # * Redistributions in binary form must reproduce the above copyright
11 | # notice, this list of conditions and the following disclaimer in
12 | # the documentation and/or other materials provided with the
13 | # distribution.
14 | # * Neither the name of Intel Corporation nor the names of its
15 | # contributors may be used to endorse or promote products derived
16 | # from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | #
30 | #
31 |
32 | autoreconf -fi
33 |
--------------------------------------------------------------------------------
/m4/placeholder.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/crypto-api-toolkit/c50cf7dc0714966f2a837a6bbc0d66551c6b788f/m4/placeholder.txt
--------------------------------------------------------------------------------
/src/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2019-2020 Intel Corporation. All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without
5 | # modification, are permitted provided that the following conditions
6 | # are met:
7 | #
8 | # * Redistributions of source code must retain the above copyright
9 | # notice, this list of conditions and the following disclaimer.
10 | # * Redistributions in binary form must reproduce the above copyright
11 | # notice, this list of conditions and the following disclaimer in
12 | # the documentation and/or other materials provided with the
13 | # distribution.
14 | # * Neither the name of Intel Corporation nor the names of its
15 | # contributors may be used to endorse or promote products derived
16 | # from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | #
30 | #
31 |
32 | SUBDIRS = p11 test
33 |
--------------------------------------------------------------------------------
/src/p11/Makefile.am:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (C) 2019-2020 Intel Corporation. All rights reserved.
3 | #
4 | # Redistribution and use in source and binary forms, with or without
5 | # modification, are permitted provided that the following conditions
6 | # are met:
7 | #
8 | # * Redistributions of source code must retain the above copyright
9 | # notice, this list of conditions and the following disclaimer.
10 | # * Redistributions in binary form must reproduce the above copyright
11 | # notice, this list of conditions and the following disclaimer in
12 | # the documentation and/or other materials provided with the
13 | # distribution.
14 | # * Neither the name of Intel Corporation nor the names of its
15 | # contributors may be used to endorse or promote products derived
16 | # from this software without specific prior written permission.
17 | #
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | #
30 | #
31 |
32 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
33 |
34 | EXTRA_DIST = $(srcdir)/enclave_config/*.pem \
35 | $(srcdir)/enclave_config/*.edl \
36 | $(srcdir)/enclave_config/*.xml
37 |
38 | AM_CPPFLAGS = -I$(srcdir)/enclave_config
39 | SUBDIRS = untrusted trusted
40 |
--------------------------------------------------------------------------------
/src/p11/enclave_config/p11Enclave.config.xml:
--------------------------------------------------------------------------------
1 |
30 |
31 |
32 | 0
33 | 1
34 | 0x40000
35 | 0xA00000
36 | 1
37 | 1
38 | 0
39 | 0
40 | 0xFFFFFFFF
41 |
42 |
--------------------------------------------------------------------------------
/src/p11/enclave_config/p11Enclave_private.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIG5AIBAAKCAYEA77bFOo3SNYa1h9cQKrH59WX02Z/zWEDw5ar9e+zQbYSshJx0
3 | vP/k3jrurJjECNlQ4mtlu4/VbPUMsHssGNH4ueBpkVP19xqztNweBnuFCZwBRmnE
4 | Gedc7/nHvUZRHDcqxwNbfdWJQ2GwJUvD4u1/eLUEz6xfmyvdHQ+6FGRXHg+fSGGI
5 | 0UW2UF5dcX5yV65cO5fkXIH3ff/kLY836814OSSnVkOy+FlZOqtrRUvocn8gl+Il
6 | t/vW+WQbHzzzVb3XU6HPKt2ee7WB6sF7AEaxfWSIb63Xi/uSZSugEsbD0utk4MH0
7 | sY4o1HtDTPiojSwXlh25MkjFC1br6jGR4dSvHpjdxIXlO7w4cR6VbD0UWK6eaToo
8 | szI4NpKJwntBLS+RbYYeFahLj1QuWaZzwdELyscmmVmh4jCvD2fDPH8IYcNWXiZs
9 | MvMwE95gf0dH9OyJfN0TQQYxHlwLuKvHFlhs9ySkkFGAEnLOrYwpx6mHvjA/dTgS
10 | Z52yy4nmnuURP/qfAgEDAoIBgQCfzy4nCTbOWc5aj2AcdqajmU3maqI61fXucf5S
11 | neBJAx2tvaMoqpiUJ0nIZdgF5jXsR5kntTjzTgh1p3K7NqXRQEZg4qP6Ec0jPWlZ
12 | p64GaADZm9gRROif+9p+LuC9ehyErOepOQYs68rDh9fsnlT7I1iKcupncpNotSa4
13 | QuS+tRTa67CLg87gPuj2VEw6dD19D+2TAU+pVULJCiVH3lAmGG+O18ylkOYnHPIu
14 | Mpr2/2sP7BklUo9Q7WdqKKI5KTjtb2TCmnv55IHS5KEr+fhsIhgPbTnRxfd8g3YG
15 | W8rYrRpyEhxYdUmRt0/FGr5y6D0SsE5Gk2AbLaLYXBTNO7n8OFxK6KuKUqNQ1bn5
16 | Aob/OLyE2/e9dhY2thU6Y/P4q//T2YSrYAlhUbjz019UrEQndRPoigrzQbxYZ2YX
17 | VFd2B1TnLUkchaFR94f9CymvHTyqbguAdgW4EKisQQPX1zIAMTq3h8WE5nx+8Di8
18 | GUcU2V7NEoAc3d1wD+km8WBlIQsCgcEA+pmXqNsQRuwNLimui8Ic1FhcHyY5ktwt
19 | 7466Q9CRIECXc+iEf60E9C/s+zylN0lsVjsKGTJ3VqXriWZnch8+lpYvZlKoXRiF
20 | w9jIpizX5CvfOv5/p6rCzOs5iItMghB16VCRItCaO+PH04IJIsSo/+XjnnZ90Ybk
21 | 6dS9gf/1Zt8FEVX4YAdX+Tj8wgXODOwbZRRh0HHoReULz17FNiTnuGQq32H9m01z
22 | oc1uDtv3sbRFJCWjYKbaNmxpztQART7ZAoHBAPThIF4a1D3ysgBA2rKNoAbZCDlj
23 | xz52cTrXtMVsgm2nJcG+Ra0xNYW4XqoT5amGT6PaOa85PYvsjBxBCzvb2Y2uI+3W
24 | O48nvbQFNdCMcfWtpGbxtW9WVBeWMGJaBrYdG8ZvRfHHo0F10RhnW6AJ/I+xpR4U
25 | E6PHL6D37JeAj8nZUfIMhigjZh+yF8Gwu2FUkxgjoC/jQEReAubrfBxwuj52oZ2j
26 | 2i/LoE1WZp6npW017B12rtuqDG0FnxWnAGMKNwKBwQCnEQ/F52AvSAjJcR8H1r3i
27 | 5ZK/btEMkslKXybX4GDAKw+imwL/yK34H/NSKG4k252O0ga7dvo5w/JbmZpMFNRk
28 | ZB+ZjHA+EFktOzBuyI/tcpTR/v/FHIHd8iZbB4hWtaPw4GDB4GbSl9qNAVtsgxtV
29 | Q+0UTv6Lr0NGjdOr//jvP1i2OVBABOVQ0KiBWTQInWeYuEE1oUWD7gfflIN5be/Q
30 | Qsc/lqkSM6Jr3klfPU/LzYNtbmzrGebO8vE0jVWDfzsCgcEAo0DAPryNfqHMACs8
31 | dwkVWeYFe5faKaRLfI/N2PMBnm9ugSmDyMt5A9A/HA1DxlmKbTwmdNDTsp2yvYCy
32 | J+fmXnQX8+QntMUpIq4j4F2hTnPC70vOSjmNZQ7K7DwEeWi9LvTZS9ps1k6LZZo9
33 | FVv9tSEYvrgNF9ofwKVIZQBf2+Y2oV2uxWzuv8wP1nXSQOMMusJqypeALZQB70eo
34 | EvXRfvnBE8KRdTJq3jmZvxpuSM6daPnJ58ay81kUuRoAQgbPAoHBAN3Sj+YOiitA
35 | Sy/DA53n/jTNr21d5X+iMofVz57y2UZLVFYesK22MmiDWtESKBGwTivzEd2Apo4Z
36 | dQsf8h1OH/dRS1c6rn6aWBtQzKG7mFxt2X0mAHqs9ksHIoqUfT/3+6NVA/wmdvY+
37 | UbDL/ghVpDJHyllHXAsGRy1Y6SqvcUcivIXFT6sDWFKMnhP2UFNdiqXONoe2rE3h
38 | 5E22gJLRg0srPhwxztC+1BrCoEmadiq+7PGjaXwAk1b1SYqVUBnAew==
39 | -----END RSA PRIVATE KEY-----
40 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/EnclaveSecureUtils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #ifndef ENCLAVE_SECURE_UTILS_H__
33 | #define ENCLAVE_SECURE_UTILS_H__
34 |
35 | #include
36 | #include
37 |
38 | #include "cryptoki.h"
39 |
40 | bool validate_user_check_ptr(const void* ptr, const size_t length);
41 | bool is_inside_enclave(const void* ptr, const size_t length);
42 | bool validate_user_check_mechanism_ptr(const CK_MECHANISM_PTR pMechanism, const CK_ULONG ulCount);
43 | bool validate_user_check_attribute_ptr(const CK_ATTRIBUTE_PTR pTemplate, const CK_ULONG ulCount);
44 | bool is_outside_enclave(const void* ptr, const size_t length);
45 |
46 | #endif // ENCLAVESECUREUTILS_H__
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/common \
4 | -I$(srcdir)/crypto \
5 | -I$(srcdir)/data_mgr \
6 | -I$(srcdir)/handle_mgr \
7 | -I$(srcdir)/object_store \
8 | -I$(srcdir)/session_mgr \
9 | -I$(srcdir)/slot_mgr \
10 | -I$(srcdir)/.. \
11 | -I$(builddir)/.. \
12 | -I$(srcdir)/../../../../ \
13 | -I$(SGXSSLDIR)/include \
14 | -I$(SGXSDKDIR)/include \
15 | -I$(SGXSDKDIR)/include/tlibc \
16 | -I$(SGXSDKDIR)/include/libcxx \
17 | -I$(SGXSDKDIR)/include/stdc++ \
18 | -I$(SGXSDKDIR)/include/stlport
19 |
20 | if WITH_P11_KIT
21 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
22 | else
23 | AM_CPPFLAGS += -I$(srcdir)/pkcs11
24 | endif
25 |
26 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
27 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
28 |
29 | noinst_LTLIBRARIES = libsofthsm2.la
30 |
31 | libsofthsm2_la_SOURCES = access.cpp \
32 | main.cpp \
33 | P11Attributes.cpp \
34 | P11Objects.cpp \
35 | EnclaveSecureUtils.cpp \
36 | SoftHSM.cpp
37 |
38 | libsofthsm2_la_LIBADD = common/libsofthsm_common.la \
39 | crypto/libsofthsm_crypto.la \
40 | data_mgr/libsofthsm_datamgr.la \
41 | handle_mgr/libsofthsm_handlemgr.la \
42 | object_store/libsofthsm_objectstore.la \
43 | session_mgr/libsofthsm_sessionmgr.la \
44 | slot_mgr/libsofthsm_slotmgr.la
45 |
46 | SUBDIRS = common \
47 | crypto \
48 | data_mgr \
49 | object_store \
50 | session_mgr \
51 | slot_mgr \
52 | handle_mgr
53 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/access.h:
--------------------------------------------------------------------------------
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 | access.h
29 |
30 | Implements the access rules.
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_ACCESS_H
34 | #define _SOFTHSM_V2_ACCESS_H
35 |
36 | #include "cryptoki.h"
37 |
38 | CK_RV haveRead(CK_STATE sessionState, CK_BBOOL isTokenObject, CK_BBOOL isPrivateObject);
39 | CK_RV haveWrite(CK_STATE sessionState, CK_BBOOL isTokenObject, CK_BBOOL isPrivateObject);
40 |
41 | #endif /* !_SOFTHSM_V2_ACCESS_H */
42 |
43 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(softhsm_common)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/../crypto
5 | ${PROJECT_SOURCE_DIR}/../data_mgr
6 | ${PROJECT_SOURCE_DIR}/../pkcs11
7 | )
8 |
9 | set(SOURCES Configuration.cpp
10 | fatal.cpp
11 | log.cpp
12 | MutexFactory.cpp
13 | osmutex.cpp
14 | SimpleConfigLoader.cpp
15 | )
16 |
17 | include_directories(${INCLUDE_DIRS})
18 |
19 | add_library(${PROJECT_NAME} OBJECT ${SOURCES})
20 |
21 | set(softhsmtokendir ${DEFAULT_TOKENDIR})
22 | set(default_softhsm2_conf ${CMAKE_INSTALL_FULL_SYSCONFDIR}/softhsm2.conf)
23 | configure_file(softhsm2.conf.in ${PROJECT_BINARY_DIR}/etc/softhsm2.conf)
24 | configure_file(softhsm2.conf.in ${PROJECT_BINARY_DIR}/etc/softhsm2.conf.sample)
25 | configure_file(softhsm2.conf.5.in ${PROJECT_BINARY_DIR}/man5/softhsm2.conf.5)
26 |
27 | install(CODE "
28 | if(NOT EXISTS ${CMAKE_INSTALL_SYSCONFDIR}/softhsm2.conf)
29 | file(INSTALL ${PROJECT_BINARY_DIR}/etc/softhsm2.conf
30 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
31 | endif()
32 | ")
33 |
34 | install(FILES ${PROJECT_BINARY_DIR}/etc/softhsm2.conf.sample
35 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
36 | )
37 |
38 | install(FILES ${PROJECT_BINARY_DIR}/man5/softhsm2.conf.5
39 | DESTINATION ${CMAKE_INSTALL_MANDIR}/man5
40 | )
41 |
42 | install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib/softhsm/tokens)
43 |
44 | install(CODE
45 | "execute_process(
46 | COMMAND chmod 1777 ${CMAKE_INSTALL_LOCALSTATEDIR}/lib/softhsm/tokens)")
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/.. \
4 | -I$(srcdir)/../crypto \
5 | -I$(srcdir)/../data_mgr \
6 | -I$(srcdir)/../.. \
7 | -I$(SGXSDKDIR)/include \
8 | -I$(SGXSDKDIR)/include/tlibc \
9 | -I$(SGXSDKDIR)/include/libcxx \
10 | -I$(SGXSDKDIR)/include/stdc++ \
11 | -I$(SGXSDKDIR)/include/stlport
12 |
13 | if WITH_P11_KIT
14 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
15 | else
16 | AM_CPPFLAGS += -I$(srcdir)/../pkcs11
17 | endif
18 |
19 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
20 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
21 |
22 | noinst_LTLIBRARIES = libsofthsm_common.la
23 | libsofthsm_common_la_SOURCES = Configuration.cpp \
24 | fatal.cpp \
25 | osmutex.cpp \
26 | MutexFactory.cpp
27 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/QuoteGeneration.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | /*****************************************************************************
33 | QuoteGeneration.h
34 |
35 | This file contains structures for quote generation
36 | *****************************************************************************/
37 | #ifndef _QUOTEGENERATION_H
38 | #define _QUOTEGENERATION_H
39 |
40 | #include "QuoteGenerationDefs.h"
41 |
42 | #include
43 | #include
44 | #include
45 |
46 | typedef struct CK_RSA_PUBLIC_KEY_PARAMS {
47 | CK_ULONG ulExponentLen;
48 | CK_ULONG ulModulusLen;
49 | } CK_RSA_PUBLIC_KEY_PARAMS;
50 |
51 | typedef struct CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS {
52 | CK_LONG qlPolicy;
53 | CK_BYTE nonce[NONCE_LENGTH];
54 | } CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS;
55 |
56 | typedef CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS* CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS_PTR;
57 |
58 | typedef struct CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS_INTERNAL {
59 | sgx_target_info_t targetInfo;
60 | uint32_t quoteLength;
61 | CK_BYTE nonce[NONCE_LENGTH];
62 | } CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS_INTERNAL;
63 |
64 | typedef CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS_INTERNAL* CK_ECDSA_QUOTE_RSA_PUBLIC_KEY_PARAMS_INTERNAL_PTR;
65 |
66 | #endif // !_QUOTEGENERATION_H
67 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/QuoteGenerationDefs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | /*****************************************************************************
33 | QuoteGenerationDefs.h
34 |
35 | This file contains Definition for quote generation
36 | *****************************************************************************/
37 | #ifndef _QUOTEGENERATIONDEFS_H
38 | #define _QUOTEGENERATIONDEFS_H
39 |
40 | // Crypto API Toolkit custom CKMs
41 | #define CKM_EXPORT_ECDSA_QUOTE_RSA_PUBLIC_KEY (CKM_VENDOR_DEFINED + 0x0000210DUL)
42 | #define CKM_EXPORT_ECDSA_QUOTE_RSA_PUBLIC_KEY_INTERNAL (CKM_EXPORT_ECDSA_QUOTE_RSA_PUBLIC_KEY + 1)
43 |
44 | // Length of NONCE to be used in Quote Generation (in bytes)
45 | #define NONCE_LENGTH 32
46 |
47 | #endif // !_QUOTEGENERATIONDEFS_H
48 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/Serialisable.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | Serialisable.h
29 |
30 | Interface description for serialisable classes
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_SERIALISABLE_H
34 | #define _SOFTHSM_V2_SERIALISABLE_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 |
39 | class ByteString;
40 |
41 | class Serialisable
42 | {
43 | public:
44 | // Serialise the data content of a class
45 | virtual ByteString serialise() const = 0;
46 |
47 | // Default destructor
48 | virtual ~Serialisable() { }
49 | };
50 |
51 | #endif // !_SOFTHSM_V2_SERIALISABLE_H
52 |
53 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/libp11sgx.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | /*****************************************************************************
33 | libp11sgx.h
34 |
35 | This file contains custom structure(s) used by Crypto API Toolkit.
36 | *****************************************************************************/
37 | #ifndef LIB_P11SGX_H
38 | #define LIB_P11SGX_H
39 |
40 | typedef struct CK_UNWRAP_KEY_PARAMS{
41 | CK_ULONG modulusLen;
42 | CK_ULONG exponentLen;
43 | CK_ULONG signatureLen;
44 | CK_ULONG wrappedKeyLen;
45 | CK_MECHANISM_PTR pMechanism;
46 | } CK_UNWRAP_KEY_PARAMS;
47 |
48 | #endif // !LIB_P11SGX_H
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/common/osmutex.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2008-2010 .SE (The Internet Infrastructure Foundation).
3 | * Copyright (c) 2010 SURFnet bv
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | /*****************************************************************************
29 | osmutex.h
30 |
31 | Contains OS-specific implementations of intraprocess mutex functions. This
32 | implementation is based on SoftHSM v1
33 | *****************************************************************************/
34 |
35 | #ifndef _SOFTHSM_V2_OSMUTEX_H
36 | #define _SOFTHSM_V2_OSMUTEX_H
37 |
38 | #include "config.h"
39 | #include "cryptoki.h"
40 |
41 | CK_RV OSCreateMutex(CK_VOID_PTR_PTR newMutex);
42 | CK_RV OSDestroyMutex(CK_VOID_PTR mutex);
43 | CK_RV OSLockMutex(CK_VOID_PTR mutex);
44 | CK_RV OSUnlockMutex(CK_VOID_PTR mutex);
45 |
46 | #endif /* !_SOFTHSM_V2_OSMUTEX_H */
47 |
48 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/AESKey.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | AESKey.cpp
29 |
30 | AES key class
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "ByteString.h"
35 | #include "Serialisable.h"
36 | #include "AESKey.h"
37 | #include "CryptoFactory.h"
38 |
39 | // Get key check value
40 | ByteString AESKey::getKeyCheckValue() const
41 | {
42 | ByteString iv;
43 | ByteString data;
44 | ByteString encryptedData;
45 | ByteString encryptedFinal;
46 |
47 | SymmetricAlgorithm* cipher = CryptoFactory::i()->getSymmetricAlgorithm(SymAlgo::AES);
48 | if (cipher == NULL) return encryptedData;
49 |
50 | // Single block of null (0x00) bytes
51 | data.resize(cipher->getBlockSize());
52 | memset(&data[0], 0, data.size());
53 |
54 | if (!cipher->encryptInit(this, SymMode::ECB, iv, false) ||
55 | !cipher->encryptUpdate(data, encryptedData) ||
56 | !cipher->encryptFinal(encryptedFinal))
57 | {
58 | CryptoFactory::i()->recycleSymmetricAlgorithm(cipher);
59 | return encryptedData;
60 | }
61 | CryptoFactory::i()->recycleSymmetricAlgorithm(cipher);
62 |
63 | encryptedData += encryptedFinal;
64 | encryptedData.resize(3);
65 |
66 | return encryptedData;
67 | }
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/AESKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | AESKey.h
29 |
30 | AES key symmetric key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_AESKEY_H
34 | #define _SOFTHSM_V2_AESKEY_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 | #include "SymmetricKey.h"
39 |
40 | class AESKey : public SymmetricKey
41 | {
42 | public:
43 | // Base constructor
44 | AESKey(size_t inBitLen = 0) : SymmetricKey(inBitLen) { }
45 |
46 | // Get the key check value
47 | virtual ByteString getKeyCheckValue() const;
48 | };
49 |
50 | #endif // !SOFTHSM_V2_AESKEY_H
51 |
52 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DESKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | DESKey.h
29 |
30 | Base class for symmetric key classes
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DESKEY_H
34 | #define _SOFTHSM_V2_DESKEY_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 | #include "Serialisable.h"
39 | #include "SymmetricKey.h"
40 |
41 | class DESKey : public SymmetricKey
42 | {
43 | public:
44 | // Base constructor
45 | DESKey(size_t inBitLen = 0) : SymmetricKey(inBitLen) { }
46 |
47 | // Set the key
48 | virtual bool setKeyBits(const ByteString& keybits);
49 |
50 | // Get the key check value
51 | virtual ByteString getKeyCheckValue() const;
52 | };
53 |
54 | #endif // !_SOFTHSM_V2_DESKEY_H
55 |
56 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DHParameters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | DHParameters.h
29 |
30 | Diffie-Hellman parameters (only used for key generation)
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DHPARAMETERS_H
34 | #define _SOFTHSM_V2_DHPARAMETERS_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 | #include "AsymmetricParameters.h"
39 |
40 | class DHParameters : public AsymmetricParameters
41 | {
42 | public:
43 | // Base constructors
44 | DHParameters() : bitLen(0) { }
45 |
46 | // The type
47 | static const char* type;
48 |
49 | // Set the public prime p
50 | void setP(const ByteString& inP);
51 |
52 | // Set the generator g
53 | void setG(const ByteString& inG);
54 |
55 | // Set the optional bit length
56 | void setXBitLength(const size_t inBitLen);
57 |
58 | // Get the public prime p
59 | const ByteString& getP() const;
60 |
61 | // Get the generator g
62 | const ByteString& getG() const;
63 |
64 | // Get the optional bit length
65 | size_t getXBitLength() const;
66 |
67 | // Are the parameters of the given type?
68 | virtual bool areOfType(const char* inType);
69 |
70 | // Serialisation
71 | virtual ByteString serialise() const;
72 | virtual bool deserialise(ByteString& serialised);
73 |
74 | private:
75 | ByteString p;
76 | ByteString g;
77 | size_t bitLen;
78 | };
79 |
80 | #endif // !_SOFTHSM_V2_DHPARAMETERS_H
81 |
82 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DHPrivateKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | DHPrivateKey.h
29 |
30 | Diffie-Hellman private key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DHPRIVATEKEY_H
34 | #define _SOFTHSM_V2_DHPRIVATEKEY_H
35 |
36 | #include "config.h"
37 | #include "PrivateKey.h"
38 |
39 | class DHPrivateKey : public PrivateKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const;
53 |
54 | // Setters for the DH private key components
55 | virtual void setX(const ByteString& inX);
56 |
57 | // Setters for the DH public key components
58 | virtual void setP(const ByteString& inP);
59 | virtual void setG(const ByteString& inG);
60 |
61 | // Getters for the DH private key components
62 | virtual const ByteString& getX() const;
63 |
64 | // Getters for the DH public key components
65 | virtual const ByteString& getP() const;
66 | virtual const ByteString& getG() const;
67 |
68 | // Serialisation
69 | virtual ByteString serialise() const;
70 | virtual bool deserialise(ByteString& serialised);
71 |
72 | protected:
73 | // Private components
74 | ByteString x;
75 |
76 | // Public components
77 | ByteString p,g;
78 | };
79 |
80 | #endif // !_SOFTHSM_V2_DHPRIVATEKEY_H
81 |
82 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DHPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | DHPublicKey.h
29 |
30 | Diffie-Hellman public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DHPUBLICKEY_H
34 | #define _SOFTHSM_V2_DHPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "PublicKey.h"
38 |
39 | class DHPublicKey : public PublicKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const;
53 |
54 | // Setters for the DH public key components
55 | virtual void setP(const ByteString& inP);
56 | virtual void setG(const ByteString& inG);
57 | virtual void setY(const ByteString& inY);
58 |
59 | // Getters for the DH public key components
60 | virtual const ByteString& getP() const;
61 | virtual const ByteString& getG() const;
62 | virtual const ByteString& getY() const;
63 |
64 | // Serialisation
65 | virtual ByteString serialise() const;
66 | virtual bool deserialise(ByteString& serialised);
67 |
68 | protected:
69 | // Public components
70 | ByteString p,g,y;
71 | };
72 |
73 | #endif // !_SOFTHSM_V2_DHPUBLICKEY_H
74 |
75 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DSAParameters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | DSAParameters.h
29 |
30 | DSA parameters (only used for key generation)
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DSAPARAMETERS_H
34 | #define _SOFTHSM_V2_DSAPARAMETERS_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 | #include "AsymmetricParameters.h"
39 |
40 | class DSAParameters : public AsymmetricParameters
41 | {
42 | public:
43 | // The type
44 | static const char* type;
45 |
46 | // Set the public prime p
47 | void setP(const ByteString& inP);
48 |
49 | // Set the public subprime q
50 | void setQ(const ByteString& inQ);
51 |
52 | // Set the generator g
53 | void setG(const ByteString& inG);
54 |
55 | // Get the public prime p
56 | const ByteString& getP() const;
57 |
58 | // Get the public subprime q
59 | const ByteString& getQ() const;
60 |
61 | // Get the generator g
62 | const ByteString& getG() const;
63 |
64 | // Are the parameters of the given type?
65 | virtual bool areOfType(const char* inType);
66 |
67 | // Serialisation
68 | virtual ByteString serialise() const;
69 | virtual bool deserialise(ByteString& serialised);
70 |
71 | private:
72 | ByteString p;
73 | ByteString q;
74 | ByteString g;
75 | };
76 |
77 | #endif // !_SOFTHSM_V2_DSAPARAMETERS_H
78 |
79 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DSAPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | DSAPublicKey.h
29 |
30 | DSA public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DSAPUBLICKEY_H
34 | #define _SOFTHSM_V2_DSAPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "PublicKey.h"
38 |
39 | class DSAPublicKey : public PublicKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const;
53 |
54 | // Setters for the DSA public key components
55 | virtual void setP(const ByteString& inP);
56 | virtual void setQ(const ByteString& inQ);
57 | virtual void setG(const ByteString& inG);
58 | virtual void setY(const ByteString& inY);
59 |
60 | // Getters for the DSA public key components
61 | virtual const ByteString& getP() const;
62 | virtual const ByteString& getQ() const;
63 | virtual const ByteString& getG() const;
64 | virtual const ByteString& getY() const;
65 |
66 | // Serialisation
67 | virtual ByteString serialise() const;
68 | virtual bool deserialise(ByteString& serialised);
69 |
70 | protected:
71 | // Public components
72 | ByteString p,q,g,y;
73 | };
74 |
75 | #endif // !_SOFTHSM_V2_DSAPUBLICKEY_H
76 |
77 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/DerUtil.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 SURFnet bv
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 | CryptoUtil.h
29 |
30 | DER encoding convenience functions
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_DERUTIL_H
34 | #define _SOFTHSM_V2_DERUTIL_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 |
39 | namespace DERUTIL
40 | {
41 | // Convert a raw ByteString to a DER encoded octet string
42 | ByteString raw2Octet(const ByteString& byteString);
43 |
44 | // Convert a DER encoded octet string to a raw ByteString
45 | ByteString octet2Raw(const ByteString& byteString);
46 | }
47 |
48 | #endif // !_SOFTHSM_V2_DERUTIL_H
49 |
50 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/ECParameters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | ECParameters.h
29 |
30 | Elliptic Curve parameters (only used for key generation)
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_ECPARAMETERS_H
34 | #define _SOFTHSM_V2_ECPARAMETERS_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 | #include "AsymmetricParameters.h"
39 |
40 | class ECParameters : public AsymmetricParameters
41 | {
42 | public:
43 | // The type
44 | static const char* type;
45 |
46 | // Set the curve OID ec
47 | void setEC(const ByteString& inEC);
48 |
49 | // Get the curve OID ec
50 | const ByteString& getEC() const;
51 |
52 | // Are the parameters of the given type?
53 | virtual bool areOfType(const char* inType);
54 |
55 | // Serialisation
56 | virtual ByteString serialise() const;
57 | virtual bool deserialise(ByteString& serialised);
58 |
59 | private:
60 | ByteString ec;
61 | };
62 |
63 | #endif // !_SOFTHSM_V2_ECPARAMETERS_H
64 |
65 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/ECPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | ECPublicKey.h
29 |
30 | Elliptic Curve public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_ECPUBLICKEY_H
34 | #define _SOFTHSM_V2_ECPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "PublicKey.h"
38 |
39 | class ECPublicKey : public PublicKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const;
53 |
54 | // Get the base point order length
55 | virtual unsigned long getOrderLength() const = 0;
56 |
57 | // Setters for the EC public key components
58 | virtual void setEC(const ByteString& inEc);
59 | virtual void setQ(const ByteString& inQ);
60 |
61 | // Getters for the EC public key components
62 | virtual const ByteString& getEC() const;
63 | virtual const ByteString& getQ() const;
64 |
65 | // Serialisation
66 | virtual ByteString serialise() const;
67 | virtual bool deserialise(ByteString& serialised);
68 |
69 | protected:
70 | // Public components
71 | ByteString ec,q;
72 | };
73 |
74 | #endif // !_SOFTHSM_V2_ECPUBLICKEY_H
75 |
76 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/EDPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | EDPublicKey.h
29 |
30 | EDDSA public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_EDPUBLICKEY_H
34 | #define _SOFTHSM_V2_EDPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "PublicKey.h"
38 |
39 | class EDPublicKey : public PublicKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const;
53 |
54 | // Get the base point order length
55 | virtual unsigned long getOrderLength() const = 0;
56 |
57 | // Setters for the EDDSA public key components
58 | virtual void setEC(const ByteString& inEc);
59 | virtual void setA(const ByteString& inA);
60 |
61 | // Getters for the EDDSA public key components
62 | virtual const ByteString& getEC() const;
63 | virtual const ByteString& getA() const;
64 |
65 | // Serialisation
66 | virtual ByteString serialise() const;
67 | virtual bool deserialise(ByteString& serialised);
68 |
69 | protected:
70 | // Public components
71 | ByteString ec, a;
72 | };
73 |
74 | #endif // !_SOFTHSM_V2_EDPUBLICKEY_H
75 |
76 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/GOSTPrivateKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | GOSTPrivateKey.h
29 |
30 | GOST R 34.10-2001 private key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_GOSTPRIVATEKEY_H
34 | #define _SOFTHSM_V2_GOSTPRIVATEKEY_H
35 |
36 | #include "config.h"
37 | #include "PrivateKey.h"
38 |
39 | class GOSTPrivateKey : public PrivateKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const = 0;
53 |
54 | // Setters for the GOST private key components
55 | virtual void setD(const ByteString& inD);
56 |
57 | // Setters for the GOST public key components
58 | virtual void setEC(const ByteString& inEC);
59 |
60 | // Getters for the GOST private key components
61 | virtual const ByteString& getD() const;
62 |
63 | // Getters for the GOST public key components
64 | virtual const ByteString& getEC() const;
65 |
66 | // Serialisation
67 | virtual ByteString serialise() const = 0;
68 | virtual bool deserialise(ByteString& serialised) = 0;
69 |
70 | protected:
71 | // Private components
72 | ByteString d;
73 |
74 | // Public components
75 | ByteString ec;
76 | };
77 |
78 | #endif // !_SOFTHSM_V2_GOSTPRIVATEKEY_H
79 |
80 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/GOSTPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | GOSTPublicKey.h
29 |
30 | GOST R 34.10-2001 public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_GOSTPUBLICKEY_H
34 | #define _SOFTHSM_V2_GOSTPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "PublicKey.h"
38 |
39 | class GOSTPublicKey : public PublicKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const = 0;
53 |
54 | // Setters for the GOST public key components
55 | virtual void setQ(const ByteString& inQ);
56 | virtual void setEC(const ByteString& inEC);
57 |
58 | // Getters for the GOST public key components
59 | virtual const ByteString& getQ() const;
60 | virtual const ByteString& getEC() const;
61 |
62 | // Serialisation
63 | virtual ByteString serialise() const = 0;
64 | virtual bool deserialise(ByteString& serialised) = 0;
65 |
66 | protected:
67 | // Public components
68 | ByteString q, ec;
69 | };
70 |
71 | #endif // !_SOFTHSM_V2_GOSTPUBLICKEY_H
72 |
73 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/HashAlgorithm.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | HashAlgorithm.cpp
29 |
30 | Base class for hash algorithm classes
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "HashAlgorithm.h"
35 |
36 | // Base constructor
37 | HashAlgorithm::HashAlgorithm()
38 | {
39 | currentOperation = NONE;
40 | }
41 |
42 | // Hashing functions
43 | bool HashAlgorithm::hashInit()
44 | {
45 | if (currentOperation != NONE)
46 | {
47 | return false;
48 | }
49 |
50 | currentOperation = HASHING;
51 |
52 | return true;
53 | }
54 |
55 | bool HashAlgorithm::hashUpdate(const ByteString& /*data*/)
56 | {
57 | if (currentOperation != HASHING)
58 | {
59 | return false;
60 | }
61 |
62 | return true;
63 | }
64 |
65 | bool HashAlgorithm::hashFinal(ByteString& /*hashedData*/)
66 | {
67 | if (currentOperation != HASHING)
68 | {
69 | return false;
70 | }
71 |
72 | currentOperation = NONE;
73 |
74 | return true;
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/HashAlgorithm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | HashAlgorithm.h
29 |
30 | Base class for hash algorithm classes
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_HASHALGORITHM_H
34 | #define _SOFTHSM_V2_HASHALGORITHM_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 |
39 | struct HashAlgo
40 | {
41 | enum Type
42 | {
43 | Unknown,
44 | MD5,
45 | SHA1,
46 | SHA224,
47 | SHA256,
48 | SHA384,
49 | SHA512,
50 | GOST
51 | };
52 | };
53 |
54 | class HashAlgorithm
55 | {
56 | public:
57 | // Base constructors
58 | HashAlgorithm();
59 |
60 | // Destructor
61 | virtual ~HashAlgorithm() { }
62 |
63 | // Hashing functions
64 | virtual bool hashInit();
65 | virtual bool hashUpdate(const ByteString& data);
66 | virtual bool hashFinal(ByteString& hashedData);
67 |
68 | virtual int getHashSize() = 0;
69 | protected:
70 | // The current operation
71 | enum
72 | {
73 | NONE,
74 | HASHING
75 | }
76 | currentOperation;
77 | };
78 |
79 | #endif // !_SOFTHSM_V2_HASHALGORITHM_H
80 |
81 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLAES.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLAES.h
29 |
30 | OpenSSL AES implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLAES_H
34 | #define _SOFTHSM_V2_OSSLAES_H
35 |
36 | #include
37 | #include
38 | #include "config.h"
39 | #include "OSSLEVPSymmetricAlgorithm.h"
40 |
41 | class OSSLAES : public OSSLEVPSymmetricAlgorithm
42 | {
43 | public:
44 | // Destructor
45 | virtual ~OSSLAES() { }
46 |
47 | // Wrap/Unwrap keys
48 | virtual bool wrapKey(const SymmetricKey* key, const SymWrap::Type mode, const ByteString& in, ByteString& out);
49 |
50 | virtual bool unwrapKey(const SymmetricKey* key, const SymWrap::Type mode, const ByteString& in, ByteString& out);
51 |
52 | // Return the block size
53 | virtual size_t getBlockSize() const;
54 |
55 | protected:
56 | // Return the right EVP cipher for the operation
57 | virtual const EVP_CIPHER* getCipher() const;
58 | const EVP_CIPHER* getWrapCipher(const SymWrap::Type mode, const SymmetricKey* key) const;
59 | bool wrapUnwrapKey(const SymmetricKey* key, const SymWrap::Type mode, const ByteString& in, ByteString& out, const int wrap) const;
60 | bool checkLength(const int insize, const int minsize, const char * const operation) const;
61 | };
62 |
63 | #endif // !_SOFTHSM_V2_OSSLAES_H
64 |
65 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLCMAC.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 SURFnet bv
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 | OSSLCMAC.h
29 |
30 | OpenSSL CMAC implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLCMAC_H
34 | #define _SOFTHSM_V2_OSSLCMAC_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPCMacAlgorithm.h"
38 | #include
39 |
40 | class OSSLCMACDES : public OSSLEVPCMacAlgorithm
41 | {
42 | protected:
43 | virtual const EVP_CIPHER* getEVPCipher() const;
44 | virtual size_t getMacSize() const;
45 | };
46 |
47 | class OSSLCMACAES : public OSSLEVPCMacAlgorithm
48 | {
49 | protected:
50 | virtual const EVP_CIPHER* getEVPCipher() const;
51 | virtual size_t getMacSize() const;
52 | };
53 |
54 | #endif // !_SOFTHSM_V2_OSSLHMAC_H
55 |
56 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLDES.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLDES.h
29 |
30 | OpenSSL AES implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLDES_H
34 | #define _SOFTHSM_V2_OSSLDES_H
35 |
36 | #include
37 | #include
38 | #include "config.h"
39 | #include "OSSLEVPSymmetricAlgorithm.h"
40 |
41 | class OSSLDES : public OSSLEVPSymmetricAlgorithm
42 | {
43 | public:
44 | // Destructor
45 | virtual ~OSSLDES() { }
46 |
47 | // Wrap/Unwrap keys
48 | virtual bool wrapKey(const SymmetricKey* key, const SymWrap::Type mode, const ByteString& in, ByteString& out);
49 |
50 | virtual bool unwrapKey(const SymmetricKey* key, const SymWrap::Type mode, const ByteString& in, ByteString& out);
51 |
52 | // Generate key
53 | virtual bool generateKey(SymmetricKey& key, RNG* rng = NULL);
54 |
55 | // Return the block size
56 | virtual size_t getBlockSize() const;
57 |
58 | protected:
59 | // Return the right EVP cipher for the operation
60 | virtual const EVP_CIPHER* getCipher() const;
61 | };
62 |
63 | #endif // !_SOFTHSM_V2_OSSLDES_H
64 |
65 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLDHKeyPair.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLDHKeyPair.h
29 |
30 | OpenSSL Diffie-Hellman key-pair class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLDHKEYPAIR_H
34 | #define _SOFTHSM_V2_OSSLDHKEYPAIR_H
35 |
36 | #include "config.h"
37 | #include "AsymmetricKeyPair.h"
38 | #include "OSSLDHPublicKey.h"
39 | #include "OSSLDHPrivateKey.h"
40 |
41 | class OSSLDHKeyPair : public AsymmetricKeyPair
42 | {
43 | public:
44 | // Set the public key
45 | void setPublicKey(OSSLDHPublicKey& publicKey);
46 |
47 | // Set the private key
48 | void setPrivateKey(OSSLDHPrivateKey& privateKey);
49 |
50 | // Return the public key
51 | virtual PublicKey* getPublicKey();
52 | virtual const PublicKey* getConstPublicKey() const;
53 |
54 | // Return the private key
55 | virtual PrivateKey* getPrivateKey();
56 | virtual const PrivateKey* getConstPrivateKey() const;
57 |
58 | private:
59 | // The public key
60 | OSSLDHPublicKey pubKey;
61 |
62 | // The private key
63 | OSSLDHPrivateKey privKey;
64 | };
65 |
66 | #endif // !_SOFTHSM_V2_OSSLDHKEYPAIR_H
67 |
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLDHPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLDHPublicKey.h
29 |
30 | OpenSSL Diffie-Hellman public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLDHPUBLICKEY_H
34 | #define _SOFTHSM_V2_OSSLDHPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "DHPublicKey.h"
38 | #include
39 |
40 | class OSSLDHPublicKey : public DHPublicKey
41 | {
42 | public:
43 | // Constructors
44 | OSSLDHPublicKey();
45 |
46 | OSSLDHPublicKey(const DH* inDH);
47 |
48 | // Destructor
49 | virtual ~OSSLDHPublicKey();
50 |
51 | // The type
52 | static const char* type;
53 |
54 | // Check if the key is of the given type
55 | virtual bool isOfType(const char* inType);
56 |
57 | // Setters for the DH public key components
58 | virtual void setP(const ByteString& inP);
59 | virtual void setG(const ByteString& inG);
60 | virtual void setY(const ByteString& inY);
61 |
62 | // Set from OpenSSL representation
63 | virtual void setFromOSSL(const DH* inDH);
64 |
65 | // Retrieve the OpenSSL representation of the key
66 | DH* getOSSLKey();
67 |
68 | private:
69 | // The internal OpenSSL representation
70 | DH* dh;
71 |
72 | // Create the OpenSSL representation of the key
73 | void createOSSLKey();
74 | };
75 |
76 | #endif // !_SOFTHSM_V2_OSSLDHPUBLICKEY_H
77 |
78 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLDSAKeyPair.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLDSAKeyPair.h
29 |
30 | OpenSSL DSA key-pair class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLDSAKEYPAIR_H
34 | #define _SOFTHSM_V2_OSSLDSAKEYPAIR_H
35 |
36 | #include "config.h"
37 | #include "AsymmetricKeyPair.h"
38 | #include "OSSLDSAPublicKey.h"
39 | #include "OSSLDSAPrivateKey.h"
40 |
41 | class OSSLDSAKeyPair : public AsymmetricKeyPair
42 | {
43 | public:
44 | // Set the public key
45 | void setPublicKey(OSSLDSAPublicKey& publicKey);
46 |
47 | // Set the private key
48 | void setPrivateKey(OSSLDSAPrivateKey& privateKey);
49 |
50 | // Return the public key
51 | virtual PublicKey* getPublicKey();
52 | virtual const PublicKey* getConstPublicKey() const;
53 |
54 | // Return the private key
55 | virtual PrivateKey* getPrivateKey();
56 | virtual const PrivateKey* getConstPrivateKey() const;
57 |
58 | private:
59 | // The public key
60 | OSSLDSAPublicKey pubKey;
61 |
62 | // The private key
63 | OSSLDSAPrivateKey privKey;
64 | };
65 |
66 | #endif // !_SOFTHSM_V2_OSSLDSAKEYPAIR_H
67 |
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLDSAPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLDSAPublicKey.h
29 |
30 | OpenSSL DSA public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLDSAPUBLICKEY_H
34 | #define _SOFTHSM_V2_OSSLDSAPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "DSAPublicKey.h"
38 | #include
39 |
40 | class OSSLDSAPublicKey : public DSAPublicKey
41 | {
42 | public:
43 | // Constructors
44 | OSSLDSAPublicKey();
45 |
46 | OSSLDSAPublicKey(const DSA* inDSA);
47 |
48 | // Destructor
49 | virtual ~OSSLDSAPublicKey();
50 |
51 | // The type
52 | static const char* type;
53 |
54 | // Check if the key is of the given type
55 | virtual bool isOfType(const char* inType);
56 |
57 | // Setters for the DSA public key components
58 | virtual void setP(const ByteString& inP);
59 | virtual void setQ(const ByteString& inQ);
60 | virtual void setG(const ByteString& inG);
61 | virtual void setY(const ByteString& inY);
62 |
63 | // Set from OpenSSL representation
64 | virtual void setFromOSSL(const DSA* inDSA);
65 |
66 | // Retrieve the OpenSSL representation of the key
67 | DSA* getOSSLKey();
68 |
69 | private:
70 | // The internal OpenSSL representation
71 | DSA* dsa;
72 |
73 | // Create the OpenSSL representation of the key
74 | void createOSSLKey();
75 | };
76 |
77 | #endif // !_SOFTHSM_V2_OSSLDSAPUBLICKEY_H
78 |
79 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLECKeyPair.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLECKeyPair.h
29 |
30 | OpenSSL Elliptic Curve key-pair class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLECKEYPAIR_H
34 | #define _SOFTHSM_V2_OSSLECKEYPAIR_H
35 |
36 | #include "config.h"
37 | #include "AsymmetricKeyPair.h"
38 | #include "OSSLECPublicKey.h"
39 | #include "OSSLECPrivateKey.h"
40 |
41 | class OSSLECKeyPair : public AsymmetricKeyPair
42 | {
43 | public:
44 | // Set the public key
45 | void setPublicKey(OSSLECPublicKey& publicKey);
46 |
47 | // Set the private key
48 | void setPrivateKey(OSSLECPrivateKey& privateKey);
49 |
50 | // Return the public key
51 | virtual PublicKey* getPublicKey();
52 | virtual const PublicKey* getConstPublicKey() const;
53 |
54 | // Return the private key
55 | virtual PrivateKey* getPrivateKey();
56 | virtual const PrivateKey* getConstPrivateKey() const;
57 |
58 | private:
59 | // The public key
60 | OSSLECPublicKey pubKey;
61 |
62 | // The private key
63 | OSSLECPrivateKey privKey;
64 | };
65 |
66 | #endif // !_SOFTHSM_V2_OSSLECKEYPAIR_H
67 |
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLECPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLECPublicKey.h
29 |
30 | OpenSSL Elliptic Curve public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLECPUBLICKEY_H
34 | #define _SOFTHSM_V2_OSSLECPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "ECPublicKey.h"
38 | #include
39 |
40 | class OSSLECPublicKey : public ECPublicKey
41 | {
42 | public:
43 | // Constructors
44 | OSSLECPublicKey();
45 |
46 | OSSLECPublicKey(const EVP_PKEY* inPKEY);
47 |
48 | // Destructor
49 | virtual ~OSSLECPublicKey();
50 |
51 | // The type
52 | static const char* type;
53 |
54 | // Check if the key is of the given type
55 | virtual bool isOfType(const char* inType);
56 |
57 | // Get the base point order length
58 | virtual unsigned long getOrderLength() const;
59 |
60 | // Setters for the EC public key components
61 | virtual void setEC(const ByteString& inEC);
62 | virtual void setQ(const ByteString& inQ);
63 |
64 | // Set from OpenSSL representation
65 | virtual void setFromOSSL(const EVP_PKEY* inPKEY);
66 |
67 | // Retrieve the OpenSSL representation of the key
68 | EVP_PKEY* getOSSLKey();
69 |
70 | private:
71 | // The internal OpenSSL representation
72 | int nid;
73 | EVP_PKEY* pkey;
74 |
75 | // Create the OpenSSL representation of the key
76 | void createOSSLKey();
77 |
78 | unsigned long getSignatureLength() const;
79 | };
80 |
81 | #endif // !_SOFTHSM_V2_OSSLDSAPUBLICKEY_H
82 |
83 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLEDKeyPair.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLEDKeyPair.h
29 |
30 | OpenSSL EDDSA key-pair class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLEDKEYPAIR_H
34 | #define _SOFTHSM_V2_OSSLEDKEYPAIR_H
35 |
36 | #include "config.h"
37 | #include "AsymmetricKeyPair.h"
38 | #include "OSSLEDPublicKey.h"
39 | #include "OSSLEDPrivateKey.h"
40 |
41 | class OSSLEDKeyPair : public AsymmetricKeyPair
42 | {
43 | public:
44 | // Set the public key
45 | void setPublicKey(OSSLEDPublicKey& publicKey);
46 |
47 | // Set the private key
48 | void setPrivateKey(OSSLEDPrivateKey& privateKey);
49 |
50 | // Return the public key
51 | virtual PublicKey* getPublicKey();
52 | virtual const PublicKey* getConstPublicKey() const;
53 |
54 | // Return the private key
55 | virtual PrivateKey* getPrivateKey();
56 | virtual const PrivateKey* getConstPrivateKey() const;
57 |
58 | private:
59 | // The public key
60 | OSSLEDPublicKey pubKey;
61 |
62 | // The private key
63 | OSSLEDPrivateKey privKey;
64 | };
65 |
66 | #endif // !_SOFTHSM_V2_OSSLEDKEYPAIR_H
67 |
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLEDPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLEDPublicKey.h
29 |
30 | OpenSSL EDDSA public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLEDPUBLICKEY_H
34 | #define _SOFTHSM_V2_OSSLEDPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "EDPublicKey.h"
38 | #include
39 |
40 | class OSSLEDPublicKey : public EDPublicKey
41 | {
42 | public:
43 | // Constructors
44 | OSSLEDPublicKey();
45 |
46 | OSSLEDPublicKey(const EVP_PKEY* inPKEY);
47 |
48 | // Destructor
49 | virtual ~OSSLEDPublicKey();
50 |
51 | // The type
52 | static const char* type;
53 |
54 | // Check if the key is of the given type
55 | virtual bool isOfType(const char* inType);
56 |
57 | // Get the base point order length
58 | virtual unsigned long getOrderLength() const;
59 |
60 | // Setters for the EDDSA public key components
61 | virtual void setEC(const ByteString& inEC);
62 | virtual void setA(const ByteString& inA);
63 |
64 | // Set from OpenSSL representation
65 | virtual void setFromOSSL(const EVP_PKEY* inPKEY);
66 |
67 | // Retrieve the OpenSSL representation of the key
68 | EVP_PKEY* getOSSLKey();
69 |
70 | private:
71 | // The internal OpenSSL representation
72 | int nid;
73 | EVP_PKEY* pkey;
74 |
75 | // Create the OpenSSL representation of the key
76 | void createOSSLKey();
77 | };
78 |
79 | #endif // !_SOFTHSM_V2_OSSLDSAPUBLICKEY_H
80 |
81 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLEVPCMacAlgorithm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017 SURFnet bv
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 | OSSLEVPCMacAlgorithm.h
29 |
30 | OpenSSL CMAC algorithm implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLEVPCMACALGORITHM_H
34 | #define _SOFTHSM_V2_OSSLEVPCMACALGORITHM_H
35 |
36 | #include
37 | #include "config.h"
38 | #include "SymmetricKey.h"
39 | #include "MacAlgorithm.h"
40 | #include
41 | #include
42 |
43 | class OSSLEVPCMacAlgorithm : public MacAlgorithm
44 | {
45 | public:
46 | // Constructor
47 | OSSLEVPCMacAlgorithm() {
48 | curCTX = NULL;
49 | };
50 |
51 | // Destructor
52 | ~OSSLEVPCMacAlgorithm();
53 |
54 | // Signing functions
55 | virtual bool signInit(const SymmetricKey* key);
56 | virtual bool signUpdate(const ByteString& dataToSign);
57 | virtual bool signFinal(ByteString& signature);
58 |
59 | // Verification functions
60 | virtual bool verifyInit(const SymmetricKey* key);
61 | virtual bool verifyUpdate(const ByteString& originalData);
62 | virtual bool verifyFinal(ByteString& signature);
63 |
64 | // Return the MAC size
65 | virtual size_t getMacSize() const = 0;
66 |
67 | protected:
68 | // Return the right cipher for the operation
69 | virtual const EVP_CIPHER* getEVPCipher() const = 0;
70 |
71 | private:
72 | // The current context
73 | CMAC_CTX* curCTX;
74 | };
75 |
76 | #endif // !_SOFTHSM_V2_OSSLEVPCMACALGORITHM_H
77 |
78 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLEVPHashAlgorithm.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLEVPHashAlgorithm.h
29 |
30 | Base class for OpenSSL hash algorithm classes
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLEVPHASHALGORITHM_H
34 | #define _SOFTHSM_V2_OSSLEVPHASHALGORITHM_H
35 |
36 | #include "config.h"
37 | #include "HashAlgorithm.h"
38 | #include
39 |
40 | class OSSLEVPHashAlgorithm : public HashAlgorithm
41 | {
42 | public:
43 | // Base constructors
44 | OSSLEVPHashAlgorithm() : HashAlgorithm() {
45 | curCTX = NULL;
46 | }
47 |
48 | // Destructor
49 | ~OSSLEVPHashAlgorithm();
50 |
51 | // Hashing functions
52 | virtual bool hashInit();
53 | virtual bool hashUpdate(const ByteString& data);
54 | virtual bool hashFinal(ByteString& hashedData);
55 |
56 | virtual int getHashSize() = 0;
57 | protected:
58 | virtual const EVP_MD* getEVPHash() const = 0;
59 |
60 | private:
61 | // Current hashing context
62 | EVP_MD_CTX* curCTX;
63 | };
64 |
65 | #endif // !_SOFTHSM_V2_OSSLEVPHASHALGORITHM_H
66 |
67 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLEVPMacAlgorithm.h:
--------------------------------------------------------------------------------
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 | OSSLEVPMacAlgorithm.h
29 |
30 | OpenSSL MAC algorithm implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLEVPMACALGORITHM_H
34 | #define _SOFTHSM_V2_OSSLEVPMACALGORITHM_H
35 |
36 | #include
37 | #include "config.h"
38 | #include "SymmetricKey.h"
39 | #include "MacAlgorithm.h"
40 | #include
41 | #include
42 |
43 | class OSSLEVPMacAlgorithm : public MacAlgorithm
44 | {
45 | public:
46 | // Constructor
47 | OSSLEVPMacAlgorithm() {
48 | curCTX = NULL;
49 | };
50 |
51 | // Destructor
52 | ~OSSLEVPMacAlgorithm();
53 |
54 | // Signing functions
55 | virtual bool signInit(const SymmetricKey* key);
56 | virtual bool signUpdate(const ByteString& dataToSign);
57 | virtual bool signFinal(ByteString& signature);
58 |
59 | // Verification functions
60 | virtual bool verifyInit(const SymmetricKey* key);
61 | virtual bool verifyUpdate(const ByteString& originalData);
62 | virtual bool verifyFinal(ByteString& signature);
63 |
64 | // Return the MAC size
65 | virtual size_t getMacSize() const = 0;
66 |
67 | protected:
68 | // Return the right hash for the operation
69 | virtual char* getHashAlgo() const = 0;
70 |
71 | private:
72 | // The current context
73 | EVP_MAC_CTX * curCTX;
74 | };
75 |
76 | #endif // !_SOFTHSM_V2_OSSLEVPMACALGORITHM_H
77 |
78 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLGOSTKeyPair.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLGOSTKeyPair.h
29 |
30 | OpenSSL GOST R 34.10-2001 key-pair class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLGOSTKEYPAIR_H
34 | #define _SOFTHSM_V2_OSSLGOSTKEYPAIR_H
35 |
36 | #include "config.h"
37 | #include "AsymmetricKeyPair.h"
38 | #include "OSSLGOSTPublicKey.h"
39 | #include "OSSLGOSTPrivateKey.h"
40 |
41 | class OSSLGOSTKeyPair : public AsymmetricKeyPair
42 | {
43 | public:
44 | // Set the public key
45 | void setPublicKey(OSSLGOSTPublicKey& publicKey);
46 |
47 | // Set the private key
48 | void setPrivateKey(OSSLGOSTPrivateKey& privateKey);
49 |
50 | // Return the public key
51 | virtual PublicKey* getPublicKey();
52 | virtual const PublicKey* getConstPublicKey() const;
53 |
54 | // Return the private key
55 | virtual PrivateKey* getPrivateKey();
56 | virtual const PrivateKey* getConstPrivateKey() const;
57 |
58 | private:
59 | // The public key
60 | OSSLGOSTPublicKey pubKey;
61 |
62 | // The private key
63 | OSSLGOSTPrivateKey privKey;
64 | };
65 |
66 | #endif // !_SOFTHSM_V2_OSSLGOSTKEYPAIR_H
67 |
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLGOSTPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLGOSTPublicKey.h
29 |
30 | OpenSSL GOST R 34.10-2001 public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLGOSTPUBLICKEY_H
34 | #define _SOFTHSM_V2_OSSLGOSTPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "GOSTPublicKey.h"
38 | #include
39 |
40 | class OSSLGOSTPublicKey : public GOSTPublicKey
41 | {
42 | public:
43 | // Constructors
44 | OSSLGOSTPublicKey();
45 |
46 | OSSLGOSTPublicKey(const EVP_PKEY* inPKEY);
47 |
48 | // Destructor
49 | virtual ~OSSLGOSTPublicKey();
50 |
51 | // The type
52 | static const char* type;
53 |
54 | // Check if the key is of the given type
55 | virtual bool isOfType(const char* inType);
56 |
57 | // Get the output length
58 | virtual unsigned long getOutputLength() const;
59 |
60 | // Setters for the GOST public key components
61 | virtual void setEC(const ByteString& inEC);
62 | virtual void setQ(const ByteString& inQ);
63 |
64 | // Serialisation
65 | virtual ByteString serialise() const;
66 | virtual bool deserialise(ByteString& serialised);
67 |
68 | // Set from OpenSSL representation
69 | virtual void setFromOSSL(const EVP_PKEY* pkey);
70 |
71 | // Retrieve the OpenSSL representation of the key
72 | EVP_PKEY* getOSSLKey();
73 |
74 | private:
75 | // The internal OpenSSL representation
76 | EVP_PKEY* pkey;
77 | };
78 |
79 | #endif // !_SOFTHSM_V2_OSSLDSAPUBLICKEY_H
80 |
81 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLGOSTR3411.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLGOSTR3411.h
29 |
30 | OpenSSL GOST R 34.11-94 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #ifdef WITH_GOST
35 | #include "OSSLGOSTR3411.h"
36 | #include "OSSLCryptoFactory.h"
37 | #include
38 |
39 | int OSSLGOSTR3411::getHashSize()
40 | {
41 | return 32;
42 | }
43 |
44 | const EVP_MD* OSSLGOSTR3411::getEVPHash() const
45 | {
46 | return OSSLCryptoFactory::i()->EVP_GOST_34_11;
47 | }
48 | #endif
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLGOSTR3411.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLGOSTR3411.h
29 |
30 | OpenSSL GOST R 34.11-94 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLGOSTR3411_H
34 | #define _SOFTHSM_V2_OSSLGOSTR3411_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLGOSTR3411 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLGOSTR3411_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLHMAC.cpp:
--------------------------------------------------------------------------------
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 | OSSLHMAC.cpp
29 |
30 | OpenSSL HMAC implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLHMAC.h"
35 | #include
36 | #ifdef WITH_GOST
37 | #include "OSSLCryptoFactory.h"
38 | #endif
39 |
40 | char* OSSLHMACMD5::getHashAlgo() const
41 | {
42 | return (char*) OSSL_DIGEST_NAME_MD5;
43 | }
44 |
45 | size_t OSSLHMACMD5::getMacSize() const
46 | {
47 | return 16;
48 | }
49 |
50 | char* OSSLHMACSHA1::getHashAlgo() const
51 | {
52 | return (char*) OSSL_DIGEST_NAME_SHA1;
53 | }
54 |
55 | size_t OSSLHMACSHA1::getMacSize() const
56 | {
57 | return 20;
58 | }
59 |
60 | char* OSSLHMACSHA224::getHashAlgo() const
61 | {
62 | return (char*) OSSL_DIGEST_NAME_SHA2_224;
63 | }
64 |
65 | size_t OSSLHMACSHA224::getMacSize() const
66 | {
67 | return 28;
68 | }
69 |
70 | char* OSSLHMACSHA256::getHashAlgo() const
71 | {
72 | return (char*) OSSL_DIGEST_NAME_SHA2_256;
73 | }
74 |
75 | size_t OSSLHMACSHA256::getMacSize() const
76 | {
77 | return 32;
78 | }
79 |
80 | char* OSSLHMACSHA384::getHashAlgo() const
81 | {
82 | return (char*) OSSL_DIGEST_NAME_SHA2_384;
83 | }
84 |
85 | size_t OSSLHMACSHA384::getMacSize() const
86 | {
87 | return 48;
88 | }
89 |
90 | char* OSSLHMACSHA512::getHashAlgo() const
91 | {
92 | return (char*) OSSL_DIGEST_NAME_SHA2_512;
93 | }
94 |
95 | size_t OSSLHMACSHA512::getMacSize() const
96 | {
97 | return 64;
98 | }
99 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLMD5.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLMD5.h
29 |
30 | OpenSSL MD5 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLMD5.h"
35 | #include
36 |
37 | int OSSLMD5::getHashSize()
38 | {
39 | return 16;
40 | }
41 |
42 | const EVP_MD* OSSLMD5::getEVPHash() const
43 | {
44 | return EVP_md5();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLMD5.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLMD5.h
29 |
30 | OpenSSL MD5 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLMD5_H
34 | #define _SOFTHSM_V2_OSSLMD5_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLMD5 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLMD5_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLRSAKeyPair.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLRSAKeyPair.h
29 |
30 | OpenSSL RSA key-pair class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLRSAKEYPAIR_H
34 | #define _SOFTHSM_V2_OSSLRSAKEYPAIR_H
35 |
36 | #include "config.h"
37 | #include "AsymmetricKeyPair.h"
38 | #include "OSSLRSAPublicKey.h"
39 | #include "OSSLRSAPrivateKey.h"
40 |
41 | class OSSLRSAKeyPair : public AsymmetricKeyPair
42 | {
43 | public:
44 | // Set the public key
45 | void setPublicKey(OSSLRSAPublicKey& publicKey);
46 |
47 | // Set the private key
48 | void setPrivateKey(OSSLRSAPrivateKey& privateKey);
49 |
50 | // Return the public key
51 | virtual PublicKey* getPublicKey();
52 | virtual const PublicKey* getConstPublicKey() const;
53 |
54 | // Return the private key
55 | virtual PrivateKey* getPrivateKey();
56 | virtual const PrivateKey* getConstPrivateKey() const;
57 |
58 | private:
59 | // The public key
60 | OSSLRSAPublicKey pubKey;
61 |
62 | // The private key
63 | OSSLRSAPrivateKey privKey;
64 | };
65 |
66 | #endif // !_SOFTHSM_V2_OSSLRSAKEYPAIR_H
67 |
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLRSAPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLRSAPublicKey.h
29 |
30 | OpenSSL RSA public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLRSAPUBLICKEY_H
34 | #define _SOFTHSM_V2_OSSLRSAPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "RSAPublicKey.h"
38 | #include
39 |
40 | class OSSLRSAPublicKey : public RSAPublicKey
41 | {
42 | public:
43 | // Constructors
44 | OSSLRSAPublicKey();
45 |
46 | OSSLRSAPublicKey(const EVP_PKEY* inPKEY);
47 |
48 | // Destructor
49 | virtual ~OSSLRSAPublicKey();
50 |
51 | // The type
52 | static const char* type;
53 |
54 | // Check if the key is of the given type
55 | virtual bool isOfType(const char* inType);
56 |
57 | // Setters for the RSA public key components
58 | virtual void setN(const ByteString& inN);
59 | virtual void setE(const ByteString& inE);
60 |
61 | // Set from OpenSSL representation
62 | virtual void setFromOSSL(const EVP_PKEY* inPKEY);
63 |
64 | // Retrieve the OpenSSL representation of the key
65 | EVP_PKEY* getOSSLKey();
66 |
67 | private:
68 | // The internal OpenSSL representation
69 | EVP_PKEY* rsa;
70 |
71 | // Create the OpenSSL representation of the key
72 | void createOSSLKey();
73 | };
74 |
75 | #endif // !_SOFTHSM_V2_OSSLRSAPUBLICKEY_H
76 |
77 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA1.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA1.h
29 |
30 | OpenSSL SHA1 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLSHA1.h"
35 | #include
36 |
37 | int OSSLSHA1::getHashSize()
38 | {
39 | return 20;
40 | }
41 |
42 | const EVP_MD* OSSLSHA1::getEVPHash() const
43 | {
44 | return EVP_sha1();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA1.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA1.h
29 |
30 | OpenSSL SHA1 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLSHA1_H
34 | #define _SOFTHSM_V2_OSSLSHA1_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLSHA1 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLSHA1_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA224.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA224.h
29 |
30 | OpenSSL SHA224 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLSHA224.h"
35 | #include
36 |
37 | int OSSLSHA224::getHashSize()
38 | {
39 | return 28;
40 | }
41 |
42 | const EVP_MD* OSSLSHA224::getEVPHash() const
43 | {
44 | return EVP_sha224();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA224.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA224.h
29 |
30 | OpenSSL SHA224 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLSHA224_H
34 | #define _SOFTHSM_V2_OSSLSHA224_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLSHA224 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLSHA224_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA256.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA256.h
29 |
30 | OpenSSL SHA256 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLSHA256.h"
35 | #include
36 |
37 | int OSSLSHA256::getHashSize()
38 | {
39 | return 32;
40 | }
41 |
42 | const EVP_MD* OSSLSHA256::getEVPHash() const
43 | {
44 | return EVP_sha256();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA256.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA256.h
29 |
30 | OpenSSL SHA256 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLSHA256_H
34 | #define _SOFTHSM_V2_OSSLSHA256_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLSHA256 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLSHA256_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA384.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA384.h
29 |
30 | OpenSSL SHA384 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLSHA384.h"
35 | #include
36 |
37 | int OSSLSHA384::getHashSize()
38 | {
39 | return 48;
40 | }
41 |
42 | const EVP_MD* OSSLSHA384::getEVPHash() const
43 | {
44 | return EVP_sha384();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA384.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA384.h
29 |
30 | OpenSSL SHA384 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLSHA384_H
34 | #define _SOFTHSM_V2_OSSLSHA384_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLSHA384 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLSHA384_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA512.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA512.h
29 |
30 | OpenSSL SHA512 implementation
31 | *****************************************************************************/
32 |
33 | #include "config.h"
34 | #include "OSSLSHA512.h"
35 | #include
36 |
37 | int OSSLSHA512::getHashSize()
38 | {
39 | return 64;
40 | }
41 |
42 | const EVP_MD* OSSLSHA512::getEVPHash() const
43 | {
44 | return EVP_sha512();
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/OSSLSHA512.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | OSSLSHA512.h
29 |
30 | OpenSSL SHA512 implementation
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_OSSLSHA512_H
34 | #define _SOFTHSM_V2_OSSLSHA512_H
35 |
36 | #include "config.h"
37 | #include "OSSLEVPHashAlgorithm.h"
38 | #include
39 |
40 | class OSSLSHA512 : public OSSLEVPHashAlgorithm
41 | {
42 | virtual int getHashSize();
43 | protected:
44 | virtual const EVP_MD* getEVPHash() const;
45 | };
46 |
47 | #endif // !_SOFTHSM_V2_OSSLSHA512_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/RSAParameters.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | RSAParameters.h
29 |
30 | RSA parameters (only used for key generation)
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_RSAPARAMETERS_H
34 | #define _SOFTHSM_V2_RSAPARAMETERS_H
35 |
36 | #include "config.h"
37 | #include "ByteString.h"
38 | #include "AsymmetricParameters.h"
39 |
40 | class RSAParameters : public AsymmetricParameters
41 | {
42 | public:
43 | // Base constructor
44 | RSAParameters() : bitLen(0) { }
45 |
46 | // The type
47 | static const char* type;
48 |
49 | // Set the public exponent
50 | void setE(const ByteString& inE);
51 |
52 | // Set the bit length
53 | void setBitLength(const size_t inBitLen);
54 |
55 | // Get the public exponent
56 | const ByteString& getE() const;
57 |
58 | // Get the bit length
59 | size_t getBitLength() const;
60 |
61 | // Are the parameters of the given type?
62 | virtual bool areOfType(const char* inType);
63 |
64 | // Serialisation
65 | virtual ByteString serialise() const;
66 | virtual bool deserialise(ByteString& serialised);
67 |
68 | private:
69 | ByteString e;
70 | size_t bitLen;
71 | };
72 |
73 | #endif // !_SOFTHSM_V2_RSAPARAMETERS_H
74 |
75 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/crypto/RSAPublicKey.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | RSAPublicKey.h
29 |
30 | RSA public key class
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_RSAPUBLICKEY_H
34 | #define _SOFTHSM_V2_RSAPUBLICKEY_H
35 |
36 | #include "config.h"
37 | #include "PublicKey.h"
38 |
39 | class RSAPublicKey : public PublicKey
40 | {
41 | public:
42 | // The type
43 | static const char* type;
44 |
45 | // Check if the key is of the given type
46 | virtual bool isOfType(const char* inType);
47 |
48 | // Get the bit length
49 | virtual unsigned long getBitLength() const;
50 |
51 | // Get the output length
52 | virtual unsigned long getOutputLength() const;
53 |
54 | // Setters for the RSA public key components
55 | virtual void setN(const ByteString& inN);
56 | virtual void setE(const ByteString& inE);
57 |
58 | // Getters for the RSA public key components
59 | virtual const ByteString& getN() const;
60 | virtual const ByteString& getE() const;
61 |
62 | // Serialisation
63 | virtual ByteString serialise() const;
64 | virtual bool deserialise(ByteString& serialised);
65 |
66 | protected:
67 | // Public components
68 | ByteString n,e;
69 | };
70 |
71 | #endif // !_SOFTHSM_V2_RSAPUBLICKEY_H
72 |
73 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/data_mgr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(softhsm_datamgr)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/../crypto
5 | ${PROJECT_SOURCE_DIR}/../common
6 | ${PROJECT_SOURCE_DIR}/../pkcs11
7 | )
8 |
9 | set(SOURCES ByteString.cpp
10 | RFC4880.cpp
11 | SecureDataManager.cpp
12 | SecureMemoryRegistry.cpp
13 | )
14 |
15 | include_directories(${INCLUDE_DIRS})
16 |
17 | add_library(${PROJECT_NAME} OBJECT ${SOURCES})
18 |
19 | if(BUILD_TESTS)
20 | add_subdirectory(test)
21 | endif(BUILD_TESTS)
22 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/data_mgr/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/.. \
4 | -I$(srcdir)/../crypto \
5 | -I$(srcdir)/../common \
6 | -I$(SGXSDKDIR)/include \
7 | -I$(SGXSDKDIR)/include/tlibc \
8 | -I$(SGXSDKDIR)/include/libcxx \
9 | -I$(SGXSDKDIR)/include/stdc++ \
10 | -I$(SGXSDKDIR)/include/stlport
11 |
12 | if WITH_P11_KIT
13 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
14 | else
15 | AM_CPPFLAGS += -I$(srcdir)/../pkcs11
16 | endif
17 |
18 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
19 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
20 |
21 | noinst_LTLIBRARIES = libsofthsm_datamgr.la
22 | libsofthsm_datamgr_la_SOURCES = ByteString.cpp \
23 | RFC4880.cpp \
24 | SecureDataManager.cpp \
25 | SecureMemoryRegistry.cpp
26 |
27 | EXTRA_DIST = $(srcdir)/*.h
28 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/handle_mgr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(softhsm_handlemgr)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/../common
5 | ${PROJECT_SOURCE_DIR}/../crypto
6 | ${PROJECT_SOURCE_DIR}/../data_mgr
7 | ${PROJECT_SOURCE_DIR}/../object_store
8 | ${PROJECT_SOURCE_DIR}/../pkcs11
9 | ${PROJECT_SOURCE_DIR}/../slot_mgr
10 | )
11 |
12 | set(SOURCES HandleManager.cpp
13 | Handle.cpp
14 | )
15 |
16 | include_directories(${INCLUDE_DIRS})
17 |
18 | add_library(${PROJECT_NAME} OBJECT ${SOURCES})
19 |
20 | if(BUILD_TESTS)
21 | add_subdirectory(test)
22 | endif(BUILD_TESTS)
23 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/handle_mgr/Handle.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 SURFnet bv
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 | Handle.h
29 |
30 | This class represents a single handle
31 | *****************************************************************************/
32 |
33 | #include "Handle.h"
34 |
35 | // Constructor
36 | Handle::Handle(CK_HANDLE_KIND _kind, CK_SLOT_ID _slotID, CK_SESSION_HANDLE _hSession)
37 | : kind(_kind), slotID(_slotID), hSession(_hSession), object(NULL_PTR), isPrivate(false)
38 | {
39 | }
40 |
41 | Handle::Handle(CK_HANDLE_KIND _kind, CK_SLOT_ID _slotID)
42 | : kind(_kind), slotID(_slotID), hSession(CK_INVALID_HANDLE), object(NULL_PTR), isPrivate(false)
43 | {
44 | }
45 |
46 | Handle::Handle()
47 | : kind(CKH_INVALID), slotID(0), hSession(CK_INVALID_HANDLE), object(NULL_PTR), isPrivate(false)
48 | {
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/handle_mgr/Handle.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 SURFnet bv
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 | Handle.h
29 |
30 | This class represents a single handle
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_HANDLE_H
34 | #define _SOFTHSM_V2_HANDLE_H
35 |
36 | #include "cryptoki.h"
37 |
38 | enum {
39 | CKH_INVALID,
40 | CKH_SESSION,
41 | CKH_OBJECT
42 | };
43 |
44 | #define CK_HANDLE_KIND CK_ULONG
45 |
46 | class Handle
47 | {
48 | public:
49 | Handle(CK_HANDLE_KIND kind, CK_SLOT_ID slotID, CK_SESSION_HANDLE hSession);
50 | Handle(CK_HANDLE_KIND kind, CK_SLOT_ID slotID);
51 | Handle();
52 |
53 | CK_HANDLE_KIND kind;
54 | CK_SLOT_ID slotID;
55 | CK_SESSION_HANDLE hSession;
56 |
57 | CK_VOID_PTR object;
58 | bool isPrivate;
59 | };
60 |
61 | #endif // !_SOFTHSM_V2_HANDLE_H
62 |
63 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/handle_mgr/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/.. \
4 | -I$(srcdir)/../common \
5 | -I$(srcdir)/../crypto \
6 | -I$(srcdir)/../data_mgr \
7 | -I$(srcdir)/../object_store \
8 | -I$(srcdir)/../slot_mgr \
9 | -I$(SGXSDKDIR)/include \
10 | -I$(SGXSDKDIR)/include/tlibc \
11 | -I$(SGXSDKDIR)/include/libcxx \
12 | -I$(SGXSDKDIR)/include/stdc++ \
13 | -I$(SGXSDKDIR)/include/stlport
14 |
15 | if WITH_P11_KIT
16 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
17 | else
18 | AM_CPPFLAGS += -I$(srcdir)/../pkcs11
19 | endif
20 |
21 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
22 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
23 |
24 | noinst_LTLIBRARIES = libsofthsm_handlemgr.la
25 | libsofthsm_handlemgr_la_SOURCES = HandleManager.cpp \
26 | Handle.cpp
27 |
28 | EXTRA_DIST = $(srcdir)/*.h
29 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/object_store/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(softhsm_objectstore)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/../common
5 | ${PROJECT_SOURCE_DIR}/../crypto
6 | ${PROJECT_SOURCE_DIR}/../data_mgr
7 | ${PROJECT_SOURCE_DIR}/../pkcs11
8 | ${SQLITE3_INCLUDES}
9 | )
10 |
11 | set(SOURCES Directory.cpp
12 | File.cpp
13 | FindOperation.cpp
14 | Generation.cpp
15 | ObjectFile.cpp
16 | ObjectStore.cpp
17 | ObjectStoreToken.cpp
18 | OSAttribute.cpp
19 | OSToken.cpp
20 | SessionObject.cpp
21 | SessionObjectStore.cpp
22 | UUID.cpp
23 | )
24 |
25 | if(WITH_OBJECTSTORE_BACKEND_DB)
26 | list(APPEND SOURCES DB.cpp
27 | DBObject.cpp
28 | DBToken.cpp
29 | )
30 | endif(WITH_OBJECTSTORE_BACKEND_DB)
31 |
32 |
33 | include_directories(${INCLUDE_DIRS})
34 |
35 | add_library(${PROJECT_NAME} OBJECT ${SOURCES})
36 | # Versions before CMake 3.12 cannot use target_link_libraries on object
37 | # libraries, a workaround exists in src/lib/CMakeLists.txt.
38 | if(NOT CMAKE_VERSION VERSION_LESS "3.12")
39 | target_link_libraries(${PROJECT_NAME} ${SQLITE3_LIBS})
40 | endif()
41 |
42 | if(BUILD_TESTS)
43 | add_subdirectory(test)
44 | endif(BUILD_TESTS)
45 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/object_store/FindOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 SURFnet bv
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 | FindOperation.h
29 |
30 | This class represents the find operation that can be used to collect
31 | objects that match the attributes contained in a given template.
32 | *****************************************************************************/
33 |
34 | #ifndef _SOFTHSM_V2_FINDOPERATION_H
35 | #define _SOFTHSM_V2_FINDOPERATION_H
36 |
37 | #include "config.h"
38 |
39 | #include
40 | #include "OSObject.h"
41 |
42 | class FindOperation
43 | {
44 | public:
45 | // Factory method creates a new find operation
46 | static FindOperation* create();
47 |
48 | // Hand this operation back to the factory for recycling.
49 | void recycle();
50 |
51 | // Add the objects from thet set that match the attributes in the given template to the find operation.
52 | void setHandles(const std::set &handles);
53 |
54 | // Retrieve handles
55 | CK_ULONG retrieveHandles(CK_OBJECT_HANDLE_PTR phObject, CK_ULONG ulCount);
56 |
57 | // Erase handles from the handles set.
58 | CK_ULONG eraseHandles(CK_ULONG ulIndex, CK_ULONG ulCount);
59 |
60 | protected:
61 | // Use a protected constructor to force creation via factory method.
62 | FindOperation();
63 |
64 | std::set _handles;
65 | };
66 |
67 | #endif // _SOFTHSM_V2_FINDOPERATION_H
68 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/object_store/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/.. \
4 | -I$(srcdir)/../common \
5 | -I$(srcdir)/../crypto \
6 | -I$(srcdir)/../data_mgr \
7 | -I$(srcdir)/../.. \
8 | -I$(builddir)/../../../trusted/ \
9 | -I$(srcdir)/../../../../../ \
10 | -I$(SGXSDKDIR)/include \
11 | -I$(SGXSDKDIR)/include/tlibc \
12 | -I$(SGXSDKDIR)/include/libcxx \
13 | -I$(SGXSDKDIR)/include/stdc++ \
14 | -I$(SGXSDKDIR)/include/stlport
15 |
16 | if WITH_P11_KIT
17 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
18 | else
19 | AM_CPPFLAGS += -I$(srcdir)/../pkcs11
20 | endif
21 |
22 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
23 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
24 |
25 | noinst_LTLIBRARIES = libsofthsm_objectstore.la
26 | libsofthsm_objectstore_la_SOURCES = ObjectStore.cpp \
27 | UUID.cpp \
28 | Directory.cpp \
29 | File.cpp \
30 | Generation.cpp \
31 | OSAttribute.cpp \
32 | OSToken.cpp \
33 | ObjectFile.cpp \
34 | SessionObject.cpp \
35 | SessionObjectStore.cpp \
36 | FindOperation.cpp \
37 | ObjectStoreToken.cpp
38 |
39 | EXTRA_DIST = $(srcdir)/*.h
40 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/object_store/UUID.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 SURFnet bv
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 | UUID.h
29 |
30 | UUID generation helper functions; for now, this just wraps the OSF/DCE's
31 | UUID generation implementation, but if SoftHSM gets ported to non UNIX/BSD-
32 | like OSes this may incorporate other implementations
33 | *****************************************************************************/
34 |
35 | #ifndef _SOFTHSM_V2_UUID_H
36 | #define _SOFTHSM_V2_UUID_H
37 |
38 | #include "config.h"
39 | #include
40 |
41 | namespace UUID
42 | {
43 | // Generate a new UUID string
44 | std::string newUUID();
45 | }
46 |
47 | #endif // !_SOFTHSM_V2_UUID_H
48 |
49 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/session_mgr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(softhsm_sessionmgr)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/../common
5 | ${PROJECT_SOURCE_DIR}/../crypto
6 | ${PROJECT_SOURCE_DIR}/../data_mgr
7 | ${PROJECT_SOURCE_DIR}/../object_store
8 | ${PROJECT_SOURCE_DIR}/../pkcs11
9 | ${PROJECT_SOURCE_DIR}/../slot_mgr
10 | )
11 |
12 | set(SOURCES SessionManager.cpp
13 | Session.cpp
14 | )
15 |
16 | include_directories(${INCLUDE_DIRS})
17 |
18 | add_library(${PROJECT_NAME} OBJECT ${SOURCES})
19 |
20 | if(BUILD_TESTS)
21 | add_subdirectory(test)
22 | endif(BUILD_TESTS)
23 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/session_mgr/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/.. \
4 | -I$(srcdir)/../common \
5 | -I$(srcdir)/../crypto \
6 | -I$(srcdir)/../data_mgr \
7 | -I$(srcdir)/../object_store \
8 | -I$(srcdir)/../slot_mgr \
9 | -I$(SGXSDKDIR)/include/ \
10 | -I$(SGXSDKDIR)/include/tlibc \
11 | -I$(SGXSDKDIR)/include/libcxx \
12 | -I$(SGXSDKDIR)/include/stdc++ \
13 | -I$(SGXSDKDIR)/include/stlport
14 |
15 | if WITH_P11_KIT
16 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
17 | else
18 | AM_CPPFLAGS += -I$(srcdir)/../pkcs11
19 | endif
20 |
21 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
22 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
23 |
24 | noinst_LTLIBRARIES = libsofthsm_sessionmgr.la
25 | libsofthsm_sessionmgr_la_SOURCES = SessionManager.cpp \
26 | Session.cpp
27 |
28 | EXTRA_DIST = $(srcdir)/*.h
29 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/slot_mgr/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(softhsm_slotmgr)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/../common
5 | ${PROJECT_SOURCE_DIR}/../crypto
6 | ${PROJECT_SOURCE_DIR}/../data_mgr
7 | ${PROJECT_SOURCE_DIR}/../object_store
8 | ${PROJECT_SOURCE_DIR}/../pkcs11
9 | ${PROJECT_SOURCE_DIR}/../session_mgr
10 | )
11 |
12 | set(SOURCES SlotManager.cpp
13 | Slot.cpp
14 | Token.cpp
15 | )
16 |
17 | include_directories(${INCLUDE_DIRS})
18 |
19 | add_library(${PROJECT_NAME} OBJECT ${SOURCES})
20 |
21 | if(BUILD_TESTS)
22 | add_subdirectory(test)
23 | endif(BUILD_TESTS)
24 |
--------------------------------------------------------------------------------
/src/p11/trusted/SoftHSMv2/slot_mgr/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | AM_CPPFLAGS = -I$(srcdir)/.. \
4 | -I$(srcdir)/../common \
5 | -I$(srcdir)/../crypto \
6 | -I$(srcdir)/../data_mgr \
7 | -I$(srcdir)/../object_store \
8 | -I$(srcdir)/../session_mgr \
9 | -I$(SGXSDKDIR)/include \
10 | -I$(SGXSDKDIR)/include/tlibc \
11 | -I$(SGXSDKDIR)/include/libcxx \
12 | -I$(SGXSDKDIR)/include/stdc++ \
13 | -I$(SGXSDKDIR)/include/stlport
14 |
15 | if WITH_P11_KIT
16 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
17 | else
18 | AM_CPPFLAGS += -I$(srcdir)/../pkcs11
19 | endif
20 |
21 | AM_CFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c11 -O3 -Wall -Wno-implicit-function-declaration -nostdinc -fno-builtin-printf -fvisibility=hidden -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
22 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -DOSID=1 -m64 -std=c++11 -O3 -Wall -nostdinc++ -fstack-protector -fpie -fpic -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
23 |
24 | noinst_LTLIBRARIES = libsofthsm_slotmgr.la
25 |
26 | libsofthsm_slotmgr_la_SOURCES = SlotManager.cpp \
27 | Slot.cpp \
28 | Token.cpp
29 |
30 | EXTRA_DIST = $(srcdir)/*.h
31 |
--------------------------------------------------------------------------------
/src/p11/untrusted/Parallel.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #include "Parallel.h"
33 | #include "EnclaveInterface.h"
34 | #include "p11Sgx.h"
35 |
36 | //---------------------------------------------------------------------------------------------
37 | CK_RV getFunctionStatus(CK_SESSION_HANDLE hSession)
38 | {
39 | if (!isInitialized())
40 | {
41 | return CKR_CRYPTOKI_NOT_INITIALIZED;
42 | }
43 |
44 | return EnclaveInterface::getFunctionStatus(hSession);
45 |
46 |
47 | }
48 |
49 | //---------------------------------------------------------------------------------------------
50 | CK_RV cancelFunction(CK_SESSION_HANDLE hSession)
51 | {
52 | if (!isInitialized())
53 | {
54 | return CKR_CRYPTOKI_NOT_INITIALIZED;
55 | }
56 |
57 | return EnclaveInterface::cancelFunction(hSession);
58 | }
59 |
--------------------------------------------------------------------------------
/src/p11/untrusted/Parallel.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #ifndef PARALLEL_H
33 | #define PARALLEL_H
34 |
35 | #include "cryptoki.h"
36 |
37 | /**
38 | * Legacy function.
39 | * @param hSession The session handle.
40 | * @return CK_RV Returns CKR_FUNCTION_NOT_PARALLEL
41 | */
42 | CK_RV getFunctionStatus(CK_SESSION_HANDLE hSession);
43 |
44 | /**
45 | * Legacy function.
46 | * @param hSession The session handle.
47 | * @return CK_RV Returns CKR_FUNCTION_NOT_PARALLEL
48 | */
49 | CK_RV cancelFunction(CK_SESSION_HANDLE hSession);
50 |
51 | #endif // PARALLEL_H
--------------------------------------------------------------------------------
/src/p11/untrusted/RNG.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #include "RNG.h"
33 | #include "EnclaveInterface.h"
34 | #include "p11Sgx.h"
35 |
36 | //---------------------------------------------------------------------------------------------
37 | CK_RV seedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed, CK_ULONG ulSeedLen)
38 | {
39 | if (!isInitialized())
40 | {
41 | return CKR_CRYPTOKI_NOT_INITIALIZED;
42 | }
43 |
44 | return EnclaveInterface::seedRandom(hSession, pSeed, ulSeedLen);
45 | }
46 |
47 | //---------------------------------------------------------------------------------------------
48 | CK_RV generateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pRandomData, CK_ULONG ulRandomLen)
49 | {
50 | if (!isInitialized())
51 | {
52 | return CKR_CRYPTOKI_NOT_INITIALIZED;
53 | }
54 |
55 | return EnclaveInterface::generateRandom(hSession, pRandomData, ulRandomLen);
56 | }
57 |
--------------------------------------------------------------------------------
/src/p11/untrusted/RNG.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #ifndef RNG_H
33 | #define RNG_H
34 |
35 | #include "cryptoki.h"
36 |
37 | //---------------------------------------------------------------------------------------------
38 | CK_RV seedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed, CK_ULONG ulSeedLen);
39 |
40 | //---------------------------------------------------------------------------------------------
41 | CK_RV generateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pRandomData, CK_ULONG ulRandomLen);
42 |
43 | #endif //RNG_H
44 |
45 |
--------------------------------------------------------------------------------
/src/p11/untrusted/p11Sgx.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #include "p11Sgx.h"
33 |
34 | bool initialized = false;
35 | std::mutex initMutex;
36 |
37 | bool isInitialized()
38 | {
39 | return initialized;
40 | }
41 |
42 | void init()
43 | {
44 | std::lock_guard lock(initMutex);
45 | initialized = true;
46 | }
47 |
48 | void deinit()
49 | {
50 | std::lock_guard lock(initMutex);
51 | initialized = false;
52 | }
53 |
--------------------------------------------------------------------------------
/src/p11/untrusted/p11Sgx.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2020 Intel Corporation
3 | *
4 | * Redistribution and use in source and binary forms, with or without
5 | * modification, are permitted provided that the following conditions
6 | * are met:
7 | *
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
12 | * the documentation and/or other materials provided with the
13 | * distribution.
14 | * 3. Neither the name of Intel Corporation nor the names of its
15 | * contributors may be used to endorse or promote products derived
16 | * from this software without specific prior written permission.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | *
30 | */
31 |
32 | #ifndef P11SGX_H
33 | #define P11SGX_H
34 |
35 | #include
36 | #include
37 |
38 | /**
39 | * Initializes session cache.
40 | */
41 | void init();
42 |
43 | /**
44 | * Checks if session cache is initialized.
45 | * @return bool Returns true if initialized, false otherwise.
46 | */
47 | bool isInitialized();
48 |
49 | /**
50 | * Deinitializes session cache.
51 | */
52 | void deinit();
53 |
54 | #endif // P11SGX_H
--------------------------------------------------------------------------------
/src/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(p11test)
2 |
3 | set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
4 | ${PROJECT_SOURCE_DIR}/..
5 | ${PROJECT_SOURCE_DIR}/../common
6 | ${PROJECT_SOURCE_DIR}/../pkcs11
7 | ${CPPUNIT_INCLUDES}
8 | )
9 |
10 | set(SOURCES p11test.cpp
11 | SymmetricAlgorithmTests.cpp
12 | DigestTests.cpp
13 | InitTests.cpp
14 | InfoTests.cpp
15 | RandomTests.cpp
16 | SessionTests.cpp
17 | TokenTests.cpp
18 | UserTests.cpp
19 | ObjectTests.cpp
20 | DeriveTests.cpp
21 | SignVerifyTests.cpp
22 | AsymEncryptDecryptTests.cpp
23 | AsymWrapUnwrapTests.cpp
24 | TestsBase.cpp
25 | TestsNoPINInitBase.cpp
26 | ../common/log.cpp
27 | ../common/osmutex.cpp
28 | )
29 |
30 | include_directories(${INCLUDE_DIRS})
31 |
32 | add_executable(${PROJECT_NAME} ${SOURCES})
33 | target_link_libraries(${PROJECT_NAME} softhsm2-static ${CRYPTO_LIBS} ${CPPUNIT_LIBS} ${SQLITE3_LIBS})
34 | set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS -pthread)
35 |
36 | add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}
37 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
38 | )
39 |
40 | set(builddir ${PROJECT_BINARY_DIR})
41 | configure_file(softhsm2.conf.in softhsm2.conf)
42 | configure_file(softhsm2-alt.conf.in softhsm2-alt.conf)
43 | configure_file(softhsm2-mech.conf.in softhsm2-mech.conf)
44 | configure_file(tokens/dummy.in tokens/dummy)
45 |
--------------------------------------------------------------------------------
/src/test/InitTests.h:
--------------------------------------------------------------------------------
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 | InitTests.h
29 |
30 | Contains test cases to C_Initialize and C_Finalize
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_INITTESTS_H
34 | #define _SOFTHSM_V2_INITTESTS_H
35 |
36 | #include
37 | #include "TestsNoPINInitBase.h"
38 |
39 | class InitTests : public TestsNoPINInitBase
40 | {
41 | CPPUNIT_TEST_SUITE(InitTests);
42 | CPPUNIT_TEST(testInit1);
43 | CPPUNIT_TEST(testInit2);
44 | CPPUNIT_TEST(testInit3);
45 | CPPUNIT_TEST(testInit4);
46 | CPPUNIT_TEST(testInit5);
47 | CPPUNIT_TEST(testInit6);
48 | CPPUNIT_TEST(testFinal);
49 | CPPUNIT_TEST_SUITE_END();
50 |
51 | public:
52 | void testInit1();
53 | void testInit2();
54 | void testInit3();
55 | void testInit4();
56 | void testInit5();
57 | void testInit6();
58 | void testFinal();
59 |
60 | virtual void setUp();
61 | virtual void tearDown();
62 | };
63 |
64 | #endif // !_SOFTHSM_V2_INITTESTS_H
65 |
66 |
--------------------------------------------------------------------------------
/src/test/Makefile.am:
--------------------------------------------------------------------------------
1 | MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
2 |
3 | if WITH_DCAP
4 | AM_CPPFLAGS = -I$(srcdir)/.. \
5 | -I$(DCAP_INCLUDE_PATH) \
6 | -I$(SGXSDKDIR)/include \
7 | -I$(srcdir)/../p11/trusted/SoftHSMv2/common
8 | DCAP_LIB = -lsgx_dcap_ql
9 | else
10 | AM_CPPFLAGS = -I$(srcdir)/.. \
11 | -I$(SGXSDKDIR)/include \
12 | -I$(srcdir)/../p11/trusted/SoftHSMv2/common
13 | DCAP_LIB =
14 | endif
15 |
16 | if WITH_P11_KIT
17 | AM_CPPFLAGS += -I$(P11_KIT_INCLUDE_PATH)
18 | else
19 | AM_CPPFLAGS += -I$(srcdir)/../p11/trusted/SoftHSMv2/pkcs11
20 | endif
21 |
22 | AM_CXXFLAGS = -D_FORTIFY_SOURCE=2 -m64 -std=c++11 -fpie -fpic -fstack-protector -Wformat -Wformat-security -fexceptions -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -Wreturn-type -Werror=return-type
23 |
24 | noinst_PROGRAMS = p11test
25 |
26 | p11test_SOURCES = p11test.cpp \
27 | SymmetricAlgorithmTests.cpp \
28 | UnwrapKeyHelper.cpp \
29 | DigestTests.cpp \
30 | InitTests.cpp \
31 | InfoTests.cpp \
32 | RandomTests.cpp \
33 | SessionTests.cpp \
34 | TokenTests.cpp \
35 | UserTests.cpp \
36 | ObjectTests.cpp \
37 | SignVerifyTests.cpp \
38 | AsymEncryptDecryptTests.cpp \
39 | AsymWrapUnwrapTests.cpp \
40 | UnsupportedAPITests.cpp \
41 | TestsBase.cpp \
42 | TestsNoPINInitBase.cpp
43 | AM_LDFLAGS = -ldl $(DCAP_LIB) -L../p11/untrusted/.libs -lp11sgx -lcppunit -no-install -pthread -L/usr/local/lib -lssl -lcrypto -static -Wl,-z,relro -Wl,-z,now
44 |
45 | EXTRA_DIST = $(srcdir)/*.h
46 |
--------------------------------------------------------------------------------
/src/test/README:
--------------------------------------------------------------------------------
1 | To build for test of SoftHSM with static linking:
2 | make p11test
3 |
4 | To build for testing another p11 module provided as shared library:
5 | make p11test_DEPENDENCIES= p11test_LDADD= CPPFLAGS=-DP11M=\\\"./p11m.so\\\" p11test
6 | Substitute ./p11m.so with the path to your shared library.
7 | Note that nothing else of SoftHSMv2 has to be built in order to build the test of an external p11.
8 |
9 | To run the test with first a test summary and then specific output of each failure:
10 | ./p11test
11 |
12 | To get output of each test after it is executed:
13 | ./p11test direct
14 |
15 | To run a specific test:
16 | ./p11test ObjectTests::testArrayAttribute
17 | Substitute 'ObjectTests::testArrayAttribute' with the test you want to run.
18 |
--------------------------------------------------------------------------------
/src/test/SessionTests.h:
--------------------------------------------------------------------------------
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 | SessionTests.h
29 |
30 | Contains test cases to C_OpenSession, C_CloseSession, C_CloseAllSessions, and
31 | C_GetSessionInfo
32 | *****************************************************************************/
33 |
34 | #ifndef _SOFTHSM_V2_SESSIONTESTS_H
35 | #define _SOFTHSM_V2_SESSIONTESTS_H
36 |
37 | #include "TestsNoPINInitBase.h"
38 | #include
39 |
40 | class SessionTests : public TestsNoPINInitBase
41 | {
42 | CPPUNIT_TEST_SUITE(SessionTests);
43 | CPPUNIT_TEST(testOpenSession);
44 | CPPUNIT_TEST(testCloseSession);
45 | CPPUNIT_TEST(testCloseAllSessions);
46 | CPPUNIT_TEST(testGetSessionInfo);
47 | CPPUNIT_TEST_SUITE_END();
48 |
49 | public:
50 | void testOpenSession();
51 | void testCloseSession();
52 | void testCloseAllSessions();
53 | void testGetSessionInfo();
54 | };
55 |
56 | #endif // !_SOFTHSM_V2_SESSIONTESTS_H
57 |
58 |
--------------------------------------------------------------------------------
/src/test/TestsBase.cpp:
--------------------------------------------------------------------------------
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 | TestsBase.cpp
29 |
30 | Base class for test classes.
31 | *****************************************************************************/
32 |
33 | #include "TestsBase.h"
34 | #include
35 |
36 | void TestsBase::setUp() {
37 | TestsNoPINInitBase::setUp();
38 |
39 | CK_SESSION_HANDLE hSession;
40 |
41 | // Open session
42 | CPPUNIT_ASSERT( CRYPTOKI_F_PTR( C_OpenSession(m_initializedTokenSlotID, CKF_SERIAL_SESSION|CKF_RW_SESSION, NULL_PTR, NULL_PTR, &hSession)==CKR_OK ) );
43 |
44 | // Login SO
45 | CPPUNIT_ASSERT( CRYPTOKI_F_PTR( C_Login(hSession,CKU_SO, m_soPin1, m_soPin1Length)==CKR_OK ) );
46 |
47 | // Initialize the user pin
48 | CPPUNIT_ASSERT( CRYPTOKI_F_PTR( C_InitPIN(hSession, m_userPin1, m_userPin1Length)==CKR_OK ) );
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/TestsBase.h:
--------------------------------------------------------------------------------
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 | TestsBase.h
29 |
30 | Base class for test classes.
31 | *****************************************************************************/
32 |
33 | #ifndef SRC_LIB_TEST_TESTSBASE_H_
34 | #define SRC_LIB_TEST_TESTSBASE_H_
35 |
36 | #include
37 |
38 | class TestsBase : public TestsNoPINInitBase {
39 | public:
40 | virtual void setUp();
41 | };
42 |
43 |
44 | #endif /* SRC_LIB_TEST_TESTSBASE_H_ */
45 |
--------------------------------------------------------------------------------
/src/test/TestsNoPINInitBase.h:
--------------------------------------------------------------------------------
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 | TestsNoPINInitBase.h
29 |
30 | Base class for test classes. Used when there is no need for user login.
31 | *****************************************************************************/
32 |
33 | #ifndef SRC_LIB_TEST_TESTSNOPININITBASE_H_
34 | #define SRC_LIB_TEST_TESTSNOPININITBASE_H_
35 |
36 | #include "cryptoki.h"
37 | #include
38 |
39 |
40 | #ifdef P11M
41 | #define CRYPTOKI_F_PTR(func) m_ptr->func
42 | #else
43 | #define CRYPTOKI_F_PTR(func) func
44 | #endif
45 |
46 | class TestsNoPINInitBase : public CppUnit::TestFixture {
47 | public:
48 | TestsNoPINInitBase();
49 | virtual ~TestsNoPINInitBase();
50 |
51 | virtual void setUp();
52 | virtual void tearDown();
53 | private:
54 | void getSlotIDs();
55 | #ifdef P11M
56 | #ifdef _WIN32
57 | HINSTANCE__* p11Library;
58 | #else
59 | void *const p11Library;
60 | #endif
61 | protected:
62 | const CK_FUNCTION_LIST_PTR m_ptr;
63 | #else
64 | protected:
65 | #endif
66 | const CK_SLOT_ID m_invalidSlotID;
67 | CK_SLOT_ID m_initializedTokenSlotID;
68 | CK_SLOT_ID m_notInitializedTokenSlotID;
69 |
70 | const CK_UTF8CHAR_PTR m_soPin1;
71 | const CK_ULONG m_soPin1Length;
72 |
73 | const CK_UTF8CHAR_PTR m_userPin1;
74 | const CK_ULONG m_userPin1Length;
75 | };
76 |
77 |
78 | #endif /* SRC_LIB_TEST_TESTSNOPININITBASE_H_ */
79 |
--------------------------------------------------------------------------------
/src/test/TokenTests.h:
--------------------------------------------------------------------------------
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 | TokenTests.h
29 |
30 | Contains test cases to C_InitToken
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_TOKENTESTS_H
34 | #define _SOFTHSM_V2_TOKENTESTS_H
35 |
36 | #include "TestsNoPINInitBase.h"
37 | #include
38 |
39 | class TokenTests : public TestsNoPINInitBase
40 | {
41 | CPPUNIT_TEST_SUITE(TokenTests);
42 | CPPUNIT_TEST(testInitToken);
43 | CPPUNIT_TEST_SUITE_END();
44 |
45 | public:
46 | void testInitToken();
47 | };
48 |
49 | #endif // !_SOFTHSM_V2_TOKENTESTS_H
50 |
51 |
--------------------------------------------------------------------------------
/src/test/UserTests.h:
--------------------------------------------------------------------------------
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 | UserTests.h
29 |
30 | Contains test cases to C_InitPIN, C_SetPIN, C_Login, and C_Logout
31 | *****************************************************************************/
32 |
33 | #ifndef _SOFTHSM_V2_USERTESTS_H
34 | #define _SOFTHSM_V2_USERTESTS_H
35 |
36 | #include "TestsNoPINInitBase.h"
37 | #include
38 |
39 | class UserTests : public TestsNoPINInitBase
40 | {
41 | CPPUNIT_TEST_SUITE(UserTests);
42 | CPPUNIT_TEST(testInitPIN);
43 | CPPUNIT_TEST(testLogin);
44 | CPPUNIT_TEST(testLogout);
45 | CPPUNIT_TEST(testSetPIN);
46 | CPPUNIT_TEST_SUITE_END();
47 |
48 | public:
49 | void testInitPIN();
50 | void testLogin();
51 | void testLogout();
52 | void testSetPIN();
53 | };
54 |
55 | #endif // !_SOFTHSM_V2_USERTESTS_H
56 |
57 |
--------------------------------------------------------------------------------
/src/test/softhsm2-alt.conf:
--------------------------------------------------------------------------------
1 | # SoftHSM v2 configuration file
2 |
3 | directories.tokendir = ./tokens
4 | objectstore.backend = file
5 | log.level = INFO
6 | slots.removable = true
7 |
--------------------------------------------------------------------------------
/src/test/softhsm2-alt.conf.win32:
--------------------------------------------------------------------------------
1 | # SoftHSM v2 configuration file
2 |
3 | directories.tokendir = .\tokens
4 | objectstore.backend = file
5 | log.level = INFO
6 | slots.removable = true
7 |
--------------------------------------------------------------------------------
/src/test/softhsm2-mech.conf:
--------------------------------------------------------------------------------
1 | # SoftHSM v2 configuration file
2 |
3 | directories.tokendir = ./tokens
4 | objectstore.backend = file
5 | log.level = INFO
6 | slots.removable = false
7 | token.mechanisms = CKM_RSA_X_509,CKM_RSA_PKCS
8 |
9 |
--------------------------------------------------------------------------------
/src/test/softhsm2-mech.conf.win32:
--------------------------------------------------------------------------------
1 | # SoftHSM v2 configuration file
2 |
3 | directories.tokendir = .\tokens
4 | objectstore.backend = file
5 | log.level = INFO
6 | slots.removable = false
7 | token.mechanisms = CKM_RSA_X_509,CKM_RSA_PKCS
8 |
--------------------------------------------------------------------------------
/src/test/softhsm2.conf:
--------------------------------------------------------------------------------
1 | # SoftHSM v2 configuration file
2 |
3 | directories.tokendir = ./tokens
4 | objectstore.backend = file
5 | log.level = INFO
6 | slots.removable = false
7 |
--------------------------------------------------------------------------------
/src/test/softhsm2.conf.win32:
--------------------------------------------------------------------------------
1 | # SoftHSM v2 configuration file
2 |
3 | directories.tokendir = .\tokens
4 | objectstore.backend = file
5 | log.level = INFO
6 | slots.removable = false
7 |
--------------------------------------------------------------------------------
/src/test/tokens/2b371574-9ba7-f72c-12e4-fb4f8b69a8e/generation:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/crypto-api-toolkit/c50cf7dc0714966f2a837a6bbc0d66551c6b788f/src/test/tokens/2b371574-9ba7-f72c-12e4-fb4f8b69a8e/generation
--------------------------------------------------------------------------------
/src/test/tokens/2b371574-9ba7-f72c-12e4-fb4f8b69a8e/token.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/crypto-api-toolkit/c50cf7dc0714966f2a837a6bbc0d66551c6b788f/src/test/tokens/2b371574-9ba7-f72c-12e4-fb4f8b69a8e/token.lock
--------------------------------------------------------------------------------
/src/test/tokens/2b371574-9ba7-f72c-12e4-fb4f8b69a8e/token.object:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/crypto-api-toolkit/c50cf7dc0714966f2a837a6bbc0d66551c6b788f/src/test/tokens/2b371574-9ba7-f72c-12e4-fb4f8b69a8e/token.object
--------------------------------------------------------------------------------
/src/test/tokens/dummy:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/crypto-api-toolkit/c50cf7dc0714966f2a837a6bbc0d66551c6b788f/src/test/tokens/dummy
--------------------------------------------------------------------------------