5
gSOAP HTTP Content-MD5 digest plugin example application.
7
gSOAP XML Web services tools
8
Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved.
10
--------------------------------------------------------------------------------
13
The contents of this file are subject to the gSOAP Public License Version 1.3
14
(the "License"); you may not use this file except in compliance with the
15
License. You may obtain a copy of the License at
16
http://www.cs.fsu.edu/~engelen/soaplicense.html
17
Software distributed under the License is distributed on an "AS IS" basis,
18
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19
for the specific language governing rights and limitations under the License.
21
The Initial Developer of the Original Code is Robert A. van Engelen.
22
Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved.
23
--------------------------------------------------------------------------------
26
This program is free software; you can redistribute it and/or modify it under
27
the terms of the GNU General Public License as published by the Free Software
28
Foundation; either version 2 of the License, or (at your option) any later
31
This program is distributed in the hope that it will be useful, but WITHOUT ANY
32
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
33
PARTICULAR PURPOSE. See the GNU General Public License for more details.
35
You should have received a copy of the GNU General Public License along with
36
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
37
Place, Suite 330, Boston, MA 02111-1307 USA
39
Author contact information:
40
engelen@genivia.com / engelen@acm.org
41
--------------------------------------------------------------------------------
47
soapcpp2 -c httpmd5test.h
48
cc -DWITH_OPENSSL -o httpmd5test httpmd5test.c soapC.c soapClient.c soapServer.c httpmd5.c stdsoap2.c -lssl -lcrypto -lz
56
static int http_md5_handler(struct soap *soap, void **context, enum http_md5_action, char *buf, size_t len);
58
int main(int argc, char **argv)
60
struct ns__echoString r;
62
soap_register_plugin_arg(&soap, http_md5, http_md5_handler);
65
else if (soap_call_ns__echoString(&soap, "http://", NULL, argv[1], &r))
66
soap_print_fault(&soap, stderr);
72
int ns__echoString(struct soap *soap, char *arg, struct ns__echoString *response)
73
{ response->arg = arg;
77
static int http_md5_handler(struct soap *soap, void **context, enum http_md5_action action, char *buf, size_t len)
80
unsigned char hash[EVP_MAX_MD_SIZE];
84
OpenSSL_add_all_digests();
85
if (!(m = EVP_get_digestbyname("md5")))
86
return SOAP_PLUGIN_ERROR;
88
*context = (void*)malloc(sizeof(EVP_MD_CTX));
89
ctx = (EVP_MD_CTX*)*context;
91
fprintf(stderr, "MD5 Init %p\n", ctx);
93
EVP_DigestInit(ctx, m);
96
ctx = (EVP_MD_CTX*)*context;
98
fprintf(stderr, "MD5 Update %p: ", ctx);
99
fwrite(buf, len, 1, stderr);
100
fprintf(stderr, "\n");
102
EVP_DigestUpdate(ctx, (void*)buf, (unsigned int)len);
105
ctx = (EVP_MD_CTX*)*context;
107
fprintf(stderr, "MD5 Final %p\n", ctx);
109
EVP_DigestFinal(ctx, (void*)hash, &size);
110
memcpy(buf, hash, 16);
112
case HTTP_MD5_DELETE:
113
ctx = (EVP_MD_CTX*)*context;
115
fprintf(stderr, "MD5 Delete %p\n", ctx);