[pkg-opensc-commit] [libp11] 14/86: Fixed build on various OpenSSL versions
Eric Dorland
eric at moszumanska.debian.org
Sun Jul 24 21:40:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libp11.
commit 30948b491972b97b81164b3da0c40a8ea2a93506
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date: Fri Jan 22 19:59:50 2016 +0100
Fixed build on various OpenSSL versions
---
examples/rawrsasign.c | 39 ++++++++++++++++++++++++++++++++++++---
src/p11_rsa.c | 5 ++++-
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/examples/rawrsasign.c b/examples/rawrsasign.c
index 54c1372..d42f54a 100644
--- a/examples/rawrsasign.c
+++ b/examples/rawrsasign.c
@@ -35,6 +35,24 @@
#define END(x) do { ret = (x); goto end; } while (0)
+/* Missing functions for OpenSSL older than 1.1.0 */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+
+static EVP_MD_CTX *EVP_MD_CTX_new(void) {
+ EVP_MD_CTX *mctx;
+
+ mctx = OPENSSL_malloc(sizeof(EVP_MD_CTX));
+ if (mctx)
+ EVP_MD_CTX_init(mctx);
+ return mctx;
+}
+
+static void EVP_MD_CTX_free(EVP_MD_CTX *mctx) {
+ OPENSSL_free(mctx);
+}
+
+#endif
+
int main(int argc, char *argv[])
{
PKCS11_CTX *ctx = NULL;
@@ -43,9 +61,11 @@ int main(int argc, char *argv[])
PKCS11_KEY *authkey = NULL;
PKCS11_CERT *authcert = NULL;
- EVP_PKEY *pubkey = NULL;
EVP_MD_CTX *mctx = NULL;
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ EVP_PKEY *pubkey = NULL;
EVP_PKEY_CTX *pkeyctx = NULL;
+#endif
unsigned char *random = NULL, *signature = NULL;
@@ -245,8 +265,10 @@ loggedin:
fprintf(stderr, "PKCS11_private_encrypt failed\n");
END(1);
}
+ printf("Raw signing operation successfull.\n");
/* Verify the signature */
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
/* As we have done a PKCS#1 complient padding, we can verify the signature
* with "standard code", using openssl EVP interface.
*/
@@ -282,20 +304,31 @@ loggedin:
EVP_MD_CTX_free(mctx);
mctx = NULL;
- printf("raw signing operation and signature verification successfull.\n");
+ printf("Signature verification successfull.\n");
+#else
+ printf("Signature verification could not be performed "
+ "with the installed version of OpenSSL.\n");
+#endif
+
ret = 0;
end:
if (ret != 0) {
ERR_print_errors_fp(stderr);
- printf("raw signing operation failed.\n");
+ printf("Raw signing operation failed.\n");
}
+
if (mctx)
EVP_MD_CTX_free(mctx);
+
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
if (pubkey != NULL)
EVP_PKEY_free(pubkey);
+#endif
+
if (random != NULL)
OPENSSL_free(random);
+
if (signature != NULL)
OPENSSL_free(signature);
diff --git a/src/p11_rsa.c b/src/p11_rsa.c
index 1745efb..32d7895 100644
--- a/src/p11_rsa.c
+++ b/src/p11_rsa.c
@@ -175,7 +175,10 @@ static int pkcs11_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
*/
static int
pkcs11_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
- const unsigned char *signature, unsigned int siglen, const RSA * rsa)
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ const
+#endif
+ unsigned char *signature, unsigned int siglen, const RSA * rsa)
{
RSA *r = (RSA *) rsa; /* Ugly hack to get rid of compiler warning */
int res;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git
More information about the pkg-opensc-commit
mailing list