You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ka...@apache.org on 2007/02/15 07:16:48 UTC

svn commit: r507829 - in /webservices/axis2/trunk/c/rampart: include/openssl_sign.h src/omxmlsec/openssl/Makefile.am src/omxmlsec/openssl/sign.c

Author: kaushalye
Date: Wed Feb 14 22:16:47 2007
New Revision: 507829

URL: http://svn.apache.org/viewvc?view=rev&rev=507829
Log:
Adding signature wrappers for openssl layer in OMXMLSecurity


Added:
    webservices/axis2/trunk/c/rampart/include/openssl_sign.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/sign.c
Modified:
    webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am

Added: webservices/axis2/trunk/c/rampart/include/openssl_sign.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/openssl_sign.h?view=auto&rev=507829
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/openssl_sign.h (added)
+++ webservices/axis2/trunk/c/rampart/include/openssl_sign.h Wed Feb 14 22:16:47 2007
@@ -0,0 +1,51 @@
+/*
+ *   Copyright 2003-2004 The Apache Software Foundation.
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ */
+
+#include <openssl/evp.h>
+#include <openssl_cipher_ctx.h>
+#include <openssl_constants.h>
+#include <oxs_sign_ctx.h>
+#include <axis2_util.h>
+
+/**
+  * @file openssl_sign.h 
+  * @brief 
+  */
+#ifndef OPENSSL_SIGN_H
+#define OPENSSL_SIGN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup
+ * @ingroup
+ * @{
+ */
+
+AXIS2_EXTERN int AXIS2_CALL
+openssl_sign(const axis2_env_t *env,
+        oxs_sign_ctx_t *sign_ctx,
+        oxs_buffer_t *input_buf,
+        oxs_buffer_t *output_buf);
+
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* OPENSSL_SIGN_H */

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am?view=diff&rev=507829&r1=507828&r2=507829
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am Wed Feb 14 22:16:47 2007
@@ -1,5 +1,5 @@
 noinst_LTLIBRARIES = libomopenssl.la
-libomopenssl_la_SOURCES = cipher_ctx.c crypt.c rsa.c pkey.c util.c cipher_property.c digest.c x509.c pkcs12.c pem.c
+libomopenssl_la_SOURCES = cipher_ctx.c crypt.c rsa.c pkey.c util.c cipher_property.c digest.c x509.c pkcs12.c pem.c sign.c
 
 libomopenssl_la_LIBADD  = -lssl\
 			../../../../util/src/libaxis2_util.la \

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/sign.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/sign.c?view=auto&rev=507829
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/sign.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/sign.c Wed Feb 14 22:16:47 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <axis2_util.h>
+#include <oxs_buffer.h>
+#include <oxs_key.h>
+#include <oxs_error.h>
+#include <openssl_cipher_ctx.h>
+#include <openssl_sign.h>
+#include <openssl_pkey.h>
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+#include <openssl/err.h>
+#include <openssl/pem.h>
+#include <openssl/ssl.h>
+#include <openssl/bio.h>
+
+#define BUFSIZE 64
+AXIS2_EXTERN int AXIS2_CALL
+openssl_sign(const axis2_env_t *env,
+        oxs_sign_ctx_t *sign_ctx,
+        oxs_buffer_t *input_buf,
+        oxs_buffer_t *output_buf)
+{
+    openssl_pkey_t *open_pkey = NULL;
+    unsigned char sig_buf[4096]; /*Allocate enough memory dynamically*/
+    unsigned int sig_len;
+    const EVP_MD*   digest;
+    EVP_MD_CTX      md_ctx;
+    EVP_PKEY*       pkey;
+    int err, ret;
+    /*Get the key*/
+    open_pkey = oxs_sign_ctx_get_private_key(sign_ctx, env);
+    pkey = OPENSSL_PKEY_GET_KEY(open_pkey, env);
+
+    /*Set the digest according to the signature method*/
+    digest = EVP_sha1();
+    /*Sign init*/
+    
+    ret = EVP_SignInit(&md_ctx, digest);
+    
+    EVP_SignUpdate (&md_ctx, OXS_BUFFER_GET_DATA(input_buf, env), OXS_BUFFER_GET_SIZE(input_buf, env));
+    sig_len = sizeof(sig_buf);
+    err = EVP_SignFinal (&md_ctx,
+               sig_buf,
+               &sig_len,
+               pkey);
+    if (err != 1) {  
+        ERR_print_errors_fp (stderr);     
+    }
+    /*Fill the output buffer*/
+    output_buf = oxs_buffer_create(env);
+    OXS_BUFFER_POPULATE(output_buf, env, sig_buf, sig_len);
+
+    return sig_len;
+}
+



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org