Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4e6e05b
misc changes
fxdupont Jun 1, 2013
61915f6
add HMAC Sign/Verify support
fxdupont Jun 1, 2013
b6a5cd7
complete DSA support
fxdupont Jun 1, 2013
a883e6d
add ECDSA support
fxdupont Jun 2, 2013
2022e9f
fix DSA merging conflicts
fxdupont Jun 2, 2013
5b2e4e8
add DH support
fxdupont Jun 2, 2013
bc645af
fix ECDSA merging conflicts
fxdupont Jun 2, 2013
25b92fc
add ECDH partial support
fxdupont Jun 2, 2013
d956e07
Merge branch 'ecdh' into work
fxdupont Jun 2, 2013
6362583
add RSA SHA224 support
fxdupont Jun 2, 2013
c39e385
rsa224 merge
fxdupont Jun 2, 2013
8ede158
bIsMultiPartOp mess
fxdupont Jun 2, 2013
9ba38f4
better Botan DSA parameter generation
fxdupont Jun 2, 2013
4077b8c
Merge branch 'dsaparam' into dsa
fxdupont Jun 2, 2013
c781e51
add alternate DSA mechanisms
fxdupont Jun 2, 2013
0c71671
merge alternate DSA mechanisms
fxdupont Jun 2, 2013
3a4a5ee
warn on ignored CKA_SUBPRIME_BITS
fxdupont Jun 2, 2013
3bbbb76
use Strong prime in DH
fxdupont Jun 2, 2013
bdb32d7
use Strong prime in DH
fxdupont Jun 2, 2013
94866a7
add ECC support in configure
fxdupont Jun 2, 2013
862cbc0
Merge branch 'ecc' into work
fxdupont Jun 2, 2013
8f2dce2
add ECC support in configure (WITH_ECC)
fxdupont Jun 2, 2013
fc2006f
made ECC code optional
fxdupont Jun 2, 2013
3cddd07
made ECC code optional
fxdupont Jun 2, 2013
e31ad3a
tentative implementation of higher ECDH
fxdupont Jun 2, 2013
f4a2cf2
tentative implementation of higher ECDH
fxdupont Jun 2, 2013
047b71d
improve style of last change
fxdupont Jun 3, 2013
d075ad6
improve style of last change
fxdupont Jun 3, 2013
ac2fd27
add some known vector tests
fxdupont Jun 3, 2013
3462d66
add test vectors for ECDSA and ECDH (still to be debugged under Botan…
fxdupont Jun 4, 2013
233c61a
Merge commit '3462d66' into work
fxdupont Jun 4, 2013
1e8d794
fix *DH code and reduce DH param generation to avoid loonnngggg checks
fxdupont Jun 5, 2013
ebab6cc
Revert "fix *DH code and reduce DH param generation to avoid loonnngg…
fxdupont Jun 5, 2013
a99804d
fix *DH code and reduce DH param generation to avoid loonnngggg checks
fxdupont Jun 5, 2013
b2b0f37
add GOST support
fxdupont Jun 10, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions m4/acx_botan_ecc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
AC_DEFUN([ACX_BOTAN_ECC],[
AC_MSG_CHECKING(for Botan ECC support)

tmp_CPPFLAGS=$CPPFLAGS
tmp_LIBS=$LIBS

CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES"
LIBS="$LIBS $CRYPTO_LIBS"

AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <botan/ec_group.h>
#include <botan/oids.h>
int main()
{
const std::string name("secp256r1");
const Botan::OID oid(Botan::OIDS::lookup(name));
const Botan::EC_Group ecg(oid);
try {
const Botan::SecureVector<Botan::byte> der =
ecg.DER_encode(Botan::EC_DOMPAR_ENC_OID);
} catch(...) {
return 1;
}
return 0;
}
]])
],[
AC_MSG_RESULT([Found P256])
],[
AC_MSG_RESULT([Cannot find P256])
AC_MSG_ERROR([
Botan library has no ECC support
or src/pubkey/ec_group/ec_group.cpp must be fixed: at line 124:
@@ -121,7 +121,7 @@
.get_contents();
}
else if(form == EC_DOMPAR_ENC_OID)
- return DER_Encoder().encode(get_oid()).get_contents();
+ return DER_Encoder().encode(OID(get_oid())).get_contents();
else if(form == EC_DOMPAR_ENC_IMPLICITCA)
return DER_Encoder().encode_null().get_contents();
else
])
],[])
AC_LANG_POP([C++])

CPPFLAGS=$tmp_CPPFLAGS
LIBS=$tmp_LIBS
])
33 changes: 33 additions & 0 deletions m4/acx_botan_gost.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
AC_DEFUN([ACX_BOTAN_GOST],[
AC_MSG_CHECKING(for Botan GOST support)

tmp_CPPFLAGS=$CPPFLAGS
tmp_LIBS=$LIBS

CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES"
LIBS="$LIBS $CRYPTO_LIBS"

AC_LANG_PUSH([C++])
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <botan/gost_3410.h>
#include <botan/oids.h>
int main()
{
const std::string name("gost_256A");
const Botan::OID oid(Botan::OIDS::lookup(name));
const Botan::EC_Group group(oid);
return 0;
}
]])
],[
AC_MSG_RESULT([Found GOST])
],[
AC_MSG_RESULT([Cannot find GOST])
AC_MSG_ERROR([Botan library has no GOST support])
],[])
AC_LANG_POP([C++])

CPPFLAGS=$tmp_CPPFLAGS
LIBS=$tmp_LIBS
])
38 changes: 37 additions & 1 deletion m4/acx_crypto_backend.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
AC_DEFUN([ACX_CRYPTO_BACKEND],[

# First check if we want to support GOST
# First check if we want to support ECC and GOST

AC_ARG_ENABLE(ecc,
AC_HELP_STRING([--enable-ecc],
[Enable support for ECC (default enabled)]
),
[enable_ecc="${enableval}"],
[enable_ecc="yes"]
)
AC_MSG_CHECKING(for ECC support)
if test "x${enable_ecc}" = "xyes"; then
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED(
[WITH_ECC],
[],
[Compile with ECC support]
)
else
AC_MSG_RESULT(no)
fi
AM_CONDITIONAL([WITH_ECC], [test "x${enable_ecc}" = "xyes"])

AC_ARG_ENABLE(gost,
AC_HELP_STRING([--enable-gost],
Expand Down Expand Up @@ -46,6 +66,14 @@ AC_DEFUN([ACX_CRYPTO_BACKEND],[
CRYPTO_INCLUDES=$OPENSSL_INCLUDES
CRYPTO_LIBS=$OPENSSL_LIBS

if test "x${enable_ecc}" = "xyes"; then
ACX_OPENSSL_ECC
fi

if test "x${enable_gost}" = "xyes"; then
ACX_OPENSSL_GOST
fi

AC_DEFINE_UNQUOTED(
[WITH_OPENSSL],
[],
Expand All @@ -64,6 +92,14 @@ AC_DEFUN([ACX_CRYPTO_BACKEND],[
CRYPTO_INCLUDES=$BOTAN_INCLUDES
CRYPTO_LIBS=$BOTAN_LIBS

if test "x${enable_ecc}" = "xyes"; then
ACX_BOTAN_ECC
fi

if test "x${enable_gost}" = "xyes"; then
ACX_BOTAN_GOST
fi

AC_DEFINE_UNQUOTED(
[WITH_BOTAN],
[],
Expand Down
36 changes: 36 additions & 0 deletions m4/acx_openssl_ecc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
AC_DEFUN([ACX_OPENSSL_ECC],[
AC_MSG_CHECKING(for OpenSSL ECC support)

tmp_CPPFLAGS=$CPPFLAGS
tmp_LIBS=$LIBS

CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES"
LIBS="$LIBS $CRYPTO_LIBS"

AC_LANG_PUSH([C])
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <openssl/ecdsa.h>
#include <openssl/objects.h>
int main()
{
EC_KEY *ec256, *ec384;

ec256 = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
ec384 = EC_KEY_new_by_curve_name(NID_secp384r1);
if (ec256 == NULL || ec384 == NULL)
return 1;
return 0;
}
]])
],[
AC_MSG_RESULT([Found P256 and P384])
],[
AC_MSG_RESULT([Cannot find P256 or P384])
AC_MSG_ERROR([OpenSSL library has no ECC support])
],[])
AC_LANG_POP([C])

CPPFLAGS=$tmp_CPPFLAGS
LIBS=$tmp_LIBS
])
41 changes: 41 additions & 0 deletions m4/acx_openssl_gost.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
AC_DEFUN([ACX_OPENSSL_GOST],[
AC_MSG_CHECKING(for OpenSSL GOST support)

tmp_CPPFLAGS=$CPPFLAGS
tmp_LIBS=$LIBS

CPPFLAGS="$CPPFLAGS $CRYPTO_INCLUDES"
LIBS="$LIBS $CRYPTO_LIBS"

AC_LANG_PUSH([C])
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
#include <openssl/conf.h>
#include <openssl/engine.h>
int main()
{
ENGINE *e;
EC_KEY *ek;

ek = NULL;
OPENSSL_config(NULL);

e = ENGINE_by_id("gost");
if (e == NULL)
return 1;
if (ENGINE_init(e) <= 0)
return 1;
return 0;
}
]])
],[
AC_MSG_RESULT([Found GOST engine])
],[
AC_MSG_RESULT([Cannot GOST engine])
AC_MSG_ERROR([OpenSSL library has no GOST support])
],[])
AC_LANG_POP([C])

CPPFLAGS=$tmp_CPPFLAGS
LIBS=$tmp_LIBS
])
1 change: 1 addition & 0 deletions src/bin/keyconv/softhsm-keyconv-botan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*****************************************************************************/

#include <config.h>
#define KEYCONV_BOTAN
#include "softhsm-keyconv.h"

#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions src/bin/keyconv/softhsm-keyconv-ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*****************************************************************************/

#include <config.h>
#define KEYCONV_OSSL
#include "softhsm-keyconv.h"

#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion src/bin/keyconv/softhsm-keyconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int to_pkcs8(char* in_path, char* out_path, char* file_pin)
switch (algorithm)
{
case DNS_KEYALG_ERROR:
fprintf(stderr, "ERROR: The algorithm was not given in the file.\n",
fprintf(stderr, "ERROR: The algorithm %i was not given in the file.\n",
algorithm);
error = 1;
break;
Expand Down
2 changes: 2 additions & 0 deletions src/bin/keyconv/softhsm-keyconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ int b64_ntop(const unsigned char*, size_t, char*, size_t);
#define MAX_LINE 4096

// The text fields supported
#if !defined(KEYCONV_BOTAN) && !defined(KEYCONV_OSSL)
static const char* file_tags[] = {
"Private-key-format:",
"Algorithm:",
Expand All @@ -105,6 +106,7 @@ static const char* file_tags[] = {
"Activate:",
NULL
};
#endif

// The number of each text field.
// Must match the tags above.
Expand Down
7 changes: 4 additions & 3 deletions src/bin/util/softhsm-util-botan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*****************************************************************************/

#include <config.h>
#define UTIL_BOTAN
#include "softhsm-util.h"
#include "softhsm-util-botan.h"

Expand Down Expand Up @@ -86,7 +87,7 @@ int crypto_import_key_pair
char* filePIN,
char* label,
char* objID,
int objIDLen,
size_t objIDLen,
int noPublicKey
)
{
Expand Down Expand Up @@ -176,7 +177,7 @@ int crypto_save_rsa
CK_SESSION_HANDLE hSession,
char* label,
char* objID,
int objIDLen,
size_t objIDLen,
int noPublicKey,
Botan::RSA_PrivateKey* rsa
)
Expand Down Expand Up @@ -335,7 +336,7 @@ int crypto_save_dsa
CK_SESSION_HANDLE hSession,
char* label,
char* objID,
int objIDLen,
size_t objIDLen,
int noPublicKey,
Botan::DSA_PrivateKey* dsa
)
Expand Down
4 changes: 2 additions & 2 deletions src/bin/util/softhsm-util-botan.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ typedef struct dsa_key_material_t {
Botan::Private_Key* crypto_read_file(char* filePath, char* filePIN);

// RSA
int crypto_save_rsa(CK_SESSION_HANDLE hSession, char* label, char* objID, int objIDLen, int noPublicKey, Botan::RSA_PrivateKey* rsa);
int crypto_save_rsa(CK_SESSION_HANDLE hSession, char* label, char* objID, size_t objIDLen, int noPublicKey, Botan::RSA_PrivateKey* rsa);
rsa_key_material_t* crypto_malloc_rsa(Botan::RSA_PrivateKey* rsa);
void crypto_free_rsa(rsa_key_material_t* keyMat);

// DSA
int crypto_save_dsa(CK_SESSION_HANDLE hSession, char* label, char* objID, int objIDLen, int noPublicKey, Botan::DSA_PrivateKey* dsa);
int crypto_save_dsa(CK_SESSION_HANDLE hSession, char* label, char* objID, size_t objIDLen, int noPublicKey, Botan::DSA_PrivateKey* dsa);
dsa_key_material_t* crypto_malloc_dsa(Botan::DSA_PrivateKey* dsa);
void crypto_free_dsa(dsa_key_material_t* keyMat);

Expand Down
7 changes: 4 additions & 3 deletions src/bin/util/softhsm-util-ossl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*****************************************************************************/

#include <config.h>
#define UTIL_OSSL
#include "softhsm-util.h"
#include "softhsm-util-ossl.h"

Expand Down Expand Up @@ -69,7 +70,7 @@ int crypto_import_key_pair
char* filePIN,
char* label,
char* objID,
int objIDLen,
size_t objIDLen,
int noPublicKey
)
{
Expand Down Expand Up @@ -194,7 +195,7 @@ int crypto_save_rsa
CK_SESSION_HANDLE hSession,
char* label,
char* objID,
int objIDLen,
size_t objIDLen,
int noPublicKey,
RSA* rsa
)
Expand Down Expand Up @@ -353,7 +354,7 @@ int crypto_save_dsa
CK_SESSION_HANDLE hSession,
char* label,
char* objID,
int objIDLen,
size_t objIDLen,
int noPublicKey,
DSA* dsa
)
Expand Down
4 changes: 2 additions & 2 deletions src/bin/util/softhsm-util-ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ typedef struct dsa_key_material_t {
EVP_PKEY* crypto_read_file(char* filePath, char* filePIN);

// RSA
int crypto_save_rsa(CK_SESSION_HANDLE hSession, char* label, char* objID, int objIDLen, int noPublicKey, RSA* rsa);
int crypto_save_rsa(CK_SESSION_HANDLE hSession, char* label, char* objID, size_t objIDLen, int noPublicKey, RSA* rsa);
rsa_key_material_t* crypto_malloc_rsa(RSA* rsa);
void crypto_free_rsa(rsa_key_material_t* keyMat);

// DSA
int crypto_save_dsa(CK_SESSION_HANDLE hSession, char* label, char* objID, int objIDLen, int noPublicKey, DSA* dsa);
int crypto_save_dsa(CK_SESSION_HANDLE hSession, char* label, char* objID, size_t objIDLen, int noPublicKey, DSA* dsa);
dsa_key_material_t* crypto_malloc_dsa(DSA* dsa);
void crypto_free_dsa(dsa_key_material_t* keyMat);

Expand Down
Loading