You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ka...@apache.org on 2007/03/02 08:35:46 UTC
svn commit: r513643 - in /webservices/axis2/trunk/c/rampart: configure.ac
test/omxmlsec/test.c test/openssl/Makefile.am test/openssl/sign/
test/openssl/sign/Makefile.am test/openssl/sign/cert.pem
test/openssl/sign/key.pem test/openssl/sign/test.c
Author: kaushalye
Date: Thu Mar 1 23:35:44 2007
New Revision: 513643
URL: http://svn.apache.org/viewvc?view=rev&rev=513643
Log:
Adding test case for signature.
This test case ensures wether the signing + verification works fine in the openssl wrapper layer of OMXMLSecurity.
Added:
webservices/axis2/trunk/c/rampart/test/openssl/sign/
webservices/axis2/trunk/c/rampart/test/openssl/sign/Makefile.am
webservices/axis2/trunk/c/rampart/test/openssl/sign/cert.pem
webservices/axis2/trunk/c/rampart/test/openssl/sign/key.pem
webservices/axis2/trunk/c/rampart/test/openssl/sign/test.c
Modified:
webservices/axis2/trunk/c/rampart/configure.ac
webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c
webservices/axis2/trunk/c/rampart/test/openssl/Makefile.am
Modified: webservices/axis2/trunk/c/rampart/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/configure.ac?view=diff&rev=513643&r1=513642&r2=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/configure.ac (original)
+++ webservices/axis2/trunk/c/rampart/configure.ac Thu Mar 1 23:35:44 2007
@@ -89,6 +89,7 @@
test/omxmlsec/Makefile \
test/c14n/Makefile \
test/openssl/Makefile
+ test/openssl/sign/Makefile
])
AC_OUTPUT
Modified: webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c?view=diff&rev=513643&r1=513642&r2=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Thu Mar 1 23:35:44 2007
@@ -177,7 +177,7 @@
axis2_char_t *filename = "input.xml";
axis2_char_t *certfile = "rsacert.pem";
axis2_char_t *prvkeyfile = "rsakey.pem";
- axis2_char_t *operation = "SIGN";
+ axis2_char_t *operation = "S";
openssl_pkey_t *prvkey = NULL;
oxs_x509_cert_t *cert = NULL;
@@ -207,7 +207,7 @@
printf("Cannot load certificate");
}
- if(0 == axis2_strcmp(operation, "SIGN")){
+ if(0 == axis2_strcmp(operation, "S")){
sign(env, filename, prvkey, cert);
}else{
verify(env, filename, prvkey, cert);
Modified: webservices/axis2/trunk/c/rampart/test/openssl/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/openssl/Makefile.am?view=diff&rev=513643&r1=513642&r2=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/openssl/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/test/openssl/Makefile.am Thu Mar 1 23:35:44 2007
@@ -1,4 +1,4 @@
-SUBDIRS =
+SUBDIRS = sign
Added: webservices/axis2/trunk/c/rampart/test/openssl/sign/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/openssl/sign/Makefile.am?view=auto&rev=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/openssl/sign/Makefile.am (added)
+++ webservices/axis2/trunk/c/rampart/test/openssl/sign/Makefile.am Thu Mar 1 23:35:44 2007
@@ -0,0 +1,23 @@
+TESTS = test
+bin_PROGRAMS = test
+SUBDIRS =
+
+AM_CFLAGS = -g -pthread
+
+#test_SOURCES = des_test.c
+test_SOURCES = test.c
+
+
+INCLUDES = -I$(top_builddir)/include \
+ -I ../../../../include \
+ -I ../../../../util/include \
+ -I ../../../../axiom/include
+
+test_LDADD = $(top_builddir)/src/util/librampart_util.la \
+ $(top_builddir)/src/omxmlsec/libomxmlsec.la \
+ $(top_builddir)/src/omxmlsec/openssl/libomopenssl.la \
+ $(top_builddir)/src/omxmlsec/tokens/liboxstokens.la \
+ ../../../../util/src/libaxis2_util.la \
+ ../../../../axiom/src/om/libaxis2_axiom.la \
+ ../../../../axiom/src/parser/libxml2/libaxis2_libxml2.la \
+ -lxml2
Added: webservices/axis2/trunk/c/rampart/test/openssl/sign/cert.pem
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/openssl/sign/cert.pem?view=auto&rev=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/openssl/sign/cert.pem (added)
+++ webservices/axis2/trunk/c/rampart/test/openssl/sign/cert.pem Thu Mar 1 23:35:44 2007
@@ -0,0 +1,62 @@
+Certificate:
+ Data:
+ Version: 3 (0x2)
+ Serial Number:
+ dc:83:fa:3c:1e:93:11:ae
+ Signature Algorithm: sha1WithRSAEncryption
+ Issuer: C=SL, ST=WP, O=WS, OU=C, CN=Kaushalye/emailAddress=kaus@wso2.com
+ Validity
+ Not Before: Dec 6 10:27:18 2006 GMT
+ Not After : Dec 6 10:27:18 2007 GMT
+ Subject: C=SL, ST=WP, L=Katubedda, O=WS, OU=C, CN=Aaa/emailAddress=aaa@ws.com
+ Subject Public Key Info:
+ Public Key Algorithm: rsaEncryption
+ RSA Public Key: (1024 bit)
+ Modulus (1024 bit):
+ 00:c7:e1:d8:5c:ef:16:dd:5d:05:95:c8:16:7c:2f:
+ f5:13:15:b4:7a:0c:c8:fb:95:c8:03:db:3d:a8:41:
+ 5d:70:75:ce:27:15:e2:a3:ef:87:24:38:5a:ee:72:
+ ea:70:c2:45:44:b5:dd:46:ca:51:60:15:ac:51:c3:
+ 59:af:a8:17:85:af:cd:77:74:87:b2:4b:ab:13:e0:
+ 00:82:2f:2a:d0:6b:12:7d:09:dc:52:dc:16:10:58:
+ 46:38:74:c7:cf:98:96:e3:58:ce:8a:c8:31:fa:77:
+ 6c:69:65:dc:a1:4c:38:e7:b0:9e:dc:64:06:ae:aa:
+ 13:90:23:62:84:14:c0:9e:31
+ Exponent: 65537 (0x10001)
+ X509v3 extensions:
+ X509v3 Basic Constraints:
+ CA:FALSE
+ Netscape Comment:
+ OpenSSL Generated Certificate
+ X509v3 Subject Key Identifier:
+ 67:B7:BC:8C:22:29:1E:17:58:C6:43:91:A6:FB:82:E7:11:77:62:D6
+ X509v3 Authority Key Identifier:
+ keyid:D7:27:10:74:4B:F8:2F:44:0B:BC:C7:9E:04:EF:22:5B:15:18:21:CC
+
+ Signature Algorithm: sha1WithRSAEncryption
+ 4d:36:00:f0:51:10:44:72:73:5f:09:e4:fe:ad:f4:5b:a0:48:
+ 5f:50:50:d7:bb:bb:2a:98:b3:b7:d7:54:9e:57:6d:d2:cd:de:
+ d5:d5:30:4d:c7:03:09:b4:7d:d8:72:17:f7:c6:e8:72:69:89:
+ b9:bc:91:5a:a8:c8:9e:ee:76:0b:c2:ae:c2:65:59:94:5b:fe:
+ a2:30:bf:aa:49:25:b1:42:bc:6d:c4:0a:99:aa:2d:17:14:d8:
+ 8d:19:cd:75:22:84:51:22:55:4e:e1:9e:50:1f:c6:c2:57:e1:
+ 4b:58:87:d5:73:c1:69:fd:25:dd:3d:50:ee:0e:9f:6a:9a:13:
+ 52:45
+-----BEGIN CERTIFICATE-----
+MIICzjCCAjegAwIBAgIJANyD+jwekxGuMA0GCSqGSIb3DQEBBQUAMGUxCzAJBgNV
+BAYTAlNMMQswCQYDVQQIEwJXUDELMAkGA1UEChMCV1MxCjAIBgNVBAsTAUMxEjAQ
+BgNVBAMTCUthdXNoYWx5ZTEcMBoGCSqGSIb3DQEJARYNa2F1c0B3c28yLmNvbTAe
+Fw0wNjEyMDYxMDI3MThaFw0wNzEyMDYxMDI3MThaMHAxCzAJBgNVBAYTAlNMMQsw
+CQYDVQQIEwJXUDESMBAGA1UEBxMJS2F0dWJlZGRhMQswCQYDVQQKEwJXUzEKMAgG
+A1UECxMBQzEMMAoGA1UEAxMDQWFhMRkwFwYJKoZIhvcNAQkBFgphYWFAd3MuY29t
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDH4dhc7xbdXQWVyBZ8L/UTFbR6
+DMj7lcgD2z2oQV1wdc4nFeKj74ckOFrucupwwkVEtd1GylFgFaxRw1mvqBeFr813
+dIeyS6sT4ACCLyrQaxJ9CdxS3BYQWEY4dMfPmJbjWM6KyDH6d2xpZdyhTDjnsJ7c
+ZAauqhOQI2KEFMCeMQIDAQABo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQf
+Fh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUZ7e8jCIp
+HhdYxkORpvuC5xF3YtYwHwYDVR0jBBgwFoAU1ycQdEv4L0QLvMeeBO8iWxUYIcww
+DQYJKoZIhvcNAQEFBQADgYEATTYA8FEQRHJzXwnk/q30W6BIX1BQ17u7Kpizt9dU
+nldt0s3e1dUwTccDCbR92HIX98bocmmJubyRWqjInu52C8KuwmVZlFv+ojC/qkkl
+sUK8bcQKmaotFxTYjRnNdSKEUSJVTuGeUB/GwlfhS1iH1XPBaf0l3T1Q7g6fapoT
+UkU=
+-----END CERTIFICATE-----
Added: webservices/axis2/trunk/c/rampart/test/openssl/sign/key.pem
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/openssl/sign/key.pem?view=auto&rev=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/openssl/sign/key.pem (added)
+++ webservices/axis2/trunk/c/rampart/test/openssl/sign/key.pem Thu Mar 1 23:35:44 2007
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDH4dhc7xbdXQWVyBZ8L/UTFbR6DMj7lcgD2z2oQV1wdc4nFeKj
+74ckOFrucupwwkVEtd1GylFgFaxRw1mvqBeFr813dIeyS6sT4ACCLyrQaxJ9CdxS
+3BYQWEY4dMfPmJbjWM6KyDH6d2xpZdyhTDjnsJ7cZAauqhOQI2KEFMCeMQIDAQAB
+AoGAQIrSvJ+PeIdTCFyFtjAeKL13e3mpZGOnJGek7zG8JFZF7SUJ+/maX726zwhY
+X3S7vUYkX3lw8V/ONtCnoyrZ/QQBqvUPUGg2XJI+NDYDrc3RR9YHTBFiYt791iXX
+2/hpQJV7Fj2K40AxAgcDmOmsjhMROhc52cERXNUTvqo+sIECQQD+WbS0NQL4kcRZ
+kELonmCHNAFA+vYvfB82RCspctNbfoZUAUPn/BMWTf9jZms89mDGfzaWKP5xd9aB
+Hi7sTp4JAkEAyS204Q36vnbDh5Dzz5YkJNFTdgyrLTBIQ5r4ax+K1i6V/Mwq07Zw
+SCvdDaTiBHOSaVJSHE38iwZZxUsWAs6I6QJADGFlcFgcOukte4aQGy6KWEppvTX6
+Abmy8ztCNpRGQW/ZLgGZwpL8gtttEPONSLxdXYwXpht8tx00LbjAY/Q3sQJAHqEg
+2ur/9COs3WUKWd6oHhrotB51qWmidviPPfANeVKab2S+WIF8UuCqxTsHVloqPnLU
+IY8WFiyfWlR2Q3MikQJASXg8KPM8C8Jp17iBbF5f09V18iA1fAbQSaLk3Lcbp1/h
+0VsiOHjW05LvI8zIHMX2Ops7qAjxixK1T/2ec9qhuQ==
+-----END RSA PRIVATE KEY-----
Added: webservices/axis2/trunk/c/rampart/test/openssl/sign/test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/openssl/sign/test.c?view=auto&rev=513643
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/openssl/sign/test.c (added)
+++ webservices/axis2/trunk/c/rampart/test/openssl/sign/test.c Thu Mar 1 23:35:44 2007
@@ -0,0 +1,89 @@
+/*
+ * 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_constants.h>
+#include <axis2_env.h>
+#include <oxs_buffer.h>
+#include <oxs_error.h>
+#include <oxs_key_mgr.h>
+#include <openssl_sign.h>
+#include <openssl_digest.h>
+#include <openssl_constants.h>
+#include <openssl_pkey.h>
+#include <oxs_axis2_utils.h>
+#include <oxs_x509_cert.h>
+
+
+int main()
+{
+ axis2_env_t *env = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ oxs_buffer_t *inbuf = NULL;
+ oxs_buffer_t *outbuf = NULL;
+ openssl_pkey_t *prvkey = NULL;
+ openssl_pkey_t *pubkey = NULL;
+ oxs_x509_cert_t *cert = NULL;
+ char *data = "Winners in good times and survivors in hard times";
+ int len = -1;
+
+ env = axis2_env_create_all("./openssl.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /*Load private key*/
+ prvkey = oxs_key_mgr_load_private_key_from_file(env, "rsakey.pem", "");
+ if(!prvkey){
+ printf("Cannot load private key");
+ }
+
+ /*Load certificate*/
+ cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, "rsacert.pem");
+ if(!cert){
+ printf("Cannot load certificate");
+ }
+
+ inbuf = oxs_buffer_create(env);
+ OXS_BUFFER_POPULATE(inbuf, env, (unsigned char *)data, strlen(data));
+
+ outbuf = oxs_buffer_create(env);
+
+ /*Sign*/
+ printf("Signing\n");
+ len = openssl_sig_sign(env, prvkey, inbuf, outbuf);
+ if(len < 0 ){
+ printf("Signing failed\n");
+ return 0;
+ }else{
+ printf("Signing OK. Sig len = %d\n", len);
+ }
+
+
+ /*Verify*/
+ printf("Verifying\n");
+ pubkey = oxs_x509_cert_get_public_key(cert, env);
+
+ status = openssl_sig_verify(env, pubkey, inbuf, outbuf);
+ if(AXIS2_SUCCESS != status){
+ printf("Sign verification failed\n");
+ }else{
+ printf("Sign verification success\n");
+
+ }
+
+
+ return 0;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org