summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exception_lists/check_rtime3
-rw-r--r--exception_lists/copyright6
-rw-r--r--exception_lists/cstyle76
-rw-r--r--exception_lists/hdrchk36
-rw-r--r--exception_lists/packaging4
-rw-r--r--usr/src/cmd/cmd-crypto/Makefile6
-rw-r--r--usr/src/cmd/cmd-crypto/kmscfg/Makefile43
-rw-r--r--usr/src/cmd/cmd-crypto/kmscfg/kmscfg.pl179
-rw-r--r--usr/src/lib/Makefile3
-rw-r--r--usr/src/lib/libkmsagent/Makefile43
-rw-r--r--usr/src/lib/libkmsagent/Makefile.com158
-rw-r--r--usr/src/lib/libkmsagent/THIRDPARTYLICENSE52
-rw-r--r--usr/src/lib/libkmsagent/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libkmsagent/amd64/Makefile30
-rw-r--r--usr/src/lib/libkmsagent/common/ApplianceParameters.h402
-rw-r--r--usr/src/lib/libkmsagent/common/AutoMutex.h157
-rw-r--r--usr/src/lib/libkmsagent/common/ClientSoapFaultCodes.h225
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgent.cpp3851
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgent.h1163
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentAESKeyWrap.h85
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentChallenge.cpp317
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentChallenge.h111
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.cpp115
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.h100
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.cpp202
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.h99
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentFatalState.cpp79
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.cpp43
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.h55
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.cpp454
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.h63
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.cpp1169
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.h339
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKICert.cpp308
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKICertOpenSSL.cpp313
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKICommon.cpp159
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKICommon.h293
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKIKey.cpp153
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKIKeyOpenSSL.cpp412
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentPKIimpl.h165
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.cpp148
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.h75
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentStorage.cpp1575
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentStorage.h175
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.cpp235
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.h135
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAgent_direct.h942
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAuditLogger.cpp191
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAuditLogger.h144
-rw-r--r--usr/src/lib/libkmsagent/common/KMSAuditLogger_meta.cpp128
-rw-r--r--usr/src/lib/libkmsagent/common/KMSClientProfile.cpp2878
-rw-r--r--usr/src/lib/libkmsagent/common/KMSClientProfile.h456
-rw-r--r--usr/src/lib/libkmsagent/common/KMSClientProfileImpl.h344
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/AgentServiceNamespace.cpp22
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/CAServiceNamespace.cpp21
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/CertificateServiceNamespace.cpp22
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/DiscoveryServiceNamespace.cpp22
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.h34
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_Agent.nsmap36
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_AgentC.cpp8820
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_AgentClient.cpp847
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_AgentH.h1827
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_AgentStub.h834
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CA.nsmap36
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CAC.cpp2648
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CAClient.cpp148
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CAH.h702
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CAStub.h286
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_Certificate.nsmap36
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateC.cpp2425
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateClient.cpp102
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateH.h652
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateStub.h262
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_Discovery.nsmap36
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryC.cpp2904
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryClient.cpp100
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryH.h757
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryStub.h301
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/envC.cpp1359
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/envH.h329
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/envStub.h151
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/stdsoap2.cpp15632
-rw-r--r--usr/src/lib/libkmsagent/common/SOAP/stdsoap2.h2444
-rw-r--r--usr/src/lib/libkmsagent/common/SYSCommon.c2307
-rw-r--r--usr/src/lib/libkmsagent/common/SYSCommon.h1168
-rw-r--r--usr/src/lib/libkmsagent/common/debug.h161
-rw-r--r--usr/src/lib/libkmsagent/common/ieee80211_crypto.c201
-rw-r--r--usr/src/lib/libkmsagent/common/k_setupssl.c223
-rw-r--r--usr/src/lib/libkmsagent/common/k_setupssl.h66
-rw-r--r--usr/src/lib/libkmsagent/common/mapfile-vers43
-rw-r--r--usr/src/lib/libkmsagent/i386/Makefile29
-rw-r--r--usr/src/lib/libkmsagent/sparc/Makefile31
-rw-r--r--usr/src/lib/libkmsagent/sparcv9/Makefile28
-rw-r--r--usr/src/lib/pkcs11/Makefile5
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/Makefile43
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/Makefile.com99
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/amd64/Makefile36
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsAESCrypt.c1046
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsAttributeUtil.c1726
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsCrypt.h75
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsDecrypt.c405
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsDigest.c78
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsDualCrypt.c74
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsEncrypt.c424
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsGeneral.c548
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsGlobal.h88
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeys.c179
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.c1227
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.h57
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.c664
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.h308
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsObjectUtil.c930
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsRand.c48
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.c355
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.h188
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSessionUtil.c491
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSign.c92
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlot.h63
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlotToken.c386
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlottable.c77
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/kmsVerify.c91
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/common/mapfile-vers98
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/i386/Makefile29
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/sparc/Makefile27
-rw-r--r--usr/src/lib/pkcs11/pkcs11_kms/sparcv9/Makefile36
-rw-r--r--usr/src/pkg/manifests/system-library-security-crypto-pkcs11_kms.mf48
-rw-r--r--usr/src/tools/opensolaris/license-list1
127 files changed, 76981 insertions, 11 deletions
diff --git a/exception_lists/check_rtime b/exception_lists/check_rtime
index 455291e3af..a730bc1c25 100644
--- a/exception_lists/check_rtime
+++ b/exception_lists/check_rtime
@@ -210,6 +210,9 @@ NOSYMSORT lib/libsun_fc\.so\.1 # C++
NOSYMSORT lib/amd64/libsun_fc\.so\.1 # C++
NOSYMSORT lib/sparcv9/libsun_fc\.so\.1 # C++
NOSYMSORT usr/lib/amd64/libfru\.so\.1 # C++
+NOSYMSORT usr/lib/libkmsagent\.so\.1 # C++
+NOSYMSORT usr/lib/amd64/libkmsagent\.so\.1 # C++
+NOSYMSORT usr/lib/sparcv9/libkmsagent\.so\.1 # C++
# The libprtdiag_psr.so.1 objects built under usr/src/lib/libprtdiag_psr
diff --git a/exception_lists/copyright b/exception_lists/copyright
index 8e5497f38c..d6ef84ddbd 100644
--- a/exception_lists/copyright
+++ b/exception_lists/copyright
@@ -18,10 +18,7 @@
#
# CDDL HEADER END
#
-
-#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
syntax: glob
@@ -320,6 +317,7 @@ usr/src/lib/krb5/ss/mit-sipb-copyright.h
usr/src/lib/krb5/ss/options.c
usr/src/lib/krb5/ss/std_rqs.c
usr/src/lib/krb5/ss/utils.c
+usr/src/lib/libkmsagent/common/SOAP/*.*
usr/src/lib/librstp/common/*.[ch]
usr/src/lib/librstp/common/[CRT]*
usr/src/uts/intel/os/solaris.xpm
diff --git a/exception_lists/cstyle b/exception_lists/cstyle
index 99d47aa18f..a46e3cd366 100644
--- a/exception_lists/cstyle
+++ b/exception_lists/cstyle
@@ -644,3 +644,79 @@ usr/src/uts/common/gssapi/mechs/krb5/mech/util_validate.c
usr/src/uts/common/gssapi/mechs/krb5/mech/val_cred.c
usr/src/uts/common/gssapi/mechs/krb5/mech/verify.c
usr/src/uts/common/gssapi/mechs/krb5/mech/wrap_size_limit.c
+usr/src/lib/libkmsagent/common/ApplianceParameters.h
+usr/src/lib/libkmsagent/common/AutoMutex.h
+usr/src/lib/libkmsagent/common/ClientSoapFaultCodes.h
+usr/src/lib/libkmsagent/common/KMSAgent.cpp
+usr/src/lib/libkmsagent/common/KMSAgent.h
+usr/src/lib/libkmsagent/common/KMSAgentAESKeyWrap.h
+usr/src/lib/libkmsagent/common/KMSAgentChallenge.cpp
+usr/src/lib/libkmsagent/common/KMSAgentChallenge.h
+usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.cpp
+usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.h
+usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.cpp
+usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.h
+usr/src/lib/libkmsagent/common/KMSAgentFatalState.cpp
+usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.cpp
+usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.h
+usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.cpp
+usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.h
+usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.cpp
+usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.h
+usr/src/lib/libkmsagent/common/KMSAgentPKICert.cpp
+usr/src/lib/libkmsagent/common/KMSAgentPKICertOpenSSL.cpp
+usr/src/lib/libkmsagent/common/KMSAgentPKICommon.cpp
+usr/src/lib/libkmsagent/common/KMSAgentPKICommon.h
+usr/src/lib/libkmsagent/common/KMSAgentPKIKey.cpp
+usr/src/lib/libkmsagent/common/KMSAgentPKIKeyOpenSSL.cpp
+usr/src/lib/libkmsagent/common/KMSAgentPKIimpl.h
+usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.cpp
+usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.h
+usr/src/lib/libkmsagent/common/KMSAgentStorage.cpp
+usr/src/lib/libkmsagent/common/KMSAgentStorage.h
+usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.cpp
+usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.h
+usr/src/lib/libkmsagent/common/KMSAgent_direct.h
+usr/src/lib/libkmsagent/common/KMSAuditLogger.cpp
+usr/src/lib/libkmsagent/common/KMSAuditLogger.h
+usr/src/lib/libkmsagent/common/KMSAuditLogger_meta.cpp
+usr/src/lib/libkmsagent/common/KMSClientProfile.cpp
+usr/src/lib/libkmsagent/common/KMSClientProfile.h
+usr/src/lib/libkmsagent/common/KMSClientProfileImpl.h
+usr/src/lib/libkmsagent/common/PKICert.cpp
+usr/src/lib/libkmsagent/common/SOAP/AgentServiceNamespace.cpp
+usr/src/lib/libkmsagent/common/SOAP/CAServiceNamespace.cpp
+usr/src/lib/libkmsagent/common/SOAP/CertificateServiceNamespace.cpp
+usr/src/lib/libkmsagent/common/SOAP/DiscoveryServiceNamespace.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_AgentC.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_AgentClient.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_AgentH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_AgentStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_Agent_SOAP.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CAC.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_CAClient.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_CAH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CAStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateC.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateClient.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_Certificate_SOAP.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryC.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryClient.cpp
+usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_Discovery_SOAP.h
+usr/src/lib/libkmsagent/common/SOAP/envC.cpp
+usr/src/lib/libkmsagent/common/SOAP/envH.h
+usr/src/lib/libkmsagent/common/SOAP/envStub.h
+usr/src/lib/libkmsagent/common/SOAP/stdsoap2.cpp
+usr/src/lib/libkmsagent/common/SOAP/stdsoap2.h
+usr/src/lib/libkmsagent/common/SYSCommon.c
+usr/src/lib/libkmsagent/common/SYSCommon.h
+usr/src/lib/libkmsagent/common/debug.h
+usr/src/lib/libkmsagent/common/ieee80211_crypto.c
+usr/src/lib/libkmsagent/common/k_setupssl.c
+usr/src/lib/libkmsagent/common/k_setupssl.h
diff --git a/exception_lists/hdrchk b/exception_lists/hdrchk
index bc4604fa2e..2fd1070c98 100644
--- a/exception_lists/hdrchk
+++ b/exception_lists/hdrchk
@@ -166,3 +166,39 @@ usr/src/uts/common/gssapi/mechs/krb5/include/krb5.h
usr/src/uts/common/gssapi/mechs/krb5/include/old.h
usr/src/uts/common/gssapi/mechs/krb5/include/raw.h
usr/src/uts/common/gssapi/mechs/krb5/include/rsa-md4.h
+usr/src/lib/libkmsagent/common/ApplianceParameters.h
+usr/src/lib/libkmsagent/common/AutoMutex.h
+usr/src/lib/libkmsagent/common/ClientSoapFaultCodes.h
+usr/src/lib/libkmsagent/common/KMSAgent.h
+usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.h
+usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.h
+usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.h
+usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.h
+usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.h
+usr/src/lib/libkmsagent/common/KMSAgentPKICommon.h
+usr/src/lib/libkmsagent/common/KMSAgentPKIimpl.h
+usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.h
+usr/src/lib/libkmsagent/common/KMSAgentStorage.h
+usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.h
+usr/src/lib/libkmsagent/common/KMSAgent_direct.h
+usr/src/lib/libkmsagent/common/KMSAuditLogger.h
+usr/src/lib/libkmsagent/common/KMSClientProfile.h
+usr/src/lib/libkmsagent/common/KMSClientProfileImpl.h
+usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_AgentH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_AgentStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_Agent_SOAP.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CAH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CAStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_Certificate_SOAP.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryH.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryStub.h
+usr/src/lib/libkmsagent/common/SOAP/KMS_Discovery_SOAP.h
+usr/src/lib/libkmsagent/common/SOAP/envH.h
+usr/src/lib/libkmsagent/common/SOAP/envStub.h
+usr/src/lib/libkmsagent/common/SOAP/stdsoap2.h
+usr/src/lib/libkmsagent/common/SYSCommon.h
+usr/src/lib/libkmsagent/common/debug.h
+usr/src/lib/libkmsagent/common/k_setupssl.h
diff --git a/exception_lists/packaging b/exception_lists/packaging
index 58c70ec5c0..3a7b9ba989 100644
--- a/exception_lists/packaging
+++ b/exception_lists/packaging
@@ -58,6 +58,10 @@ usr/lib/llib-lsoftcrypto
usr/lib/llib-lsoftcrypto.ln
usr/lib/amd64/llib-lsoftcrypto.ln i386
usr/lib/sparcv9/llib-lsoftcrypto.ln sparc
+usr/lib/libkmsagent.so
+usr/lib/amd64/libkmsagent.so i386
+usr/lib/sparcv9/libkmsagent.so sparc
+
#
# The following files are used by the DHCP service, the
# standalone's DHCP implementation, and the kernel (nfs_dlboot).
diff --git a/usr/src/cmd/cmd-crypto/Makefile b/usr/src/cmd/cmd-crypto/Makefile
index 763c67da3f..26eeffeea7 100644
--- a/usr/src/cmd/cmd-crypto/Makefile
+++ b/usr/src/cmd/cmd-crypto/Makefile
@@ -18,8 +18,7 @@
#
# CDDL HEADER END
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
#
include ../Makefile.cmd
@@ -29,8 +28,9 @@ SUBDIRS1 = \
decrypt \
digest \
elfsign \
- pktool \
kmfcfg \
+ kmscfg \
+ pktool \
tpmadm
$(CLOSED_BUILD)SUBDIRS1 += \
diff --git a/usr/src/cmd/cmd-crypto/kmscfg/Makefile b/usr/src/cmd/cmd-crypto/kmscfg/Makefile
new file mode 100644
index 0000000000..744c2f06d9
--- /dev/null
+++ b/usr/src/cmd/cmd-crypto/kmscfg/Makefile
@@ -0,0 +1,43 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include $(SRC)/cmd/Makefile.cmd
+
+PROG= kmscfg
+
+.KEEP_STATE:
+
+all: $(PROG)
+
+install: all .WAIT $(ROOTPROG)
+
+_msg: $(PROG).po
+
+clean:
+
+$(ROOTBINPROG): $(PROG)
+ $(INS.file)
+
+lint:
+
+include $(SRC)/cmd/Makefile.targ
diff --git a/usr/src/cmd/cmd-crypto/kmscfg/kmscfg.pl b/usr/src/cmd/cmd-crypto/kmscfg/kmscfg.pl
new file mode 100644
index 0000000000..bed782039c
--- /dev/null
+++ b/usr/src/cmd/cmd-crypto/kmscfg/kmscfg.pl
@@ -0,0 +1,179 @@
+#!/usr/perl5/bin/perl
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program initializes the private data needed to initialize
+# the PKCS#11 KMS provider (/usr/lib/security/pkcs11_kms.so.1) in
+# the Solaris Cryptographic Framework.
+#
+# It takes the following options:
+# [-p Profile Name]
+# [-a Agent ID]
+# [-i Agent Address]
+# [-t Transaction Timeout]
+# [-f Failover Limit]
+# [-d Discovery Frequency]
+# [-?]
+#
+
+use strict;
+use warnings;
+use locale;
+use Getopt::Std;
+use POSIX qw(locale_h);
+use File::Basename;
+use Sun::Solaris::Utils qw(textdomain gettext gmatch);
+
+my $cmd = basename($0);
+
+sub fatal {
+ print STDERR @_;
+ exit(1);
+}
+
+sub usage {
+ print STDERR gettext("Usage:") . " $cmd\n" .
+ gettext(
+ "\t[-p[rofile] Profile Name] The name of the KMA profile to use.\n" .
+ "\t[-a[gent] Agent ID] The KMA agent ID.\n" .
+ "\t[-i[paddr] Agent Address] Address of the KMA\n" .
+ "\t[-t[imeout] Transaction Timeout] Transaction timeout period (integer)\n" .
+ "\t[-f[ailover] Failover Limit] Maximum failover limit (integer)\n" .
+ "\t[-d[iscovery] Discovery Freq] Frequency to attempt KMA discovery\n");
+ exit(1);
+}
+
+sub get_input {
+ my($prompt, $default) = @_;
+ my $resp;
+ if (length($default)) {
+ print "$prompt [$default]: ";
+ } else {
+ print "$prompt: ";
+ }
+ chop ($resp = <STDIN>);
+ if (length($default)) {
+ return $resp ? $resp : $default;
+ }
+ return $resp;
+}
+
+setlocale(LC_ALL, "");
+textdomain(TEXT_DOMAIN);
+
+my($profile, $agentid, $address, $timeout, $failover, $discovery, $help);
+
+my (%opt);
+getopts('?p:a:i:t:f:d:', \%opt) || usage();
+usage() if exists ($opt{'?'});
+
+my $TOKENDIR;
+
+if (exists($ENV{KMSTOKEN_DIR})) {
+ $TOKENDIR= $ENV{KMSTOKEN_DIR};
+} else {
+ my $name = getpwuid($<);
+ $TOKENDIR= "/var/kms/$name";
+}
+
+my $cfgfile = "$TOKENDIR/kmstoken.cfg";
+
+if ( ! -d $TOKENDIR ) {
+ mkdir ($TOKENDIR, 0700) || die "mkdir $TOKENDIR error: $!\n";
+}
+
+if (-f $cfgfile) {
+ my $ans;
+ print gettext("KMS Token config file ") . "($cfgfile) " .
+ gettext("already exists,\n" .
+ "do you want to overwrite it (Y/n)? ");
+ chop ($ans = <STDIN>);
+ if (length($ans)) {
+ if ($ans !~ /^[yY].*/) {
+ exit(0);
+ }
+ }
+}
+
+if (!exists($opt{'p'})) {
+ $profile = get_input("Profile Name", "");
+ if (!length($profile)) {
+ fatal(gettext("You must enter a KMA Profile Name.\n"));
+ }
+} else {
+ $profile = $opt{'p'};
+}
+
+if (!exists($opt{'a'})) {
+ $agentid = get_input("Agent ID", "");
+ if (!length($agentid)) {
+ fatal(gettext("You must enter a KMA Profile ID.\n"));
+ }
+} else {
+ $agentid = $opt{'a'};
+}
+
+if (!exists($opt{'i'})) {
+ $address = get_input("KMA IP Address", "");
+ if (!length($address)) {
+ fatal(gettext("You must enter a KMA IP Address.\n"));
+ }
+} else {
+ $address = $opt{'i'};
+}
+
+if (!exists($opt{'t'})) {
+ $timeout = 10;
+} else {
+ $timeout = $opt{'t'};
+}
+
+if (!exists($opt{'f'})) {
+ $failover = 3;
+} else {
+ $failover = $opt{'f'};
+}
+
+if (!exists($opt{'d'})) {
+ $discovery = 10;
+} else {
+ $discovery = $opt{'d'};
+}
+
+# Save the old one
+if (-f $cfgfile) {
+ rename($cfgfile, "$cfgfile.old");
+}
+
+my $FH;
+
+open($FH, ">$cfgfile");
+print $FH "#\n# Profile Name\n#\n$profile\n";
+print $FH "#\n# Agent ID\n#\n$agentid\n";
+print $FH "#\n# KMA Address\n#\n$address\n";
+print $FH "#\n# Transaction Timeout\n#\n$timeout\n";
+print $FH "#\n# Failover Limit\n#\n$failover\n";
+print $FH "#\n# Discovery Frequency\n#\n$discovery\n";
+print $FH "#\n# Security Mode\n#\n1\n";
+close ($FH);
+
+exit(0);
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 483d528754..ee052bdde3 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -113,6 +113,7 @@ SUBDIRS += \
libipmp \
libiscsit \
libkmf \
+ libkmsagent \
libkstat \
libkvm \
liblm \
@@ -633,7 +634,7 @@ libinetsvc: libscf
librestart: libuutil libscf
../cmd/sgs/libdl: ../cmd/sgs/libconv
../cmd/sgs/libelf: ../cmd/sgs/libconv
-pkcs11: libcryptoutil
+pkcs11: libcryptoutil libkmsagent
print: libldap5
udapl/udapl_tavor: udapl/libdat
libzfs: libdevid libgen libnvpair libuutil \
diff --git a/usr/src/lib/libkmsagent/Makefile b/usr/src/lib/libkmsagent/Makefile
new file mode 100644
index 0000000000..ae5fbe8178
--- /dev/null
+++ b/usr/src/lib/libkmsagent/Makefile
@@ -0,0 +1,43 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include $(SRC)/lib/Makefile.lib
+
+SUBDIRS= $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+check := TARGET= check
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+
+.KEEP_STATE:
+
+all clean clobber install lint: $(SUBDIRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
diff --git a/usr/src/lib/libkmsagent/Makefile.com b/usr/src/lib/libkmsagent/Makefile.com
new file mode 100644
index 0000000000..10113e89e1
--- /dev/null
+++ b/usr/src/lib/libkmsagent/Makefile.com
@@ -0,0 +1,158 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+LIBRARY= libkmsagent.a
+VERS= .1
+
+LIB_C_OBJECTS= \
+ SYSCommon.o \
+ ieee80211_crypto.o \
+ k_setupssl.o
+
+LIB_CPP_OBJECTS= \
+ KMSAgent.o \
+ KMSAgentChallenge.o \
+ KMSAgentCryptoUtilities.o \
+ KMSAgentDataUnitCache.o \
+ KMSAgentFatalState.o \
+ KMSAgentKeyCallout.o \
+ KMSAgentKnownAnswerTests.o \
+ KMSAgentLoadBalancer.o \
+ KMSAgentPKICert.o \
+ KMSAgentPKICertOpenSSL.o \
+ KMSAgentPKICommon.o \
+ KMSAgentPKIKey.o \
+ KMSAgentPKIKeyOpenSSL.o \
+ KMSAgentSoapUtilities.o \
+ KMSAgentStorage.o \
+ KMSAgentStringUtilities.o \
+ KMSAuditLogger.o \
+ KMSClientProfile.o
+
+SOAP_OBJECTS =\
+ AgentServiceNamespace.o \
+ CAServiceNamespace.o \
+ CertificateServiceNamespace.o \
+ DiscoveryServiceNamespace.o \
+ KMS_AgentC.o \
+ KMS_AgentClient.o \
+ KMS_CAC.o \
+ KMS_CAClient.o \
+ KMS_CertificateC.o \
+ KMS_CertificateClient.o \
+ KMS_DiscoveryC.o \
+ KMS_DiscoveryClient.o \
+ envC.o \
+ stdsoap2.o
+
+OBJECTS= \
+ $(LIB_C_OBJECTS) \
+ $(LIB_CPP_OBJECTS) \
+ $(SOAP_OBJECTS)
+
+LIBSRCDIR= ../common
+SOAPSRCDIR= ../common/SOAP
+
+include $(SRC)/lib/Makefile.lib
+
+SRCDIR=../common
+CSRCS = $(LIB_C_OBJECTS:%.o=$(LIBSRCDIR)/%.c)
+LIBSRCS = $(LIB_CPP_OBJECTS:%.o=$(LIBSRCDIR)/%.cpp) $(CSRCS)
+SOAPSRCS= $(SOAP_OBJECTS:%.o=$(SOAPSRCDIR)/%.cpp)
+
+CCOBJS = $(LIB_CPP_OBJECTS:%.o=pics/%.o) \
+ $(SOAP_OBJECTS:%.o=pics/%.o)
+
+LIBS = $(DYNLIB)
+
+LDLIBS += -lCstd -lCrun -lpam -lc -lsoftcrypto -lcrypto -lssl -lsocket
+LDLIBS64 += -lCstd -lCrun -lpam -lc -lsoftcrypto -lcrypto -lssl -lsocket
+
+DEFINES = -DKMSUSERPKCS12 -D_REENTRANT -DNOWCSICMP -DUNIX \
+ -DWITH_OPENSSL -DHAVE_OPENSSL_SSL_H \
+ -DWITH_IPV6 -D_POSIX_THREADS -DXML_STATIC \
+ -DHAVE_EXPAT_CONFIG_H -DK_SOLARIS_PLATFORM \
+ -DOPENSSL_NO_DEPRECATED \
+ -DKMS_AGENT_VERSION_STRING=\"KMSAgentLibraryVersion:Build1016\"
+
+CFLAGS += $(CCVERBOSE)
+
+#
+# When building C++ objects, redefine CCFLAGS for 32-bit builds to
+# use "compat=5" instead of "compat=4".
+# The 64-bit CCFLAGS already use compat=5 option (see $SRC/Makefile.master)
+#
+$(CCOBJS) := i386_CCFLAGS = \
+ -compat=5 \
+ -Qoption ccfe -messages=no%anachronism \
+ -Qoption ccfe -features=no%conststrings \
+ $(CCERRWARN)
+
+$(CCOBJS) := sparc_CCFLAGS = \
+ -cg92 -compat=5 \
+ -Qoption ccfe -messages=no%anachronism \
+ -Qoption ccfe -features=no%conststrings \
+ $(CCERRWARN)
+
+CPPFLAGS += -I../common -I../common/SOAP -I$(SRC)/common/crypto/aes $(DEFINES)
+
+COPTFLAG += -xCC
+COPTFLAG64 += -xCC
+
+pics/stdsoap2.o:= CPPFLAGS += -DWITH_NONAMESPACES
+
+ROOTLIBDIR= $(ROOT)/usr/lib
+ROOTLIBDIR64= $(ROOT)/usr/lib/$(MACH64)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+#
+# Don't lint C++ code
+#
+lint:
+
+#
+# Need special rules here because the files are named ".cpp" instead
+# of ".cc". The source comes from KMS, and we need to keep them in sync
+# so we won't change the naming convention.
+#
+pics/%.o: $(LIBSRCDIR)/%.cpp
+ $(COMPILE.cc) -o $@ $<
+ $(POST_PROCESS_O)
+
+pics/%.o: $(SOAPSRCDIR)/%.cpp
+ $(COMPILE.cc) -o $@ $<
+ $(POST_PROCESS_O)
+
+.cpp:
+ $(LINK.cc) -o $@ $< $(LDLIBS)
+ $(POST_PROCESS)
+
+.cpp.o:
+ $(COMPILE.cc) $(OUTPUT_OPTION) $<
+ $(POST_PROCESS_O)
+
+include $(SRC)/lib/Makefile.targ
+
diff --git a/usr/src/lib/libkmsagent/THIRDPARTYLICENSE b/usr/src/lib/libkmsagent/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..75276e00e1
--- /dev/null
+++ b/usr/src/lib/libkmsagent/THIRDPARTYLICENSE
@@ -0,0 +1,52 @@
+--------------------------------------------------------------------------------
+gSOAP public license.
+
+The contents of this file are subject to the gSOAP Public License Version 1.3
+(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.cs.fsu.edu/~engelen/soaplicense.html
+Software distributed under the License is distributed on an "AS IS" basis,
+WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+for the specific language governing rights and limitations under the License.
+
+The Initial Developer of the Original Code is Robert A. van Engelen.
+Copyright (C) 2000-2010, Robert van Engelen, Genivia Inc., All Rights Reserved.
+
+--------------------------------------------------------------------------------
+The gSOAP Public License 1.3 is based on MPL1.1 (Mozilla Public License 1.1).
+
+The license allows for commercial and non-commercial use of gSOAP without fees or
+royalties. It also allows products to be built on top and distributed under any
+license (including commercial). Products developed with gSOAP should include a
+notice of copyright and a disclaimer of warranty in the product's documentation
+(License Exhibit B).
+
+The gSOAP public license requires modifications that are distributed as part of
+an open source product based on gSOAP to be submitted back to us.
+
+Note that the wsdl2h tool, UDDI code, Web server, and sample applications are
+NOT covered by the gSOAP public license. These are offered under a choice of
+GPL or commercial licensing.
+
+--------------------------------------------------------------------------------
+GPL license.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+Author contact information:
+engelen@genivia.com / engelen@acm.org
+
+This program is released under the GPL with the additional exemption that
+compiling, linking, and/or using OpenSSL is allowed.
+--------------------------------------------------------------------------------
diff --git a/usr/src/lib/libkmsagent/THIRDPARTYLICENSE.descrip b/usr/src/lib/libkmsagent/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..72934f7749
--- /dev/null
+++ b/usr/src/lib/libkmsagent/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+PORTIONS OF LIBKMSAGENT
diff --git a/usr/src/lib/libkmsagent/amd64/Makefile b/usr/src/lib/libkmsagent/amd64/Makefile
new file mode 100644
index 0000000000..5378290d7c
--- /dev/null
+++ b/usr/src/lib/libkmsagent/amd64/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libkmsagent/common/ApplianceParameters.h b/usr/src/lib/libkmsagent/common/ApplianceParameters.h
new file mode 100644
index 0000000000..9fec9719a1
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/ApplianceParameters.h
@@ -0,0 +1,402 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*-----------------------------------------------------------------------------
+* File: ApplianceParameters.h
+-----------------------------------------------------------------------------*/
+
+#ifndef ApplianceParameters_h
+#define ApplianceParameters_h
+
+// Server Config
+
+#define DEFAULT_SERVER_LOG_FILENAME "KeyMgrLog.log"
+#define DEFAULT_SERVER_CONFIG_FILENAME "ServerConfig.cfg"
+#define DEFAULT_CONNECTION_QUEUE_SIZE 100
+#define DEFAULT_THREAD_POOL_SIZE 8
+#define DEFAULT_THREAD_POOL_MIN_IDLE_THREADS 8
+#define DEFAULT_THREAD_POOL_MAX_IDLE_THREADS 8
+#define DEFAULT_THREAD_POOL_MAINTENANCE_FREQUENCY_IN_SECONDS 0
+#define DEFAULT_THREAD_POOL_SHRINK_BY 0
+#define DEFAULT_THREAD_POOL_SPAWN_BY 0
+#define DEFAULT_THREAD_POOL_ORIGINAL_SIZE 8
+#define DEFAULT_SOCKET_TIMEOUT_IN_SECONDS 60
+// former default for SSL_Accept timeout was 10s - increased to 20s to support HP LTO-4
+#define DEFAULT_SSL_ACCEPT_TIMEOUT_IN_SECONDS 20
+#define DEFAULT_SOCKET_CONNECTION_BACKLOG 100
+#define DEFAULT_MANAGEMENT_SERVICE_MAX_CONNECTIONS 10
+#define DEFAULT_CA_SERVICE_PORT_NUMBER 3331
+#define DEFAULT_CERTIFICATE_SERVICE_PORT_NUMBER 3332
+#define DEFAULT_MANAGEMENT_SERVICE_PORT_NUMBER 3333
+#define DEFAULT_AGENT_SERVICE_PORT_NUMBER 3334
+#define DEFAULT_DISCOVERY_SERVICE_PORT_NUMBER 3335
+#define DEFAULT_REPLICATION_SERVICE_PORT_NUMBER 3336
+#define EXTENDED_SSL_SESSION_CACHE_TIMEOUT 86400
+#define DEFAULT_DATABASE_MAINTENANCE_FREQUENCY_IN_SECONDS 86400
+#define DEFAULT_TRIGGER_DATABASE_MAINTENANCE_TIMEOUT_IN_SECONDS 30
+#define DEFAULT_AUDIT_LOG_MAINTENANCE_FREQUENCY_IN_SECONDS 3600
+// see CR 6689920
+#define DEFAULT_KEY_POOL_MAINTENANCE_FREQUENCY_IN_SECONDS 15
+#define KEY_POOL_MINIMUM_SIZE 1000
+#define KEY_POOL_MAXIMUM_SIZE 200000
+#define DEFAULT_KEY_GENERATION_BATCH_SIZE 10
+#define DEFAULT_REPLICATION_ANTI_ENTROPY_FREQUENCY_IN_SECONDS 60
+#define DEFAULT_MAXIMUM_REPLICATION_MESSAGE_SIZE_IN_BYTES 8192
+#define DEFAULT_MAXIMUM_JOIN_CLUSTER_MESSAGE_SIZE_IN_BYTES 262144
+#define DEFAULT_MAXIMUM_JOIN_CLUSTER_KMA_ENTRIES 20
+#define DEFAULT_REPLICATION_THROTTLE_TIME_IN_MILLISECONDS 1000
+#define DEFAULT_REPLICATION_SPREAD_TIME_IN_MILLISECONDS 3000
+#define DEFAULT_REPLICATION_TIMEOUT_IN_SECONDS 15
+#define DEFAULT_RETRIEVE_ROOT_CA_CERTIFICATE_TIMEOUT_IN_SECONDS 15
+#define DEFAULT_RETRIEVE_APPLIANCE_CERTIFICATE_TIMEOUT_IN_SECONDS 15
+#define DEFAULT_JOIN_CLUSTER_TIMEOUT_IN_SECONDS 15
+#define DEFAULT_JOIN_CLUSTER_REPLICATED_IN_SECONDS 10
+#define DEFAULT_REQUEST_ANTI_ENTROPY_PUSH_TIMEOUT_IN_SECONDS 60
+#define DEFAULT_PUSH_UPDATES_TIMEOUT_IN_SECONDS 60
+#define DEFAULT_CLUSTER_PEER_STATUS_TIMEOUT_IN_SECONDS 10
+#define DEFAULT_TABLE_LOCK_TIMEOUT_IN_SECONDS 2
+#define DEFAULT_REPLICATION_TABLE_LOCK_TIMEOUT_IN_SECONDS 8
+#define DEFAULT_TRANSACTION_RETRY_TIMEOUT_IN_SECONDS 4
+#define DEFAULT_KEY_STORE_GROW_SIZE_IN_SLOTS 10000
+// Since write-caching is disabled on the hard disk, this is not necessary to force overwrites to disk
+#define DEFAULT_KEY_STORE_OVERWRITE_BUFFER_EXTRA_SIZE 0
+#define DEFAULT_KEY_STORE_OVERWRITE_PASS_COUNT 7
+#define DEFAULT_CLOCK_ADJUSTMENT_LIMIT_IN_SECONDS 300
+#define DEFAULT_DATABASE_START_TIMEOUT_IN_SECONDS 30
+#define DEFAULT_DATABASE_TRANSACTION_RETRY_COUNT 10
+#define DEFAULT_DATABASE_TRANSACTION_RETRY_SLEEP_IN_MILLISECONDS 1000
+#define DEFAULT_MAX_SNMP_TRAP_QUEUE_SIZE 10000
+#define DEFAULT_SNMP_TIMEOUT_IN_SECONDS 10
+#define DEFAULT_SNMP_RETRY_LIMIT 1
+#define DEFAULT_FILE_TRANSFER_MAXIMUM_CHUNK_SIZE_IN_KILOBYTES 1024
+#define DEFAULT_CERTIFICATE_START_TIME_SHIFT_IN_SECONDS (60*60*24)
+#define DEFAULT_DISCOVERY_FREQUENCY_IN_SECONDS (60*10)
+#define DEFAULT_AUDIT_LOG_FAIL_BACK_FREQUENCY_IN_SECONDS (60*10)
+#define DEFAULT_NTP_PEER_UPDATE_FREQUENCY_IN_SECONDS 23
+#define DEFAULT_NTP_PEER_UPDATE_QUERY_INTERVAL 156
+#define DEFAULT_SYSTEM_DUMP_LOG_LINE_COUNT 5000
+#define DEFAULT_MASTER_KEY_PROVIDER_MAINTENANCE_FREQUENCY_IN_SECONDS 3600
+#define DEFAULT_SEND_PUSH_UPDATES_TO_JOIN_PEER_KMA_IN_SECONDS 3600
+#define DEFAULT_PENDING_QUORUM_OPERATION_EXPIRATION_FREQUENCY_IN_SECONDS 600
+#define DEFAULT_SUPPORT_ACCOUNT_MAX_PASSWORD_AGE_IN_DAYS 7
+#define DEFAULT_REPLICATION_ACCELERATION_TIMEOUT_IN_SECONDS 300
+
+#define DEFAULT_DATABASE_ADMINISTRATOR_USERNAME "dbadmin"
+#define DEFAULT_DATABASE_ADMINISTRATOR_PASSWORD "npwd4kms2"
+#define DEFAULT_DATABASE_NAME "keymgr"
+#define DEFAULT_DATABASE_PARAMS ""
+#define DEFAULT_DATABASE_USERNAME "keymgr"
+#define DEFAULT_DATABASE_PASSWORD "npwd4kms2"
+#define DEFAULT_KEY_STORE_FILE_NAME "KeyStore.dat"
+#define DEFAULT_OPENSSL_ROOT_CA_CERTIFICATE_FILE_NAME "RootCACertificate.crt"
+#define DEFAULT_OPENSSL_APPLIANCE_KEY_PAIR_FILE_NAME "KMAKeyPair.pem"
+#ifndef WIN32
+#define DEFAULT_OPENSSL_AGENT_PRIVATE_KEY_DIR "/var/opt/SUNWkms2/data/"
+#endif
+
+#ifndef DEFAULT_SERVER_VERSION
+#define DEFAULT_SERVER_VERSION "2.1.04"
+#endif
+#define DEFAULT_SNMP_TRAP_GENERIC_TRAP_OID "1.3.6.1.4.1.42.2"
+#define DEFAULT_SNMP_TRAP_DATE_TIME_OID "1.3.6.1.4.1.42.2.1"
+#define DEFAULT_SNMP_TRAP_AUDIT_CLASS_OID "1.3.6.1.4.1.42.2.2"
+#define DEFAULT_SNMP_TRAP_AUDIT_OPERATION_OID "1.3.6.1.4.1.42.2.3"
+#define DEFAULT_SNMP_TRAP_AUDIT_CONDITION_OID "1.3.6.1.4.1.42.2.4"
+#define DEFAULT_SNMP_TRAP_AUDIT_SEVERITY_OID "1.3.6.1.4.1.42.2.5"
+#define DEFAULT_SNMP_TRAP_ENTITY_ID_OID "1.3.6.1.4.1.42.2.6"
+#define DEFAULT_SNMP_TRAP_NETWORK_ADDRESS_OID "1.3.6.1.4.1.42.2.7"
+#define DEFAULT_SNMP_TRAP_MESSAGE_OID "1.3.6.1.4.1.42.2.8"
+#define DEFAULT_SNMP_TRAP_AUDIT_SOLUTION_OID "1.3.6.1.4.1.42.2.9"
+#define DEFAULT_BACKUP_FILE_NAME "BackupFile"
+#define DEFAULT_RESTORE_FILE_NAME "RestoreFile"
+#define DEFAULT_CACHED_BACKUP_FILE_NAME "/var/opt/SUNWkms2/CachedBackupFile"
+#define DEFAULT_CACHED_CORE_SECURITY_XML_FILE_NAME "/var/opt/SUNWkms2/CachedCoreSecurityXMLFile"
+#define DEFAULT_CACHED_BACKUP_KEY_XML_FILE_NAME "/var/opt/SUNWkms2/CachedBackupKeyXMLFile"
+#define DEFAULT_SOFTWARE_UPGRADE_FILE_NAME "/SUNWkms2/boxcar/SoftwareUpgradeFile"
+#define DEFAULT_IMPORT_10KEYS_FILE_NAME "Import10KeysFile"
+#define DEFAULT_KEY_SHARING_EXPORT_FILE_NAME "KeySharingExport.dat"
+#define DEFAULT_KEY_SHARING_IMPORT_FILE_NAME "KeySharingImport.dat"
+#define DEFAULT_JOIN_PEER_KMA_FILE_NAME "/var/opt/SUNWkms2/data/JoinPeerKMAFile"
+
+#define DEFAULT_PRIMARY_NETWORK_IF "bge0"
+#define DEFAULT_SECONDARY_NETWORK_IF "aggr1"
+#define DEFAULT_AGGREGATE_NETWORK "nge1 nge0"
+#define DEFAULT_PRIMARY_ALIAS "KMA-Mgmt"
+#define DEFAULT_SECONDARY_ALIAS "KMA-Service"
+#define DEFAULT_DATABASE_FILE_SYSTEM_PATH "/var/lib/pgsql"
+#define DEFAULT_BUNDLE_SOFTWARE_COMMAND "/opt/SUNWkms2/bin/BundleSoftwareUpgrade"
+#define DEFAULT_FLAR_FILE_PATH "/SUNWkms2/boxcar/SoftwareUpgrade.flar"
+
+// System Calls (Config)
+
+#define DEFAULT_SERVER_RESTART_COMMAND "/usr/sbin/svcadm restart kms2 > /dev/null 2>&1"
+#define DEFAULT_SET_IP_CONFIGURATION_COMMAND "/opt/SUNWkms2/bin/SetIPAddresses"
+#define DEFAULT_RESET_TO_FACTORY_DEFAULT_COMMAND "/opt/SUNWkms2/bin/ResetAndZeroizeLauncher > /dev/null 2>&1"
+#define DEFAULT_RESET_TO_FACTORY_AND_ZEROIZE_DEFAULT_COMMAND "/opt/SUNWkms2/bin/ResetAndZeroizeLauncher -zeroize > /dev/null 2>&1"
+#define DEFAULT_SHUTDOWN_COMMAND "/usr/sbin/shutdown -y -g 5 -i 5 'KMS is shutting down the system' > /dev/null 2>&1"
+#define DEFAULT_ENABLE_SUPPORT_COMMAND "/bin/passwd -u support > /dev/null 2>&1"
+#define DEFAULT_DISABLE_SUPPORT_COMMAND "/bin/passwd -l support > /dev/null 2>&1"
+#define DEFAULT_REGENERATE_SSH_KEYS_COMMAND "/opt/SUNWkms2/bin/RegenerateSSHKeys > /dev/null 2>&1"
+#define DEFAULT_DISPLAY_SSH_KEYS_COMMAND "/opt/SUNWkms2/bin/GetSSHKeys"
+#define DEFAULT_ENABLE_SSH_COMMAND "/usr/sbin/svcadm enable ssh > /dev/null 2>&1"
+#define DEFAULT_DISABLE_SSH_COMMAND "/opt/SUNWkms2/bin/DisableSSH > /dev/null 2>&1"
+#define DEFAULT_GET_SUPPORT_STATUS_COMMAND "/opt/SUNWkms2/bin/StateOfSupport"
+#define DEFAULT_GET_SSH_STATUS_COMMAND "/opt/SUNWkms2/bin/StateOfSSHD"
+#define DEFAULT_ENABLE_SERVER_STARTUP_COMMAND "/bin/true"
+#define DEFAULT_SERVER_STARTUP_COMMAND "/usr/sbin/svcadm enable kms2 > /dev/null 2>&1"
+#define DEFAULT_SOFTWARE_UPGRADE_COMMAND "/opt/SUNWkms2/bin/InstallSoftwareVersion"
+#define DEFAULT_LIST_SOFTWARE_VERSIONS_COMMAND "/opt/SUNWkms2/bin/ListSoftwareVersions"
+#define DEFAULT_STOP_SOFTWARE_AND_RUN_COMMAND "echo Stop and run not implemented" // "/usr/local/bin/StopSoftwareAndRun"
+#define DEFAULT_VERIFY_SOFTWARE_COMMAND "/opt/SUNWkms2/bin/VerifySoftwareFile"
+#define DEFAULT_VERIFY_ACTIVATE_COMMAND "/opt/SUNWkms2/bin/VerifyActivateSoftware"
+#define DEFAULT_CHANGE_SOFTWARE_COMMAND "/opt/SUNWkms2/bin/ChangeSoftwareVersion"
+#define DEFAULT_REBOOT_SYSTEM_COMMAND "/usr/sbin/shutdown -y -g 5 -i 6 'KMS is rebooting the system' > /dev/null 2>&1"
+#define DEFAULT_STOP_SERVER_COMMAND "/usr/sbin/svcadm disable kms2"
+#define DEFAULT_INTERFACE_CONFIG_COMMAND "/usr/sbin/ifconfig"
+#define DEFAULT_SYSTEM_DUMP_COMMAND "/opt/SUNWkms2/bin/SystemDump"
+#define DEFAULT_CONFIGURE_NTP_COMMAND "/opt/SUNWkms2/bin/ConfigureNTP"
+#define DEFAULT_SET_TIMEZONE_COMMAND "/opt/SUNWkms2/bin/SetTimezone"
+#define DEFAULT_GET_KEYBOARD_LAYOUT_COMMAND "/opt/SUNWkms2/bin/GetKeyboardLayout"
+#define DEFAULT_SET_KEYBOARD_LAYOUT_COMMAND "/opt/SUNWkms2/bin/SetKeyboardLayout"
+#define DEFAULT_CONFIGURE_PRIMARY_ADMIN_COMMAND "/opt/SUNWkms2/bin/ConfigurePrimaryAdmin"
+#define DEFAULT_GET_IPV6_ADDRESS_COMMAND "/opt/SUNWkms2/bin/GetIPv6Address"
+#define DEFAULT_INITIALIZE_SCA6000_COMMAND "/opt/SUNWkms2/bin/InitializeSCA6000"
+#define DEFAULT_QUERY_SYSTEM_MESSAGES_COMMAND "/opt/SUNWkms2/bin/QuerySystemMessages"
+
+// @see StringUtilities.cpp
+#define DEFAULT_PENDING_QUORUM_OPERATION_TIMEOUT "P2D" // Default to 2 days (defined by ISO 8601)
+#define PENDING_OPERATIONS_VERSION_STRING "2.2"
+
+// PKI
+
+#define KEY_SIZE 2048
+#define CRL_DAYS 365
+#define CRL_HOURS 0
+#define PKI_FORMAT FILE_FORMAT_PEM
+#define DER_FORMAT FILE_FORMAT_DER
+#define PKCS12_FORMAT FILE_FORMAT_PKCS12
+#define PKI_UNPROTECTED_PASSWORD "password"
+#define DN_O_ROOT_CA "Oracle"
+#define DN_OU_ROOT_CA "KMS"
+#define DN_CN_ROOT_CA "RootCA"
+ // NOTE: Do not directly use the following values.
+ // Use the configurable Security Parameter values instead
+#define DEFAULT_ROOT_CA_CERTIFICATE_LIFETIME "P49Y"
+#define DEFAULT_CERTIFICATE_LIFETIME "P49Y"
+#define AUTHENTICATION_SECRET_LENGTH 20
+#define AUTHENTICATION_CHALLENGE_LENGTH 20
+#define AUTHENTICATION_RESPONSE_LENGTH 20
+#define AUTHENTICATION_ITERATION_TIME_IN_MILLISECONDS 100
+// reduce the time for agents since we support agents on embedded processors
+#define AGENT_AUTHENTICATION_ITERATION_TIME_IN_MILLISECONDS 10
+#define MIN_AUTHENTICATION_ITERATION_COUNT 40000 // a bit less than 1/10 second on standard Appliance hardware
+#define MAX_AUTHENTICATION_ITERATION_COUNT 400000 // a bit less that 1 second on standard Appliance hardware
+
+// Core Security
+
+#define MAX_CORE_SECURITY_KEY_SPLIT_COUNT 10
+#define CORE_SECURITY_HMAC_LENGTH 64
+#define MAX_CORE_SECURITY_PAD_LENGTH 16
+
+//------------- to be removed: Transfer Partner code is obsolete -----------
+#define MAX_KEY_DISTRIBUTION_PUBLIC_KEY_COUNT 4
+#define MAX_CORE_SECURITY_PUBLIC_KEY_LENGTH 256
+//--------------------------------------------------------------------------
+
+// SOAP Services
+
+// TODO: make functions instead of macros?
+
+#define SOAP_SERVER_ERROR( pstSoap ) (soap_receiver_fault( pstSoap, "Server Error", NULL ))
+// This has been replaced with SoapClientError:
+//#define SOAP_CLIENT_ERROR( pstSoap, sMessage ) (soap_sender_fault( pstSoap, sMessage, NULL ))
+#define SOAP_IS_CLIENT_ERROR( pstSoap ) (strcmp( *soap_faultcode( pstSoap ), pstSoap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client" ) == 0)
+#define GET_SOAP_FAULTCODE( pstSoap ) ((soap_set_fault( pstSoap ),*soap_faultcode( pstSoap )) ? (*soap_faultcode( pstSoap )) : "Unknown")
+#define GET_SOAP_FAULTSTRING( pstSoap ) ((soap_set_fault( pstSoap ),*soap_faultstring( pstSoap )) ? (*soap_faultstring( pstSoap )) : "Unknown")
+#define GET_SOAP_FAULTDETAIL( pstSoap ) ((soap_set_fault( pstSoap ),*soap_faultdetail( pstSoap )) ? (*soap_faultdetail( pstSoap )) : "Unknown")
+#define SOAP_AUDIT_LOG_MESSAGE( pStringTable, pstSoap ) ( CAuditMessage( CAuditLogger::AUDIT_VALUE_SOAP_FAULTCODE, GET_SOAP_FAULTCODE( pstSoap ) ) + CAuditMessage( CAuditLogger::AUDIT_VALUE_SOAP_FAULTSTRING, GET_SOAP_FAULTSTRING( pstSoap ) ) + CAuditMessage( CAuditLogger::AUDIT_VALUE_SOAP_FAULTDETAIL, GET_SOAP_FAULTDETAIL( pstSoap ) ) )
+#define SOAP_HTTP_PROTOCOL "http://"
+#define SOAP_HTTPS_PROTOCOL "https://"
+
+// Data Entry
+
+#define MINIMUM_WIDE_STRING_VALUE_LENGTH 1
+#define MAXIMUM_WIDE_STRING_VALUE_LENGTH 64
+#define MAXIMUM_UTF8_STRING_VALUE_LENGTH ( MAXIMUM_WIDE_STRING_VALUE_LENGTH * 6 )
+#define MINIMUM_WIDE_TEXT_VALUE_LENGTH 1
+#define MAXIMUM_WIDE_TEXT_VALUE_LENGTH 8192
+#define MAXIMUM_UTF8_TEXT_VALUE_LENGTH ( MAXIMUM_WIDE_TEXT_VALUE_LENGTH * 6 )
+
+// Business Logic
+
+#define AUDIT_ID_BUFFER_LENGTH 16
+#define CERTIFICATE_SERIAL_NUMBER_BUFFER_LENGTH 16
+#define BACKUP_ID_BUFFER_LENGTH 16
+#define DATA_UNIT_ID_HEX_STRING_LENGTH 32
+#define DATA_UNIT_KEY_ID_BUFFER_LENGTH 30
+#define DATA_UNIT_KEY_ID_HEX_STRING_LENGTH (DATA_UNIT_KEY_ID_BUFFER_LENGTH*2)
+#define MAXIMUM_QUERY_NEXT_PAGE_SIZE 1000
+#define MAXIMUM_QUERY_FILTER_PARAMS_COUNT 100
+#define MAXIMUM_LIST_DATA_UNIT_STATUS_PARAMS_COUNT ( MAXIMUM_QUERY_FILTER_PARAMS_COUNT )
+#define MAXIMUM_LIST_AUDIT_LOGS_FOR_AGENTS_PARAMS_COUNT ( MAXIMUM_QUERY_FILTER_PARAMS_COUNT )
+#define MAXIMUM_LIST_AUDIT_LOGS_FOR_DATA_UNITS_PARAMS_COUNT ( MAXIMUM_QUERY_FILTER_PARAMS_COUNT )
+#define MAXIMUM_LIST_AUDIT_LOGS_FOR_KEYS_PARAMS_COUNT ( MAXIMUM_QUERY_FILTER_PARAMS_COUNT )
+// 0 allows unlimited # of DUs to be exported, positive int constricts the size
+#define DEFAULT_KEYSHARING_MAXIMUM_EXPORT_DATA_UNITS_RESULT_SIZE 0
+#define TRANSFER_PARTNER_KEY_ID_LENGTH 32
+#define TRANSFER_PARTNER_KEY_VALUE_LENGTH 259
+#define TRANSFER_PARTNER_KEY_VALUE_HEX_STRING_LENGTH (TRANSFER_PARTNER_KEY_VALUE_LENGTH*2)
+ // NOTE: Do not directly use the following value.
+ // Use the configurable Security Parameter value instead
+#define DEFAULT_MAX_FAILED_RETRIEVE_CERTIFICATE_ATTEMPTS 5
+ // The obvious logic for determining if a key's bits are on a backup is as follows:
+ // The key must have been created before the backup was created:
+ // Backup.CreatedDate >= DataUnitKey.CreatedDate
+ // And the key must not have been destroyed before the backup was created:
+ // (DataUnitKey.DestroyedDate IS NULL) OR (Backup.CreatedDate <= DataUnitKey.DestroyedDate)
+ // This logic would be fine in a single-appliance cluster, or if we had (or when we have)
+ // time synchronization. But right now the appliances in a cluster may have different
+ // times from each other, and that makes it dangerous to use a simple date comparison.
+ // (Note that when determining if a key is on a backup, we *really* don't want false
+ // negatives, but we don't mind false positives so much, within reason.)
+ // To address this, the best solution we came up with is to use a "backup date window".
+ // Instead of simply using the CreatedDate of a backup in our logic, we'll use:
+ // (Backup.CreatedDate + BACKUP_DATE_WINDOW_INTERVAL) >= DataUnitKey.CreatedDate
+ // and
+ // (DataUnitKey.DestroyedDate IS NULL) OR ((Backup.CreatedDate - BACKUP_DATE_WINDOW_INTERVAL) <= DataUnitKey.DestroyedDate)
+ // Note that the adding and subtracting of BACKUP_DATE_WINDOW_INTERVAL effectively increases
+ // the chance that the calculation will show that a key's bits are on a backup.
+ // It's still possible to get false negatives, and there will be more false positives,
+ // but if BACKUP_DATE_WINDOW_INTERVAL is set to the largest reasonable value that
+ // appliances' clocks could differ by, then we can eliminate false negatives to a
+ // fairly high degree of probability. (We can raise the probability to any arbitrary
+ // amount by increasing the window, but the trade-off is that we'll have more and more
+ // false positives.)
+#define DEFAULT_BACKUP_DATE_WINDOW_IN_SECONDS 300
+
+// Security Parameter Constraints
+
+#define MINIMUM_LONG_TERM_RETENTION_AUDIT_LOG_SIZE_LIMIT 1000
+#define MAXIMUM_LONG_TERM_RETENTION_AUDIT_LOG_SIZE_LIMIT 1000000
+#define MINIMUM_LONG_TERM_RETENTION_AUDIT_LOG_LIFETIME "P7D"
+#define MINIMUM_MEDIUM_TERM_RETENTION_AUDIT_LOG_SIZE_LIMIT 1000
+#define MAXIMUM_MEDIUM_TERM_RETENTION_AUDIT_LOG_SIZE_LIMIT 1000000
+#define MINIMUM_MEDIUM_TERM_RETENTION_AUDIT_LOG_LIFETIME "P7D"
+#define MINIMUM_SHORT_TERM_RETENTION_AUDIT_LOG_SIZE_LIMIT 1000
+#define MAXIMUM_SHORT_TERM_RETENTION_AUDIT_LOG_SIZE_LIMIT 1000000
+#define MINIMUM_SHORT_TERM_RETENTION_AUDIT_LOG_LIFETIME "P7D"
+#define MINIMUM_AUDIT_LOG_MAINTENANCE_FREQUENCY "PT1M"
+#define MINIMUM_ROOT_CA_CERTIFICATE_LIFETIME "P1M"
+#define MINIMUM_CERTIFICATE_LIFETIME "P1M"
+#define MINIMUM_RETRIEVE_CERTIFICATE_ATTEMPT_LIMIT 1
+#define MAXIMUM_RETRIEVE_CERTIFICATE_ATTEMPT_LIMIT 1000
+#define MINIMUM_PASSPHRASE_MINIMUM_LENGTH 8
+#define MAXIMUM_PASSPHRASE_MINIMUM_LENGTH ( MAXIMUM_WIDE_STRING_VALUE_LENGTH )
+#define MINIMUM_MANAGEMENT_SESSION_TIMEOUT_IN_MINUTES 0
+#define MAXIMUM_MANAGEMENT_SESSION_TIMEOUT_IN_MINUTES 60
+
+// The SYSTEM_FIPS_MODE_ONLY_ values must match those in
+// enum KMS_Management__FIPSModeOnly in KMS_Management_SOAP.h and
+// enum KMSManagement_FIPSModeOnly in KMSManagement.h
+#define SYSTEM_FIPS_MODE_ONLY_UNCHANGED (-1)
+#define SYSTEM_FIPS_MODE_ONLY_FALSE 0
+#define SYSTEM_FIPS_MODE_ONLY_TRUE 1
+#define MINIMUM_FIPS_MODE_ONLY ( SYSTEM_FIPS_MODE_ONLY_FALSE )
+#define MAXIMUM_FIPS_MODE_ONLY ( SYSTEM_FIPS_MODE_ONLY_TRUE )
+
+#define DEFAULT_MINIMUM_PASSPHRASE_LENGTH 8
+#define DEFAULT_MANAGEMENT_SESSION_TIMEOUT_IN_MINUTES 15
+#define DEFAULT_FIPS_MODE_ONLY ( SYSTEM_FIPS_MODE_ONLY_FALSE )
+
+// To limit maximum query size, we limit # created
+// this is probably (hopefully) temporary
+#define MAXIMUM_CREATION_COUNT 999
+
+// Audit Log
+
+#define AUDIT_LOG_DEFAULT_SIZE_LONG_TERM_RETENTION 1000000
+#define AUDIT_LOG_DEFAULT_SIZE_MEDIUM_TERM_RETENTION 100000
+#define AUDIT_LOG_DEFAULT_SIZE_SHORT_TERM_RETENTION 10000
+#define AUDIT_LOG_DEFAULT_LIFETIME_DAYS_LONG_TERM_RETENTION "P2Y"
+#define AUDIT_LOG_DEFAULT_LIFETIME_DAYS_MEDIUM_TERM_RETENTION "P3M"
+#define AUDIT_LOG_DEFAULT_LIFETIME_DAYS_SHORT_TERM_RETENTION "P7D"
+
+// Replication
+
+// schema version 7: change to soap Discovery Service for supporting DNS
+// schema version 8: change to soap Agent Service for RetrieveDataUnitKeys
+// schema version 9: ensure that Ready keys appear in current backup
+// schema version 10: IPv6 support and AES key wrap
+// schema version 11: ICSF integration, distributed quorum, SNMP v2
+// schema version 12: replication acceleration
+#define REPLICATION_SCHEMA_VERSION_MIN 8
+#define REPLICATION_SCHEMA_VERSION_MAX 12
+#define REPLICATION_SCHEMA_VERSION_KEYS_IN_BACKUP 9
+#define REPLICATION_SCHEMA_VERSION_IPV6_ADDRESSES 10
+#define REPLICATION_SCHEMA_VERSION_AES_KEY_WRAP 10
+#define REPLICATION_SCHEMA_VERSION_MASTER_KEY_MODE 11
+#define REPLICATION_SCHEMA_VERSION_DISTRIBUTED_QUORUM 11
+#define REPLICATION_SCHEMA_VERSION_SNMP_PROTOCOL_VERSION_TWO 11
+#define REPLICATION_SCHEMA_VERSION_REPLICATION_ACCELERATION 12
+// value to return on inactive software versions
+#define REPLICATION_SCHEMA_VERSION_INVALID 0
+
+// Key Sharing Transfer Formats
+
+#define TRANSFER_FORMAT_INVALID (-100)
+#define TRANSFER_FORMAT_DEFAULT (-1)
+#define TRANSFER_FORMAT_LEGACY 0
+#define TRANSFER_FORMAT_LEGACY_VERSION_STRING "2.0.1"
+#define TRANSFER_FORMAT_FIPS 1
+#define TRANSFER_FORMAT_FIPS_VERSION_STRING "2.1"
+
+// Master Key Modes
+#define _MASTER_KEY_MODE_OFF 0
+#define _MASTER_KEY_MODE_ALL_KEYS 1
+#define _MASTER_KEY_MODE_RECOVER_KEYS_ONLY 2
+
+// Derived/Master Key stuff
+#define KEY_VERSION_PREFIX_LENGTH 2
+#define KEY_VERSION_PREFIX_HEX_LENGTH (KEY_VERSION_PREFIX_LENGTH*2)
+#define NON_DERIVED_KEY_VERSION 0x0000
+#define NON_DERIVED_KEY_VERSION_HEX (L"0000")
+#define DERIVED_KEY_VERSION 0x0001
+#define DERIVED_KEY_VERSION_HEX (L"0001")
+#define MASTER_KEY_ID_PREFIX_HEX (L"0000")
+#define MASTER_KEY_ID_PREFIX_LENGTH 2
+#define MASTER_KEY_ID_PREFIX_HEX_LENGTH (MASTER_KEY_ID_PREFIX_LENGTH*2)
+#define MASTER_KEY_ID_KMAID_LENGTH 8
+#define MASTER_KEY_ID_KMAID_HEX_LENGTH (MASTER_KEY_ID_KMAID_LENGTH*2)
+#define MASTER_KEY_ID_RANDOM_LENGTH 8
+#define MASTER_KEY_ID_LENGTH (MASTER_KEY_ID_PREFIX_LENGTH + MASTER_KEY_ID_KMAID_LENGTH + MASTER_KEY_ID_RANDOM_LENGTH)
+#define MASTER_KEY_ID_HEX_LENGTH (MASTER_KEY_ID_LENGTH*2) // ICSF can only handle 32-byte string IDs for keys
+#define MASTER_KEY_ID_BASE64_LENGTH 32
+#define DATA_UNIT_KEY_ID_HEX_LENGTH (DATA_UNIT_KEY_ID_BUFFER_LENGTH*2)
+
+// SNMP Manager protocol version stuff
+#define SYSTEM_SNMP_PROTOCOL_VERSION_THREE 0
+#define SYSTEM_SNMP_PROTOCOL_VERSION_TWO 1
+
+#endif //ApplianceParameters_h
diff --git a/usr/src/lib/libkmsagent/common/AutoMutex.h b/usr/src/lib/libkmsagent/common/AutoMutex.h
new file mode 100644
index 0000000000..31943e8559
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/AutoMutex.h
@@ -0,0 +1,157 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*------------------------------------------------------------------------------
+ * Module : AutoMutex.h
+ -----------------------------------------------------------------------------*/
+
+#ifndef AutoMutex_h
+#define AutoMutex_h
+
+#include "SYSCommon.h"
+
+class CAutoMutex
+{
+public:
+
+ /*---------------------------------------------------------------------------
+ * Constructor:
+ * Locks the given mutex handle.
+ *
+ * Input
+ * -----
+ * i_hMutex Mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+
+ CAutoMutex( K_MUTEX_HANDLE i_hMutex )
+ : m_hMutex( 0 ),
+ m_bLocked( false )
+ {
+ if ( i_hMutex )
+ {
+ Lock( i_hMutex );
+ }
+ }
+
+
+ /*---------------------------------------------------------------------------
+ * Destructor:
+ * Unlocks this mutex.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+
+ virtual ~CAutoMutex()
+ {
+ if ( m_bLocked )
+ {
+ Unlock();
+ }
+ }
+
+ /*---------------------------------------------------------------------------
+ * Function: Lock
+ *
+ * Description:
+ * Locks this mutex handle. If i_hMutex is null, the handle passed to the
+ * constructor will be used. Fatals if there is no valid handle.
+ *
+ * Input
+ * -----
+ * i_hMutex Mutex handle to lock
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+
+ void Lock( K_MUTEX_HANDLE i_hMutex = 0 )
+ {
+ FATAL_ASSERT( !m_bLocked );
+
+ if ( i_hMutex )
+ {
+ m_hMutex = i_hMutex;
+ }
+
+ FATAL_ASSERT( m_hMutex );
+ K_LockMutex( m_hMutex );
+ m_bLocked = true;
+ }
+
+
+ /*---------------------------------------------------------------------------
+ * Function: Unlock
+ *
+ * Description:
+ * Unlocks the mutex handle passed to the constructor or to a previous
+ * Lock call. Fatals if the mutex is not locked.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+
+ void Unlock()
+ {
+ FATAL_ASSERT( m_bLocked );
+ FATAL_ASSERT( m_hMutex );
+ K_UnlockMutex( m_hMutex );
+ m_bLocked = false;
+ }
+
+private:
+ K_MUTEX_HANDLE m_hMutex;
+ bool m_bLocked;
+};
+
+
+#endif // AutoMutex_h
diff --git a/usr/src/lib/libkmsagent/common/ClientSoapFaultCodes.h b/usr/src/lib/libkmsagent/common/ClientSoapFaultCodes.h
new file mode 100644
index 0000000000..9d67d176ed
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/ClientSoapFaultCodes.h
@@ -0,0 +1,225 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef CLIENTSOAPFAULTCODES_H
+#define CLIENTSOAPFAULTCODES_H
+
+/**
+ * Enumeration of error codes that have corresponding soap error strings.
+ * Note: These start at 1000 to avoid overlapping with other soap error codes
+ *
+ * The format of these enumerations is roughly as follows:
+ *
+ * Start with CLIENT_ERROR_
+ *
+ * Next, put AGENT if the error is intended for the KMA Agent interface
+ * put MANAGER if the error is intended for the KMS Manager interface
+ * put SERVER if the error is the fault of the KMS server for any interface
+ *
+ * After that, briefly describe the error.
+ */
+enum SoapClientErrorCode
+{
+ INVALID_CLIENT_ERROR = 0,
+ CLIENT_ERROR_ACCESS_DENIED = 1000,
+ CLIENT_ERROR_SERVER_BUSY,
+ CLIENT_ERROR_AUTHENTICATION_FAILED,
+ CLIENT_ERROR_NETWORK_ADDRESS_UNREACHABLE,
+ CLIENT_ERROR_INVALID_EXPECTED_PEER_LAST_KNOWN_TIMESTAMP_VECTOR,
+ CLIENT_ERROR_INCOMPATIBLE_VERSION,
+ CLIENT_ERROR_INCOMPATIBLE,
+ CLIENT_ERROR_BUNDLE_ALREADY_IN_PROGRESS,
+ CLIENT_ERROR_AGENT_INVALID_PARAMETERS,
+ CLIENT_ERROR_AGENT_KEY_DOES_NOT_EXIST,
+ CLIENT_ERROR_AGENT_KEY_DESTROYED,
+ CLIENT_ERROR_AGENT_DATA_UNIT_ID_NOT_FOUND_EXTERNAL_ID_EXISTS,
+ CLIENT_ERROR_AGENT_DATA_UNIT_EXPIRED,
+ CLIENT_ERROR_INVALID_DATA_UNIT_ID,
+ CLIENT_ERROR_INVALID_KEY_ID,
+ CLIENT_ERROR_AGENT_DUPLICATE_EXTERNAL_ID,
+ CLIENT_ERROR_AGENT_INVALID_EXTERNAL_ID,
+ CLIENT_ERROR_AGENT_DATA_UNIT_NOT_REKEYABLE,
+ CLIENT_ERROR_AGENT_APPLIANCE_LOCKED,
+ CLIENT_ERROR_AGENT_INVALID_PASSPHRASE,
+ CLIENT_ERROR_DATA_UNIT_NOT_FOUND,
+ CLIENT_ERROR_AGENT_NO_READY_KEYS,
+ CLIENT_ERROR_MANAGER_INVALID_PARAMETERS,
+ CLIENT_ERROR_MANAGER_DATA_UNIT_NOT_DESTROYED,
+ CLIENT_ERROR_MANAGER_APPLIANCE_EXISTS,
+ CLIENT_ERROR_MANAGER_APPLIANCE_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_CANNOT_DELETE_LOCAL_APPLIANCE,
+ CLIENT_ERROR_MANAGER_APPLIANCE_IN_USE,
+ CLIENT_ERROR_MANAGER_AGENT_EXISTS,
+ CLIENT_ERROR_MANAGER_AGENT_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_AGENT_IN_USE,
+ CLIENT_ERROR_MANAGER_USER_EXISTS,
+ CLIENT_ERROR_MANAGER_USER_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_USER_IN_USE,
+ CLIENT_ERROR_MANAGER_ROLE_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_USER_ROLE_EXISTS,
+ CLIENT_ERROR_MANAGER_USER_ROLE_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_CANNOT_DELETE_ONLY_SECURITY_OFFICER,
+ CLIENT_ERROR_MANAGER_CANNOT_REMOVE_ONLY_SECURITY_OFFICER_ROLE,
+ CLIENT_ERROR_MANAGER_SITE_EXISTS,
+ CLIENT_ERROR_MANAGER_SITE_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_SITE_IN_USE,
+ CLIENT_ERROR_MANAGER_CANNOT_SET_PASSPHRASE_FOR_LOCAL_APPLIANCE,
+ CLIENT_ERROR_MANAGER_INVALID_PASSPHRASE,
+ CLIENT_ERROR_MANAGER_LIFETIME_OVERRIDE_NOT_PERMITTED,
+ CLIENT_ERROR_MANAGER_AGENT_ALREADY_IN_KEY_GROUP,
+ CLIENT_ERROR_MANAGER_AGENT_ALREADY_HAS_DEFAULT_KEY_GROUP,
+ CLIENT_ERROR_MANAGER_AGENT_NOT_IN_KEY_GROUP,
+ CLIENT_ERROR_MANAGER_CORE_SECURITY_ALREADY_LOCKED,
+ CLIENT_ERROR_MANAGER_CORE_SECURITY_ALREADY_UNLOCKED,
+ CLIENT_ERROR_MANAGER_BACKUP_ID_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_BACKUP_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_BACKUP_RESTORE_DENIED,
+ CLIENT_ERROR_MANAGER_BACKUP_OR_RESTORE_IN_PROGRESS,
+ CLIENT_ERROR_MANAGER_BACKUP_RESTORE_FILE_DUPLICATE_ENTITY_FAILURE,
+ CLIENT_ERROR_MANAGER_BACKUP_RESTORE_FILE_INVALID,
+ CLIENT_ERROR_MANAGER_FILE_CHUNK_OFFSET_INVALID,
+ CLIENT_ERROR_MANAGER_FILE_CHUNK_IO_ERROR,
+ CLIENT_ERROR_MANAGER_BACKUP_ALREADY_DESTROYED,
+ CLIENT_ERROR_MANAGER_BACKUP_DESTROYED,
+ CLIENT_ERROR_MANAGER_BACKUP_NOT_AVAILABLE,
+ CLIENT_ERROR_MANAGER_CLOCK_ADJUSTMENT_LIMIT_EXCEEDED,
+ CLIENT_ERROR_MANAGER_CLOCK_ADJUSTMENT_ALREADY_PERFORMED_TODAY,
+ CLIENT_ERROR_MANAGER_CLOCK_ADJUSTMENT_FAILED,
+ CLIENT_ERROR_MANAGER_SOFTWARE_UPGRADE_FILE_NOT_FOUND,
+ CLIENT_ERROR_MANAGER_SOFTWARE_UPGRADE_FAILED,
+ CLIENT_ERROR_MANAGER_LIST_SOFTWARE_VERSIONS_FAILED,
+ CLIENT_ERROR_MANAGER_CHANGE_SOFTWARE_VERSION_FAILED,
+ CLIENT_ERROR_MANAGER_VERIFY_SOFTWARE_UPLOAD_FAILED,
+ CLIENT_ERROR_MANAGER_SNMP_MANAGER_EXISTS,
+ CLIENT_ERROR_MANAGER_SNMP_MANAGER_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_EXISTS,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_IN_USE,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_ALREADY_IN_KEY_GROUP,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_NOT_IN_KEY_GROUP,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_NOT_ENABLED,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_NOT_ALLOWED_EXPORT_TO,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_HAS_NO_PUBLIC_KEYS,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_PUBLIC_KEY_ID_ALREADY_EXISTS,
+ CLIENT_ERROR_MANAGER_APPLIANCE_LOCKED,
+ CLIENT_ERROR_MANAGER_DATA_UNIT_EXPIRED,
+ CLIENT_ERROR_MANAGER_UNEXPECTED_TRANSFER_PARTNER,
+ CLIENT_ERROR_MANAGER_KEY_GROUP_DOES_NOT_ALLOW_EXPORT_FROM,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_KEY_GROUP_ACCESS_DENIED,
+ CLIENT_ERROR_MANAGER_TRANSFER_PARTNER_NOT_ALLOWED_IMPORT_FROM,
+ CLIENT_ERROR_MANAGER_KEY_GROUP_NOT_ALLOWED_IMPORT_TO,
+ CLIENT_ERROR_MANAGER_DUPLICATE_DATA_UNIT_ID,
+ CLIENT_ERROR_MANAGER_DUPLICATE_DATA_UNIT_KEY_ID,
+ CLIENT_ERROR_MANAGER_DUPLICATE_EXTERNAL_ID,
+ CLIENT_ERROR_MANAGER_CORE_SECURITY_PUBLIC_KEY_NOT_FOUND,
+ CLIENT_ERROR_MANAGER_CHANGE_PRIMARY_LOCAL_NETWORK_ADDRESS_DENIED,
+ CLIENT_ERROR_MANAGER_CHANGE_SECONDARY_LOCAL_NETWORK_ADDRESS_DENIED,
+ CLIENT_ERROR_MANAGER_KEY_POLICY_EXISTS,
+ CLIENT_ERROR_MANAGER_KEY_POLICY_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_KEY_POLICY_IN_USE,
+ CLIENT_ERROR_MANAGER_CHANGE_SOFTWARE_VERSION_IN_PROGRESS,
+ CLIENT_ERROR_MANAGER_VERIFY_SOFTWARE_UPLOAD_IN_PROGRESS,
+ CLIENT_ERROR_MANAGER_APPLY_SOFTWARE_VERSION_IN_PROGRESS,
+ CLIENT_ERROR_MANAGER_KEY_GROUP_EXISTS,
+ CLIENT_ERROR_MANAGER_KEY_GROUP_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_KEY_GROUP_IN_USE,
+ CLIENT_ERROR_MANAGER_KEY_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_KEY_ALREADY_COMPROMISED,
+ CLIENT_ERROR_MANAGER_KEY_ALREADY_IN_KEY_GROUP,
+ CLIENT_ERROR_MANAGER_INVALID_BACKUP_ID,
+ CLIENT_ERROR_MANAGER_LIMIT_EXCEEDED,
+ CLIENT_ERROR_MANAGER_SYSTEM_DUMP_FAILED,
+ CLIENT_ERROR_MANAGER_SYSTEM_DUMP_DOES_NOT_EXIST,
+ CLIENT_ERROR_MANAGER_ADD_NTP_SERVER_FAILED,
+ CLIENT_ERROR_MANAGER_DELETE_NTP_SERVER_FAILED,
+ CLIENT_ERROR_MANAGER_NTP_SERVER_SPECIFIED,
+ CLIENT_ERROR_MANAGER_GET_LOCAL_CLOCK_FAILED,
+ CLIENT_ERROR_MANAGER_ADJUST_LOCAL_CLOCK_FAILED,
+ CLIENT_ERROR_MANAGER_NEED_CORE_SECURITY_BACKUP,
+ CLIENT_ERROR_MANAGER_KEY_DESTRUCTION_IN_PROGRESS,
+ CLIENT_ERROR_IMPORT_10KEYS_ALREADY_UPLOADED,
+ CLIENT_ERROR_IMPORT_10KEYS_FILE_DOES_NOT_EXIST,
+ CLIENT_ERROR_IMPORT_10KEYS_INVALID_FILE_FORMAT,
+ CLIENT_ERROR_IMPORT_10KEYS_FILE_READ_ERROR,
+ CLIENT_ERROR_IMPORT_10KEYS_FAILED,
+ CLIENT_ERROR_IMPORT_10KEYS_DUPLICATE_KEY_ID_AND_VALUE,
+ CLIENT_ERROR_IMPORT_10KEYS_DUPLICATE_KEY_ID,
+ CLIENT_ERROR_IMPORT_10KEYS_KEY_VALUE_NOT_HEX,
+ CLIENT_ERROR_INVALID_BACKUP_TIME,
+ CLIENT_ERROR_KEY_TRANSFER_IN_PROGRESS,
+ CLIENT_ERROR_KEY_TRANSFER_FILE_NOT_VALIDATED,
+ CLIENT_ERROR_LOCAL_APPLIANCE_NOT_PEER_SERVER,
+ CLIENT_ERROR_CANNOT_CONTACT_PEER_SERVER,
+ CLIENT_ERROR_MISMATCHED_SIGNING_PUBLIC_KEY_ID,
+ CLIENT_ERROR_MISMATCHED_ENCRYPTION_PUBLIC_KEY_ID,
+ CLIENT_ERROR_DATA_UNIT_HAS_NO_EXPORTABLE_KEYS,
+ CLIENT_ERROR_SOME_KEYS_NOT_EXPORTABLE, // This is actually a warning -- should we treat it differently? Start at 2000?
+ CLIENT_ERROR_UPDATE_REPLICATION_SCHEMA,
+ CLIENT_ERROR_NOT_SUPPORTED,
+ CLIENT_ERROR_AGENT_KWK_NOT_REGISTERED,
+ CLIENT_ERROR_AGENT_KWK_ID_MISMATCH,
+ CLIENT_ERROR_LIST_KMA_NETWORK_ADDRESSES_FAILED,
+ CLIENT_ERROR_GET_KMA_DNS_INFORMATION_FAILED,
+ CLIENT_ERROR_LIST_KMA_ROUTING_TABLE_ENTRIES_FAILED,
+ CLIENT_ERROR_EXPORT_FORMAT_DISALLOWED,
+ CLIENT_ERROR_TRANSFER_FORMAT_DISALLOWED,
+ CLIENT_ERROR_FIPS_MODE_REQUIRED,
+ CLIENT_ERROR_CLIENT_UPGRADE_REQUIRED,
+ CLIENT_ERROR_RESTORE_INVALID_BACKUP_XML_FORMAT,
+ CLIENT_ERROR_MANAGER_INVALID_MASTER_KEY_PROVIDER_PARAMETERS,
+ CLIENT_ERROR_MANAGER_PENDED_OPERATION_ID_DOES_NOT_EXIST,
+ CLIENT_ERROR_INVALID_PENDED_OPERATION_TYPE,
+ CLIENT_ERROR_SERVER_HSM_REQUIRED_BUT_MISSING,
+ CLIENT_ERROR_MANAGER_INTERNAL,
+ CLIENT_ERROR_AGENT_INVALID_HMAC,
+ CLIENT_ERROR_AGENT_INVALID_KEY,
+ CLIENT_ERROR_QUORUM_NOT_MET,
+ CLIENT_ERROR_MANAGER_CANNOT_QUERY_NTP_SERVER,
+ CLIENT_ERROR_MANAGER_NTP_SERVER_DELTA_TOO_BIG,
+ CLIENT_ERROR_MANAGER_CANNOT_UPDATE_NTP_CONFIG,
+ CLIENT_ERROR_MANAGER_CANNOT_CONTACT_SNMP_MANAGER,
+ CLIENT_ERROR_MANAGER_CORE_SECURITY_ERROR_INTERNAL,
+ CLIENT_ERROR_MANAGER_CORE_SECURITY_NOT_FOUND,
+
+ // NOTE: When you add a new CLIENT_ERROR_* definition above this comment,
+ // you should also add:
+ //
+ // 1) A case statement for it near the end of the switch
+ // statement in the GetSoapClientErrorCodeMessage() routine
+ // in the Common/SoapFaults/ClientSoapFaults.cpp file
+ // 2) A case statement for it near the end of the switch
+ // statement in the GetTranslatedSoapFault() routine in the
+ // Common/SoapFaults/ClientSoapErrorTranslator.cpp file
+ // 3) A case statement for it near the end of the switch statement
+ // in the GetErrorString routine in the
+ // Client/Manager/Global.cpp file
+
+ CLIENT_ERROR_LAST
+};
+
+
+#define GET_FAULT_CODE(errstr) (atoi(errstr))
+
+#endif //CLIENTSOAPFAULTCODES_H
diff --git a/usr/src/lib/libkmsagent/common/KMSAgent.cpp b/usr/src/lib/libkmsagent/common/KMSAgent.cpp
new file mode 100644
index 0000000000..3d34ea571f
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgent.cpp
@@ -0,0 +1,3851 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgent.cpp
+ */
+
+#ifdef WIN32
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+#include <process.h>
+#endif
+
+#include <stdlib.h>
+
+#include "KMSClientProfile.h"
+
+#include "KMS_AgentStub.h"
+#include "KMS_DiscoveryStub.h"
+
+#include "KMSClientProfileImpl.h"
+#include "KMSAgent.h"
+#include "KMSAuditLogger.h"
+#include "KMSAgentSoapUtilities.h"
+#include "KMSAgentStringUtilities.h"
+#include "KMSAgentPKICommon.h"
+#include "KMSAgentLoadBalancer.h"
+
+#include "KMSAgentWebServiceNamespaces.h"
+#include "k_setupssl.h"
+
+#include "ApplianceParameters.h"
+
+#include "AutoMutex.h"
+#include "KMSAgentKeyCallout.h"
+
+#include "KMSAgentLoadBalancer.h"
+#include "KMSAgentDataUnitCache.h"
+
+#ifdef K_SOLARIS_PLATFORM
+#include "KMSAgentStorage.h"
+#endif
+
+#include "ClientSoapFaultCodes.h"
+
+#ifdef METAWARE
+#include "debug.h"
+#include "sizet.h"
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#endif
+
+#include "KMSAgentAESKeyWrap.h"
+#include "KMSAgentKnownAnswerTests.h"
+
+#if defined(METAWARE) && defined(DEBUG_RETURNS)
+extern "C" void ecpt_trace_msg (ECPT_TRACE_ENTRY*, char*, ...);
+
+#define RETURN(a) { ecpt_trace_msg( trace,"(returned=%x)",(a)); return(a); }
+
+#else
+#define RETURN(a) return(a)
+#endif
+
+/* KMS_AGENT_VERSION_STRING gets passed in via compilation flags */
+extern "C" const char KMSAgent_Version[KMS_MAX_VERSION_LENGTH + 1] = KMS_AGENT_VERSION_STRING;
+
+
+/* The following enum and structs are used for QueryParameters in
+ * ListKeyGroup. Since they are only used in implementation code,
+ * so they are not in the header file in order to hide these details
+ */
+
+
+/*---------------------------Start Query Parameters Declartion -------- */
+
+#define KMS_MAX_AGENT_FILTER_PARAMETERS 10
+
+enum KMSAgent_SortOrder
+{
+ SORT_ORDER_ASCENDING = 0,
+ SORT_ORDER_DESCENDING
+};
+
+enum KMSAgent_FilterOperator
+{
+ FILTER_OPERATOR_EQUAL = 0,
+ FILTER_OPERATOR_NOT_EQUAL,
+ FILTER_OPERATOR_GREATER_THAN,
+ FILTER_OPERATOR_LESS_THAN,
+ FILTER_OPERATOR_GREATER_THAN_OR_EQUAL,
+ FILTER_OPERATOR_LESS_THAN_OR_EQUAL,
+ FILTER_OPERATOR_STARTS_WITH
+};
+
+struct KMSAgent_FilterParameters
+{
+ utf8char m_wsFieldName[KMS_MAX_FIELD_NAME + 1];
+ enum KMSAgent_FilterOperator m_eFilterOperator;
+ utf8char m_wsFieldValue[KMS_MAX_FIELD_VALUE + 1];
+};
+
+struct KMSAgent_QueryParameters
+{
+ utf8char m_wsSortFieldName[KMS_MAX_FIELD_NAME + 1];
+ enum KMSAgent_SortOrder m_eSortOrder;
+
+ struct KMSAgent_FilterParameters m_aFilterParameters[KMS_MAX_AGENT_FILTER_PARAMETERS];
+ int m_iSizeFilterParameters;
+
+ utf8char m_wsPreviousPageLastIDValue[KMS_MAX_ID + 1];
+ utf8char m_wsPreviousPageLastSortFieldValue[KMS_MAX_FIELD_VALUE + 1];
+};
+
+/*---------------------------End Of Query Parameters Declaration -------- */
+
+#ifdef METAWARE
+int CAgentLoadBalancer::FailOver (int i_iFailedApplianceIndex,
+ struct soap *i_pstSoap);
+#endif
+
+extern const char * KMSAgent_GetVersion ()
+{
+ return (KMSAgent_Version);
+}
+
+static bool CopyQueryParametersFromRequest
+(
+ struct soap *i_pstSoap,
+ int i_iPageSize,
+ struct KMS_Agent::KMS_Agent__QueryParameters *i_pQueryParameters,
+ struct KMSAgent_QueryParameters *i_pSourceQueryParameters
+ )
+{
+
+ // set page size
+ i_pQueryParameters->NextPageSize = i_iPageSize;
+
+ // copy sort field name
+ i_pQueryParameters->SortFieldName = (char *)
+ soap_malloc(i_pstSoap,
+ sizeof (i_pSourceQueryParameters->m_wsSortFieldName));
+ if (i_pQueryParameters->SortFieldName == NULL)
+ {
+ return (false);
+ }
+ strncpy(i_pQueryParameters->SortFieldName,
+ i_pSourceQueryParameters->m_wsSortFieldName,
+ sizeof (i_pSourceQueryParameters->m_wsSortFieldName));
+ i_pQueryParameters->SortFieldName[sizeof (i_pSourceQueryParameters->m_wsSortFieldName)-1] = 0;
+
+ // sort order
+ i_pQueryParameters->SortOrder =
+ (enum KMS_Agent::KMS_Agent__SortOrder)i_pSourceQueryParameters->m_eSortOrder;
+
+ // copy filter parameters
+ i_pQueryParameters->FilterParameters.__size =
+ i_pSourceQueryParameters->m_iSizeFilterParameters;
+
+ if (i_pQueryParameters->FilterParameters.__size > 0)
+ {
+ i_pQueryParameters->
+ FilterParameters.__ptr =
+ (struct KMS_Agent::KMS_Agent__FilterParameters *)soap_malloc
+ (i_pstSoap,
+ sizeof (KMS_Agent::KMS_Agent__FilterParameters) *
+ i_pQueryParameters->FilterParameters.__size);
+
+ if (i_pQueryParameters->FilterParameters.__ptr == NULL)
+ {
+ return (false);
+ }
+ }
+ else
+ {
+ i_pQueryParameters->FilterParameters.__ptr = NULL;
+ }
+
+ for (int i = 0; i < i_pSourceQueryParameters->m_iSizeFilterParameters; i++)
+ {
+ struct KMS_Agent::KMS_Agent__FilterParameters *pParameters;
+
+ pParameters = &(i_pQueryParameters->FilterParameters.__ptr[i]);
+
+ // copy field name
+ pParameters->FieldName = (
+ utf8cstr) soap_malloc(i_pstSoap,
+ sizeof (i_pSourceQueryParameters->
+ m_aFilterParameters[i].m_wsFieldName));
+ if (pParameters->FieldName == NULL)
+ {
+ return (false);
+ }
+
+ strncpy(pParameters->FieldName,
+ i_pSourceQueryParameters->m_aFilterParameters[i].m_wsFieldName,
+ sizeof (i_pSourceQueryParameters->
+ m_aFilterParameters[i].m_wsFieldName));
+ pParameters->FieldName[sizeof (i_pSourceQueryParameters->
+ m_aFilterParameters[i].m_wsFieldName)-1] = '\0';
+
+ // copy field value
+ pParameters->FieldValue =
+ (utf8cstr) soap_malloc
+ (i_pstSoap,
+ sizeof (i_pSourceQueryParameters->m_aFilterParameters[i].m_wsFieldValue));
+ if (pParameters->FieldValue == NULL)
+ {
+ return (false);
+ }
+
+ strncpy(pParameters->FieldValue,
+ i_pSourceQueryParameters->m_aFilterParameters[i].m_wsFieldValue,
+ sizeof (i_pSourceQueryParameters->m_aFilterParameters[i].m_wsFieldValue));
+ pParameters->FieldValue[sizeof (i_pSourceQueryParameters->m_aFilterParameters[i].m_wsFieldValue)-1] = '\0';
+
+ // copy FilterOperator
+ pParameters->FilterOperator =
+ (KMS_Agent::KMS_Agent__FilterOperator)
+ i_pSourceQueryParameters->m_aFilterParameters[i].m_eFilterOperator;
+ }
+
+ // copy PreviousPageLastIDValue
+ i_pQueryParameters->PreviousPageLastIDValue =
+ (utf8cstr) soap_malloc(i_pstSoap,
+ sizeof (i_pSourceQueryParameters->m_wsPreviousPageLastIDValue));
+ if (i_pQueryParameters->PreviousPageLastIDValue == NULL)
+ {
+ return (false);
+ }
+ strncpy(i_pQueryParameters->PreviousPageLastIDValue,
+ i_pSourceQueryParameters->m_wsPreviousPageLastIDValue,
+ sizeof (i_pSourceQueryParameters->m_wsPreviousPageLastIDValue));
+ i_pQueryParameters->PreviousPageLastIDValue[sizeof (i_pSourceQueryParameters->m_wsPreviousPageLastIDValue)-1] = '\0';
+
+ // copy PreviousPageLastIDValue
+ i_pQueryParameters->PreviousPageLastSortFieldValue =
+ (utf8cstr) soap_malloc(i_pstSoap,
+ sizeof (i_pSourceQueryParameters->
+ m_wsPreviousPageLastSortFieldValue));
+ if (i_pQueryParameters->PreviousPageLastSortFieldValue == NULL)
+ {
+ return (false);
+ }
+ strncpy(i_pQueryParameters->PreviousPageLastSortFieldValue,
+ i_pSourceQueryParameters->m_wsPreviousPageLastSortFieldValue,
+ sizeof (i_pSourceQueryParameters->
+ m_wsPreviousPageLastSortFieldValue));
+ i_pQueryParameters->PreviousPageLastSortFieldValue[sizeof (i_pSourceQueryParameters->
+ m_wsPreviousPageLastSortFieldValue)-1] = 0;
+
+ return (true);
+}
+
+static void CopyQueryParametersFromResponse (
+ struct KMSAgent_QueryParameters *i_pQueryParameters,
+ struct KMS_Agent::KMS_Agent__QueryParameters *i_pSourceQueryParameters)
+{
+
+ // copy sort field name
+ if (i_pSourceQueryParameters->SortFieldName)
+ {
+ strncpy(i_pQueryParameters->m_wsSortFieldName,
+ i_pSourceQueryParameters->SortFieldName,
+ sizeof(i_pQueryParameters->m_wsSortFieldName));
+ i_pQueryParameters->m_wsSortFieldName[sizeof(i_pQueryParameters->m_wsSortFieldName)-1] = '\0';
+ }
+
+ // copy order
+ i_pQueryParameters->m_eSortOrder =
+ (KMSAgent_SortOrder) i_pSourceQueryParameters->SortOrder;
+
+ // copy filter parameters
+ i_pQueryParameters->m_iSizeFilterParameters =
+ i_pSourceQueryParameters->FilterParameters.__size;
+
+ // we only accept this amount of parameters
+ if (i_pQueryParameters->m_iSizeFilterParameters >= KMS_MAX_AGENT_FILTER_PARAMETERS)
+ {
+ // this should not happen, but just for defending the code
+ i_pQueryParameters->m_iSizeFilterParameters = KMS_MAX_AGENT_FILTER_PARAMETERS;
+ }
+
+ for (int i = 0; i < i_pQueryParameters->m_iSizeFilterParameters; i++)
+ {
+ struct KMS_Agent::KMS_Agent__FilterParameters *pParameters;
+
+ pParameters = i_pSourceQueryParameters->FilterParameters.__ptr + i;
+
+ i_pQueryParameters->m_aFilterParameters[i].m_eFilterOperator
+ = (KMSAgent_FilterOperator) pParameters->FilterOperator;
+
+ if (pParameters->FieldName)
+ {
+ strncpy(i_pQueryParameters->m_aFilterParameters[i].m_wsFieldName,
+ pParameters->FieldName,
+ sizeof (i_pQueryParameters->m_aFilterParameters[i].m_wsFieldName));
+ i_pQueryParameters->
+ m_aFilterParameters[i].m_wsFieldName[sizeof (i_pQueryParameters->m_aFilterParameters[i].m_wsFieldName) - 1] = '\0';
+ }
+
+ if (pParameters->FieldValue)
+ {
+ strncpy(i_pQueryParameters->m_aFilterParameters[i].m_wsFieldValue,
+ pParameters->FieldValue,
+ sizeof(i_pQueryParameters->m_aFilterParameters[i].m_wsFieldValue));
+ i_pQueryParameters->
+ m_aFilterParameters[i].m_wsFieldValue[sizeof(i_pQueryParameters->m_aFilterParameters[i].m_wsFieldValue)-1] = '\0';
+ }
+ }
+ // copy PreviousPageLastIDValue
+ if (i_pSourceQueryParameters->PreviousPageLastIDValue)
+ {
+ strncpy(i_pQueryParameters->m_wsPreviousPageLastIDValue,
+ i_pSourceQueryParameters->PreviousPageLastIDValue,
+ sizeof(i_pQueryParameters->m_wsPreviousPageLastIDValue));
+ i_pQueryParameters->m_wsPreviousPageLastIDValue[sizeof(i_pQueryParameters->m_wsPreviousPageLastIDValue)-1] = '\0';
+ }
+
+ // copy PreviousPageLastSortFieldValue
+ if (i_pSourceQueryParameters->PreviousPageLastSortFieldValue)
+ {
+ strncpy(i_pQueryParameters->m_wsPreviousPageLastSortFieldValue,
+ i_pSourceQueryParameters->PreviousPageLastSortFieldValue,
+ sizeof(i_pQueryParameters->m_wsPreviousPageLastSortFieldValue));
+ i_pQueryParameters->m_wsPreviousPageLastSortFieldValue[sizeof(i_pQueryParameters->m_wsPreviousPageLastSortFieldValue)-1] = '\0';
+ }
+
+}
+
+/**
+ * copies data unit to the soap data unit structure, placing the xsd_string types on the
+ * gsoap heap.
+ * @return(false if soap_malloc fails
+ */
+static bool CopyDataUnitFromRequest (struct soap *i_pstSoap,
+ struct KMS_Agent::KMS_Agent__DataUnit *i_pDataUnit,
+ const KMSAgent_DataUnit * const i_pSourceDataUnit)
+{
+
+ if (i_pSourceDataUnit)
+ {
+ // copy field name
+ i_pDataUnit->DataUnitID =
+ (utf8cstr) soap_malloc(i_pstSoap,
+ 2 * sizeof (i_pSourceDataUnit->m_acDataUnitID) + 1);
+ if (i_pDataUnit->DataUnitID == NULL)
+ {
+ return (false);
+ }
+
+ ConvertBinaryToUTF8HexString(i_pDataUnit->DataUnitID,
+ i_pSourceDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+ }
+ else
+ {
+ strcpy(i_pDataUnit->DataUnitID, "");
+ }
+
+ i_pDataUnit->ExternalUniqueID = (utf8cstr) soap_malloc(i_pstSoap,
+ 2 * sizeof (i_pSourceDataUnit->m_acExternalUniqueID) + 1);
+ if (i_pDataUnit->ExternalUniqueID == NULL)
+ {
+ return (false);
+ }
+
+ if (i_pSourceDataUnit->m_iExternalUniqueIDLength > 0 &&
+ i_pSourceDataUnit->m_iExternalUniqueIDLength <= KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE)
+ {
+ ConvertBinaryToUTF8HexString(i_pDataUnit->ExternalUniqueID,
+ i_pSourceDataUnit->m_acExternalUniqueID,
+ i_pSourceDataUnit->m_iExternalUniqueIDLength);
+ }
+ else
+ {
+ strcpy(i_pDataUnit->ExternalUniqueID, "");
+ }
+
+ i_pDataUnit->ExternalTag = (utf8cstr) soap_malloc(i_pstSoap, sizeof (i_pSourceDataUnit->m_acExternalTag));
+ if (i_pDataUnit->ExternalTag == NULL)
+ {
+ return (false);
+ }
+
+ if (strlen(i_pSourceDataUnit->m_acExternalTag) <= sizeof (i_pSourceDataUnit->m_acExternalTag))
+ {
+ strncpy(i_pDataUnit->ExternalTag,
+ i_pSourceDataUnit->m_acExternalTag,
+ sizeof (i_pSourceDataUnit->m_acExternalTag));
+ i_pDataUnit->ExternalTag[sizeof (i_pSourceDataUnit->m_acExternalTag)-1] = '\0';
+ }
+ else
+ {
+ strcpy(i_pDataUnit->ExternalTag, "");
+ }
+
+ i_pDataUnit->Description = (utf8cstr) soap_malloc(i_pstSoap, sizeof (i_pSourceDataUnit->m_acDescription));
+ if (i_pDataUnit->Description == NULL)
+ {
+ return (false);
+ }
+ if (strlen(i_pSourceDataUnit->m_acDescription) <= sizeof (i_pSourceDataUnit->m_acDescription))
+ {
+ strncpy(i_pDataUnit->Description,
+ i_pSourceDataUnit->m_acDescription,
+ sizeof (i_pSourceDataUnit->m_acDescription));
+ i_pDataUnit->Description[sizeof (i_pSourceDataUnit->m_acDescription)-1] = '\0';
+ }
+ else
+ {
+ strcpy(i_pDataUnit->Description, "");
+ }
+
+ i_pDataUnit->DataUnitState = (KMS_Agent::KMS_Agent__DataUnitState) i_pSourceDataUnit->m_iDataUnitState;
+
+ return (true);
+}
+
+/**
+ * Converts an ExternalUniqueID value to UTF8Hexstring value from gSoap managed heap storage
+ * @param i_pstSoap pointer to gSoap runtime
+ * @param i_pExternalUniqueID non-NULL pointer to an external unique id to be converted
+ * @return(NULL if memory cannot be allocated
+ */
+static char * ConvertBinaryDataFromRequest (struct soap *i_pstSoap,
+ const unsigned char * i_pBinaryData,
+ int i_iBinaryDataLen)
+{
+ char * pBinaryData = (char *) soap_malloc(i_pstSoap, 2 * i_iBinaryDataLen + 1);
+ if (pBinaryData != NULL)
+ {
+ ConvertBinaryToUTF8HexString(pBinaryData,
+ i_pBinaryData,
+ i_iBinaryDataLen);
+ }
+ return (pBinaryData);
+}
+
+/**
+ * Converts a UTF8 char string value to a fixed length array from
+ * gSoap managed heap storage
+ * @param pointer to gSoap runtime
+ * @param i_pUTF8string non-NULL pointer to a null terminated UTF8 string
+ * @param i_iLen size of arrray to be allocated
+ * @return(NULL if gSoap allocated storage could not be obtained
+ */
+static char * ConvertUTF8StringFromRequest (struct soap *i_pstSoap,
+ const char * const i_pUTF8string,
+ size_t i_iLen)
+{
+ char * pUTF8string = NULL;
+ pUTF8string = (char *) soap_malloc(i_pstSoap, i_iLen);
+ if (pUTF8string != NULL)
+ {
+ strncpy(pUTF8string, i_pUTF8string, i_iLen);
+ pUTF8string[i_iLen-1] = '\0';
+ }
+ return (pUTF8string);
+}
+
+static KMSAgent_ArrayOfKeyGroups * CopyKeyGroupsResponse
+(
+ struct KMS_Agent::KMS_Agent__ArrayOfKeyGroups *i_pKeyGroupsResponse
+ )
+{
+ // alloc memory for result
+ KMSAgent_ArrayOfKeyGroups *pResult =
+ (KMSAgent_ArrayOfKeyGroups *) calloc(1, sizeof (KMSAgent_ArrayOfKeyGroups));
+
+ // no memory, return
+ if (pResult == NULL)
+ {
+ return (NULL);
+ }
+
+ // copy size
+ pResult->m_iSize = i_pKeyGroupsResponse->__size;
+
+ // if the size is 0, return(an empty result
+ if (pResult->m_iSize == 0)
+ {
+ return (pResult);
+ }
+
+ // alloc memory for all key groups
+ pResult->m_pKeyGroups = (KMSAgent_KeyGroup*)
+ calloc(1, sizeof (KMSAgent_KeyGroup) * pResult->m_iSize);
+
+ if (pResult->m_pKeyGroups == NULL)
+ {
+ free(pResult);
+ return (NULL);
+ }
+
+ for (int i = 0; i < pResult->m_iSize; i++)
+ {
+ KMSAgent_KeyGroup *pKeyGroup;
+
+ pKeyGroup = &(pResult->m_pKeyGroups[i]);
+
+ strncpy(pKeyGroup->m_acKeyGroupID,
+ i_pKeyGroupsResponse->__ptr[i].KeyGroupID,
+ sizeof(pKeyGroup->m_acKeyGroupID));
+ pKeyGroup->m_acKeyGroupID[sizeof(pKeyGroup->m_acKeyGroupID)-1] = '\0';
+
+ strncpy(pKeyGroup->m_acDescription,
+ i_pKeyGroupsResponse->__ptr[i].Description,
+ sizeof(pKeyGroup->m_acDescription));
+ pKeyGroup->m_acDescription[sizeof(pKeyGroup->m_acDescription)-1] = '\0';
+ }
+
+ return (pResult);
+}
+/**
+ * allocate storage for the KMSAgent_ArrayOfKeys struct and the array of keys returned in the
+ * soap response.
+ * @param i_pProfile pointer to profile
+ * @param io_pClusterIndex pointer to the cluster index value which is used
+ * by AES Key Unwrap to access the KWK for the KMA corresponding to the
+ * cluster index.
+ * @param i_pKeysResponse pointer to the soap response' array of keys struct
+ * @return(pointer to allocated KMSAgent_ArrayOfKeys and the corresponding keys, returns NULL
+ * on any error and frees any allocated storage before returning. For response data validation errors a
+ * message will be logged.
+ */
+static KMSAgent_ArrayOfKeys * CopyDataUnitKeysResponse (
+ KMSClientProfile *i_pProfile,
+ int * const io_pClusterIndex,
+ struct KMS_Agent::KMS_Agent__ArrayOfKeys *i_pKeysResponse)
+{
+ KMSAgent_ArrayOfKeys * pResult =
+ (KMSAgent_ArrayOfKeys *) calloc(1, sizeof (KMSAgent_ArrayOfKeys));
+
+ if (pResult == NULL)
+ {
+ return (NULL);
+ }
+
+ // if the size is 0, return(an empty result
+ if (i_pKeysResponse->__size == 0)
+ {
+ return (pResult);
+ }
+
+ if (i_pKeysResponse->__size > KMS_MAX_PAGE_SIZE)
+ {
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_ARRAY_SIZE_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+
+ pResult->m_iSize = i_pKeysResponse->__size;
+
+ // alloc memory for all keys returned
+ pResult->m_pKeys = (KMSAgent_Key*)
+ calloc(1, sizeof (KMSAgent_Key) * i_pKeysResponse->__size);
+
+ if (pResult->m_pKeys == NULL)
+ {
+ free(pResult);
+ return (NULL);
+ // no memory, don't log
+ }
+
+ // copy keys from response
+ for (int i = 0; i < i_pKeysResponse->__size; i++)
+ {
+ if (KMS_KEY_ID_SIZE != ConvertUTF8HexStringToBinary(
+ i_pKeysResponse->__ptr[i].KeyID, NULL))
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+
+ ConvertUTF8HexStringToBinary(
+ i_pKeysResponse->__ptr[i].KeyID, pResult->m_pKeys[i].m_acKeyID);
+
+ if ((KMS_AGENT_KEY_STATE) i_pKeysResponse->__ptr[i].KeyState < KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS ||
+ (KMS_AGENT_KEY_STATE) i_pKeysResponse->__ptr[i].KeyState > KMS_KEY_STATE_COMPROMISED)
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_STATE_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+ pResult->m_pKeys[i].m_iKeyState = (KMS_AGENT_KEY_STATE) i_pKeysResponse->__ptr[i].KeyState;
+
+ if ((KMS_KEY_TYPE) i_pKeysResponse->__ptr[i].KeyType != (KMS_KEY_TYPE)KMS_KEY_TYPE_AES_256)
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_TYPE_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+ pResult->m_pKeys[i].m_iKeyType = (KMS_KEY_TYPE) i_pKeysResponse->__ptr[i].KeyType;
+
+ strncpy(pResult->m_pKeys[i].m_acKeyGroupID,
+ i_pKeysResponse->__ptr[i].KeyGroupID,
+ sizeof(pResult->m_pKeys[i].m_acKeyGroupID));
+ pResult->m_pKeys[i].m_acKeyGroupID[sizeof(pResult->m_pKeys[i].m_acKeyGroupID)-1] = '\0';
+
+ CAgentLoadBalancer *pAgentLoadBalancer = reinterpret_cast
+ <CAgentLoadBalancer *> (i_pProfile->m_pAgentLoadBalancer);
+
+ if (pAgentLoadBalancer->AESKeyWrapSupported(*io_pClusterIndex))
+ {
+ if (i_pKeysResponse->__ptr[i].Key.__size != KMS_MAX_WRAPPED_KEY_SIZE)
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_WRAPPED_KEY_LENGTH_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+ else
+ {
+ if (pAgentLoadBalancer->AESKeyUnwrap(io_pClusterIndex,
+ i_pKeysResponse->__ptr[i].Key.__ptr,
+ pResult->m_pKeys[i].m_acKey) == false)
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_AESKEYUNWRAP_ERROR,
+ NULL,
+ NULL,
+ NULL);
+
+ return (NULL);
+ }
+ }
+ }
+ else // non-AES Key Wrap
+ {
+ if (i_pKeysResponse->__ptr[i].Key.__size != KMS_MAX_KEY_SIZE)
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_LENGTH_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+
+ memcpy(pResult->m_pKeys[i].m_acKey,
+ i_pKeysResponse->__ptr[i].Key.__ptr,
+ KMS_MAX_KEY_SIZE);
+ }
+
+ pResult->m_pKeys[i].m_iKeyLength = KMS_MAX_KEY_SIZE;
+
+ if (KMSAgentKeyCallout(pResult->m_pKeys[i].m_acKey) != 0)
+ {
+ free(pResult->m_pKeys);
+ free(pResult);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_KEY_CALLOUT_ERROR,
+ NULL,
+ NULL,
+ NULL);
+ return (NULL);
+ }
+ }
+
+ return (pResult);
+}
+
+/**
+ * This function returns the API status code based upon the error string in the profile and
+ * availability of KMAs. KMA availability determination is based upon the i_iKMAFailoverReturnCode
+ * parameter and the size of the cluster. A cluster size of 0 is an indicator that there are
+ * no KMAs available, unless cluster discovery is disabled by the profile's cluster discovery
+ * frequency.
+ *
+ * @param i_pProfile pointer to the profile
+ * @param i_iKMAFailoverReturnCode the return(code from CAgentLoadBalancer::Failover() or 0
+ * if it was not called. This is used to for determining if KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * needs to be returned.
+ * @returns KMS_AGENT_STATUS_GENERIC_ERROR
+ * unless the profile's last error message field contains a message substring matching one of the
+ * KMSAgent service soap fault strings.
+ *
+ */
+static KMS_AGENT_STATUS KMSAgent_GetLastStatusCode (KMSClientProfile *i_pProfile,
+ int i_iKMAFailoverReturnCode)
+{
+ bool bServerError = false;
+
+ FATAL_ASSERT(i_pProfile);
+
+ // see KMSAgentLoadBalancer.h for return codes from Failover
+
+ if (i_iKMAFailoverReturnCode == CAgentLoadBalancer::NO_FIPS_KMA_AVAILABLE)
+ {
+ return (KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE);
+ }
+
+ // parse for server errors -
+ // when KMAs have no ready keys we want to inform the client, vs reporting that the KMS is unavailable
+ bServerError = ServerError(i_pProfile->m_wsErrorString, 0);
+
+ // parse for Soap errors
+ const char* sFaultstringStart = strstr(i_pProfile->m_wsErrorString, "SoapFaultString=");
+
+ int iErrorCode = INVALID_CLIENT_ERROR; // initially
+
+
+ // if there is a Soap error
+ if (sFaultstringStart)
+ {
+ if (SSL_InvalidCertificate(sFaultstringStart))
+ {
+ // this can be caused by the KMS invalidating the agent's cert
+ return (KMS_AGENT_STATUS_ACCESS_DENIED);
+ }
+ iErrorCode = GET_FAULT_CODE(sFaultstringStart + strlen("SoapFaultString="));
+ }
+
+
+#ifdef METAWARE
+ // log the failure code/cause to the event log
+ LogToFile(i_iKMAFailoverReturnCode, i_pProfile->m_wsErrorString);
+ LogToFile(iErrorCode, "error code");
+#endif
+
+
+ // parse return code passed in from last call to FailOver, Balance or BalanceByDataUnitKeyID
+ // if failover reported no kma and there is a valid server error and client couldn't get keys
+ if (i_iKMAFailoverReturnCode == CAgentLoadBalancer::NO_KMA_AVAILABLE &&
+ bServerError &&
+ iErrorCode == CLIENT_ERROR_AGENT_NO_READY_KEYS)
+ {
+ return (KMS_AGENT_STATUS_KMS_UNAVAILABLE);
+ }
+
+ // if there is a server error and we are doing discovery
+ if (bServerError &&
+ ((i_pProfile->m_iClusterDiscoveryFrequency > 0 &&
+ i_pProfile->m_iClusterNum == 0)
+ || iErrorCode == CLIENT_ERROR_AGENT_APPLIANCE_LOCKED))
+ {
+ return (KMS_AGENT_STATUS_KMS_UNAVAILABLE);
+ }
+
+ if (bServerError && i_iKMAFailoverReturnCode == CAgentLoadBalancer::NO_KMA_AVAILABLE)
+ {
+ return (KMS_AGENT_STATUS_KMS_UNAVAILABLE);
+ }
+
+ if ( i_iKMAFailoverReturnCode == CAgentLoadBalancer::AES_KEY_UNWRAP_ERROR )
+ return (KMS_AGENT_AES_KEY_UNWRAP_ERROR);
+ if ( i_iKMAFailoverReturnCode == CAgentLoadBalancer::AES_KEY_WRAP_SETUP_ERROR )
+ return (KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR);
+
+ if (iErrorCode == CLIENT_ERROR_ACCESS_DENIED)
+ return (KMS_AGENT_STATUS_ACCESS_DENIED);
+ if (iErrorCode == CLIENT_ERROR_SERVER_BUSY)
+ return (KMS_AGENT_STATUS_SERVER_BUSY);
+ if (iErrorCode == CLIENT_ERROR_AGENT_INVALID_PARAMETERS)
+ return (KMS_AGENT_STATUS_INVALID_PARAMETER);
+ if (iErrorCode == CLIENT_ERROR_AGENT_KEY_DOES_NOT_EXIST)
+ return (KMS_AGENT_STATUS_KEY_DOES_NOT_EXIST);
+ if (iErrorCode == CLIENT_ERROR_AGENT_KEY_DESTROYED)
+ return (KMS_AGENT_STATUS_KEY_DESTROYED);
+ if (iErrorCode == CLIENT_ERROR_AGENT_DATA_UNIT_ID_NOT_FOUND_EXTERNAL_ID_EXISTS)
+ return (KMS_AGENT_STATUS_DATA_UNIT_ID_NOT_FOUND_EXTERNAL_ID_EXISTS);
+ if (iErrorCode == CLIENT_ERROR_AGENT_DUPLICATE_EXTERNAL_ID)
+ return (KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS);
+ if (iErrorCode == CLIENT_ERROR_AGENT_NO_READY_KEYS)
+ return (KMS_AGENT_STATUS_KMS_NO_READY_KEYS);
+
+ // this check is made last to allow other specific errors that may have occurred to take precedence,
+ // e.g. return access denied before reporting No FIPS KMAs
+ if (i_pProfile->m_eKMSmode == FIPS_MODE &&
+ KMSClient_NoFIPSCompatibleKMAs(i_pProfile))
+ {
+ return (KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE);
+ }
+
+ return (KMS_AGENT_STATUS_GENERIC_ERROR);
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_InitializeLibrary
+ *--------------------------------------------------------------------------*/
+#include "KMSAuditLogger.h"
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_InitializeLibrary (utf8cstr const i_pWorkingDirectory,
+ int i_bUseFileLog)
+
+{
+ bool bSuccess;
+
+#if defined(METAWARE)
+#warn "debug timing is on"
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_InitializeLibrary);
+#endif
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSAgent_InitializeLibrary : Entered");
+#endif
+
+ bSuccess = KMSClient_InitializeLibrary(
+ i_pWorkingDirectory,
+ i_bUseFileLog);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMS_AGENT_STATUS_GENERIC_ERROR);
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_KnownAnswerTests
+ *
+ *--------------------------------------------------------------------------*/
+KMS_AGENT_STATUS KMSAgent_KnownAnswerTests()
+{
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_KnownAnswerTests);
+#endif
+
+ // Known Answer Test on AES Key Wrap code
+ if ( KnownAnswerTestAESKeyWrap() != 0 )
+ {
+ RETURN(KMS_AGENT_STATUS_FIPS_KAT_AES_KEYWRAP_ERROR);
+ }
+
+ if ( KnownAnswerTestAESECB() != 0 )
+ {
+ RETURN(KMS_AGENT_STATUS_FIPS_KAT_AES_ECB_ERROR);
+ }
+
+ if ( KnownAnswerTestHMACSHA1() != 0 )
+ {
+ RETURN(KMS_AGENT_STATUS_FIPS_KAT_HMAC_SHA1_ERROR);
+ }
+
+ RETURN(KMS_AGENT_STATUS_OK);
+
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_FinalizeLibrary
+ *
+ *--------------------------------------------------------------------------*/
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_FinalizeLibrary ()
+{
+ bool bSuccess;
+
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_FinalizeLibrary);
+#endif
+
+ bSuccess = KMSClient_FinalizeLibrary();
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMS_AGENT_STATUS_GENERIC_ERROR);
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_GetLastErrorMessage
+ *
+ *--------------------------------------------------------------------------*/
+
+extern "C"
+utf8cstr KMSAgent_GetLastErrorMessage (KMSClientProfile* i_pProfile)
+{
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_GetLastErrorMessage);
+#endif
+
+ if (i_pProfile == NULL)
+ {
+ RETURN(NULL);
+ }
+
+ RETURN(KMSClient_GetLastErrorMessage(i_pProfile));
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_GetClusterInformation
+ *
+ *--------------------------------------------------------------------------*/
+extern "C"
+KMS_AGENT_STATUS KMSAgent_GetClusterInformation (
+ KMSClientProfile * const i_pProfile,
+ int i_iEntitySiteIDSize,
+ int i_iClusterEntryArraySize,
+ utf8cstr const o_pEntitySiteID,
+ int * const o_pApplianceNum,
+ KMSClusterEntry * const o_pClusterEntryArray)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_GetClusterInformation);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!o_pEntitySiteID || (i_iEntitySiteIDSize <= (KMS_MAX_ENTITY_SITE_ID)))
+ {
+ Log(AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "EntitySiteIDSize arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_iClusterEntryArraySize > KMS_MAX_CLUSTER_NUM)
+ {
+ Log(AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "i_iClusterEntryArraySize exceeds KMS_MAX_CLUSTER_NUM");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!o_pApplianceNum)
+ {
+ Log(AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ApplianceNum arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!o_pClusterEntryArray ||
+ (i_iClusterEntryArraySize <= 0))
+ {
+ Log(AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ClusterEntry or Size arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ bSuccess = KMSClient_GetClusterInformation(
+ i_pProfile,
+ o_pEntitySiteID,
+ i_iEntitySiteIDSize,
+ o_pApplianceNum,
+ o_pClusterEntryArray,
+ i_iClusterEntryArraySize);
+
+ // KMSClient_GetClusterInformation logs if there was an error
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, 0));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_SelectAppliance (
+ KMSClientProfile * const i_pProfile,
+ utf8cstr const i_pApplianceAddress)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_SelectAppliance);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_SELECT_APPLIANCE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pApplianceAddress)
+ {
+ Log(AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ApplianceAddress arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ // All modes are supported by this function.
+
+ bSuccess = KMSClient_SelectAppliance(i_pProfile, i_pApplianceAddress);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, 0));
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_LoadProfile
+ *
+ *--------------------------------------------------------------------------*/
+extern "C"
+KMS_AGENT_STATUS KMSAgent_LoadProfile (
+ KMSClientProfile * const io_pProfile,
+ utf8cstr const i_pProfileName,
+ utf8cstr const i_pAgentID,
+ utf8cstr const i_pPassphrase,
+ utf8cstr const i_pInitialApplianceAddress,
+ int i_iTransactionTimeout,
+ int i_iFailOverLimit,
+ int i_iClusterDiscoveryFrequency,
+ int i_eKMSmode)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_LoadProfile);
+#endif
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSAgent_LoadProfile : Entered");
+#endif
+ if (!io_pProfile ||
+ !i_pProfileName || (strlen(i_pProfileName) <= 0))
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile or Name arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pInitialApplianceAddress || (strlen(i_pInitialApplianceAddress) <= 0))
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "InitialApplianceAddress arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_iTransactionTimeout <= 0)
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "TransactionTimeout arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (i_iClusterDiscoveryFrequency < 0)
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ClusterDiscoveryFrequency arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ // for enrollment both arguments are required
+ if ((i_pAgentID && !i_pPassphrase) || (i_pPassphrase && !i_pAgentID))
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Enrollment requires AgentID & Passphrase");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pAgentID && (strlen(i_pAgentID) <= 0))
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "AgentID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pPassphrase && (strlen(i_pPassphrase) <= 0))
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Passphrase arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if ( i_eKMSmode != DEFAULT_MODE && i_eKMSmode != FIPS_MODE )
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "KMS security mode arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (KMSClient_ProfileLoaded(io_pProfile))
+ {
+ Log(AUDIT_CLIENT_AGENT_LOAD_PROFILE_PROFILE_ALREADY_LOADED,
+ NULL,
+ NULL,
+ "profile is already loaded and should be unloaded first");
+ RETURN(KMS_AGENT_STATUS_PROFILE_ALREADY_LOADED);
+ }
+
+ memset(io_pProfile, 0, sizeof (KMSClientProfile));
+ char sInitialApplianceAddress[KMS_MAX_NETWORK_ADDRESS+1];
+ strncpy(sInitialApplianceAddress, i_pInitialApplianceAddress, sizeof(sInitialApplianceAddress));
+ sInitialApplianceAddress[sizeof(sInitialApplianceAddress)-1] = '\0';
+
+ // Convert to lower case
+
+ for ( size_t i = 0; i < strlen( sInitialApplianceAddress ); i++ )
+ {
+ if ( isupper( sInitialApplianceAddress[i] ) )
+ {
+ sInitialApplianceAddress[i] = tolower( sInitialApplianceAddress[i] );
+ }
+ }
+
+ bSuccess = KMSClient_LoadProfile(
+ io_pProfile,
+ i_pProfileName,
+ i_pAgentID,
+ i_pPassphrase,
+ sInitialApplianceAddress,
+ i_iTransactionTimeout,
+ i_iFailOverLimit,
+ i_iClusterDiscoveryFrequency,
+ i_eKMSmode);
+
+ if (bSuccess)
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSAgent_LoadProfile : Returned ok");
+#endif
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ // when not enrolling & cluster discovery is disabled there are no
+ // soap transactions so failover would not have occurred
+ bool bEnrolling = i_pAgentID && i_pPassphrase;
+
+ if (!bEnrolling &&
+ i_iClusterDiscoveryFrequency == 0)
+ {
+ RETURN(KMSAgent_GetLastStatusCode(io_pProfile, 0));
+ }
+ else
+ {
+// if (i_eKMSmode == FIPS_MODE &&
+// KMSClient_NoFIPSCompatibleKMAs(io_pProfile))
+// {
+// RETURN(KMSAgent_GetLastStatusCode(io_pProfile,
+// CAgentLoadBalancer::NO_FIPS_KMA_AVAILABLE));
+// }
+
+ RETURN(KMSAgent_GetLastStatusCode(io_pProfile,
+ CAgentLoadBalancer::NO_KMA_AVAILABLE));
+ }
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_UnloadProfile
+ *
+ *--------------------------------------------------------------------------*/
+extern "C"
+KMS_AGENT_STATUS KMSAgent_UnloadProfile (KMSClientProfile * const i_pProfile)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_UnloadProfile);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_UNLOAD_PROFILE_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ bSuccess = KMSClient_UnloadProfile(i_pProfile);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, 0));
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_DeleteProfile
+ *
+ *--------------------------------------------------------------------------*/
+extern "C"
+KMS_AGENT_STATUS KMSAgent_DeleteProfile (utf8cstr i_pProfileName)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_DeleteProfile);
+#endif
+
+ if (!i_pProfileName || (strlen(i_pProfileName) <= 0))
+ {
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ bSuccess = KMSClient_DeleteProfile(i_pProfileName);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMS_AGENT_STATUS_GENERIC_ERROR);
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_ListKeyGroups
+ *
+ *--------------------------------------------------------------------------*/
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_ListKeyGroups (
+ KMSClientProfile * const i_pProfile,
+ KMSAgent_ArrayOfKeyGroups* * const o_ppKeyGroups)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_ListKeyGroups);
+#endif
+
+ int bIsLastPage;
+ struct KMSAgent_QueryParameters stQueryParameters;
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_ppKeyGroups)
+ {
+ Log(AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "KeyGroups arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+
+ // Get Key Groups
+ memset(&stQueryParameters, 0, sizeof (stQueryParameters));
+
+ struct KMS_Agent::KMS_Agent__QueryParameters oQueryParameters;
+ struct KMS_Agent::KMS_Agent__ListKeyGroupsResponse oResponse;
+
+ memset(&oQueryParameters, 0, sizeof (oQueryParameters));
+
+ bSuccess = CopyQueryParametersFromRequest(pstSoap,
+ KMS_MAX_LIST_KEY_GROUPS,
+ &oQueryParameters,
+ &stQueryParameters);
+ if (!bSuccess)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory, don't log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+
+ int iIndex = pLoadBalancer->Balance();
+
+ if ( iIndex >= 0 )
+ {
+ do
+ {
+ const char* sURL =
+ pLoadBalancer->GetHTTPSURL(iIndex, i_pProfile->m_iPortForAgentService);
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__ListKeyGroups(
+ pstSoap,
+ sURL,
+ NULL,
+ oQueryParameters,
+ oResponse) == SOAP_OK;
+
+ if (!bSuccess)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile, AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ if (bSuccess)
+ {
+ bIsLastPage = oResponse.LastPage;
+
+ *o_ppKeyGroups = CopyKeyGroupsResponse(&oResponse.KeyGroups);
+ if (*o_ppKeyGroups == NULL)
+ {
+ bSuccess = false;
+ // no memory, don't log
+ }
+
+ CopyQueryParametersFromResponse(&stQueryParameters,
+ &oResponse.NextPageQueryParameters);
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ RETURN(KMS_AGENT_STATUS_OK);
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, iIndex));
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_FreeArrayOfKeyGroups
+ *
+ *--------------------------------------------------------------------------*/
+
+extern "C"
+void KMSAgent_FreeArrayOfKeyGroups (
+ struct KMSAgent_ArrayOfKeyGroups *i_pArrayOfKeyGroups)
+{
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_FreeArrayOfKeyGroups);
+#endif
+ if (!i_pArrayOfKeyGroups)
+ {
+ return;
+ }
+
+ // free memory for all information groups
+ if (i_pArrayOfKeyGroups->m_pKeyGroups)
+ {
+ free(i_pArrayOfKeyGroups->m_pKeyGroups);
+ }
+
+ free(i_pArrayOfKeyGroups);
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_CreateKey (
+ KMSClientProfile * const i_pProfile,
+ const KMSAgent_DataUnit * const i_pDataUnit,
+ KEY_GROUP_ID const i_pKeyGroupID,
+ KMSAgent_Key * const o_pKey)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_CreateKey);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_pKey)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Key arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ if (i_pKeyGroupID &&
+ strlen(i_pKeyGroupID) > KMS_MAX_KEY_GROUP_ID_SIZE)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "GroupID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ struct KMS_Agent::KMS_Agent__DataUnit
+ stDataUnit = {"", "", "", "",
+ (KMS_Agent::KMS_Agent__DataUnitState) 0};
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__CreateKeyResponse oResponse;
+
+ if (i_pDataUnit != NULL)
+ {
+ if (!CopyDataUnitFromRequest(pstSoap,
+ &stDataUnit,
+ i_pDataUnit))
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pKeyGroupID = NULL;
+ if (i_pKeyGroupID)
+ {
+ pKeyGroupID = ConvertUTF8StringFromRequest(pstSoap,
+ i_pKeyGroupID,
+ KMS_MAX_KEY_GROUP_ID_SIZE + 1);
+ if (pKeyGroupID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+
+ int iIndex;
+ UTF8_KEYID acKWKID;
+ bool bClientAESKeyWrapSetupError = false;
+
+ if (i_pDataUnit)
+ {
+ // attempt to maintain affinity with KMA for specified DU ID
+ iIndex = pLoadBalancer->BalanceByDataUnitID(
+ i_pDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+ }
+ else
+ {
+ iIndex = pLoadBalancer->Balance();
+ }
+
+ if (iIndex >= 0)
+ {
+ do
+ {
+ bSuccess = true;
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ Long64 lKMAID = pLoadBalancer->GetKMAID(iIndex);
+
+ if (bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // if this fails we want to utilize normal failover logic, GetKWKID
+ // logs error
+ bSuccess = pLoadBalancer->GetKWKID(iIndex, lKMAID, pstSoap,
+ acKWKID, &bClientAESKeyWrapSetupError) ? true : false;
+ if (bSuccess)
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__CreateKey2(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ i_pKeyGroupID ? pKeyGroupID : (char *) "",
+ acKWKID,
+ //NOTE: this is ugly but the soap response struct's are the same for both flavors of CreateKey
+ *(reinterpret_cast<struct KMS_Agent::KMS_Agent__CreateKey2Response *>(&oResponse))) == SOAP_OK;
+ }
+ }
+ else if (bSuccess) // NO AES Key Wrap
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__CreateKey(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ i_pKeyGroupID ? pKeyGroupID : (char *) "",
+ oResponse) == SOAP_OK;
+ }
+
+ // don'f failover for Client side AES Key Wrap setup problems
+ if (!bSuccess && !bClientAESKeyWrapSetupError)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ if (bSuccess)
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess) && (!bClientAESKeyWrapSetupError));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("CreateKey gets keyID %s (size %x) \n",
+ oResponse.Key.KeyID,
+ sizeof (oResponse.Key.KeyID));
+#endif
+
+
+ if (bSuccess)
+ {
+ if (KMS_KEY_ID_SIZE != ConvertUTF8HexStringToBinary(
+ oResponse.Key.KeyID, NULL))
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEYID_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+
+ ConvertUTF8HexStringToBinary(
+ oResponse.Key.KeyID, // in
+ o_pKey->m_acKeyID); // out
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("CreateKey gets keyState %x (size %x) \n",
+ oResponse.Key.KeyState,
+ sizeof (oResponse.Key.KeyState));
+#endif
+
+ if ((KMS_AGENT_KEY_STATE) oResponse.Key.KeyState < KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS ||
+ (KMS_AGENT_KEY_STATE) oResponse.Key.KeyState > KMS_KEY_STATE_COMPROMISED)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_STATE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+
+ o_pKey->m_iKeyState = (KMS_AGENT_KEY_STATE) oResponse.Key.KeyState;
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("CreateKey o_pKey->m_iKeyState %x (size %x) = "
+ "(KMS_AGENT_KEY_STATE) oResponse.Key.KeyState %x (size %x)\n",
+ o_pKey->m_iKeyState,
+ sizeof (o_pKey->m_iKeyState),
+ oResponse.Key.KeyState,
+ sizeof (oResponse.Key.KeyState));
+#endif
+
+
+ if ((KMS_KEY_TYPE) oResponse.Key.KeyType != KMS_KEY_TYPE_AES_256)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_TYPE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ o_pKey->m_iKeyType = (KMS_KEY_TYPE) oResponse.Key.KeyType;
+
+ if (strlen(oResponse.Key.KeyGroupID) > KMS_MAX_KEY_GROUP_ID_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_GROUP_ID_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strncpy(o_pKey->m_acKeyGroupID,
+ oResponse.Key.KeyGroupID,
+ sizeof(o_pKey->m_acKeyGroupID));
+ o_pKey->m_acKeyGroupID[sizeof(o_pKey->m_acKeyGroupID)-1] = '\0';
+ }
+
+ if ( bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // verify KWK ID matches what was registered
+ if (oResponse.Key.Key.__size != KMS_MAX_WRAPPED_KEY_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_WRAPPED_KEY_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ if (pLoadBalancer->AESKeyUnwrap(&iIndex, oResponse.Key.Key.__ptr,
+ o_pKey->m_acKey) == false)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_AESKEYUNWRAP_ERROR,
+ NULL,
+ sKmaAddress,
+ NULL);
+
+ bSuccess = false;
+ }
+ }
+ }
+ else if (bSuccess) // non-AES key wrap
+ {
+ if (oResponse.Key.Key.__size != KMS_MAX_KEY_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ memcpy(o_pKey->m_acKey,
+ oResponse.Key.Key.__ptr,
+ KMS_MAX_KEY_SIZE);
+ }
+ }
+
+ if (bSuccess)
+ {
+ o_pKey->m_iKeyLength = KMS_MAX_KEY_SIZE;
+
+ if (KMSAgentKeyCallout(o_pKey->m_acKey) != 0)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_KEY_KEY_CALLOUT_ERROR,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ }
+ }
+
+ if (bSuccess)
+ {
+ // add Key ID and the creating KMA IP address to the DU cache
+ CDataUnitCache* pDataUnitCache = (CDataUnitCache*) i_pProfile->m_pDataUnitCache;
+
+ if (i_pProfile->m_iClusterDiscoveryFrequency != 0) // load balancing enabled
+ {
+ bSuccess = pDataUnitCache->Insert(
+ NULL,
+ 0,
+ o_pKey->m_acKeyID,
+ KMS_KEY_ID_SIZE,
+ pLoadBalancer->GetApplianceNetworkAddress(iIndex));
+ }
+ }
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile,
+ bClientAESKeyWrapSetupError ?
+ CAgentLoadBalancer::AES_KEY_WRAP_SETUP_ERROR : iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_CreateDataUnit (
+ KMSClientProfile * const i_pProfile,
+ const unsigned char * i_pExternalUniqueID,
+ int i_iExternalUniqueIDIDLen,
+ utf8cstr const i_pExternalTag,
+ utf8cstr const i_pDescription,
+ KMSAgent_DataUnit * const o_pDataUnit)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_CreateDataUnit);
+#endif
+
+#if defined(DEBUG) && defined(METAWARE)
+#warn "debug Create Data Unit is on"
+ log_printf("KMSAgent_CreateDataUnit entered\n");
+ log_printf("KMSAgent_CreateDataUnit profile=%x\n", i_pProfile);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_pDataUnit)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnit arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ // validate input parms
+
+ if (i_pExternalUniqueID &&
+ (i_iExternalUniqueIDIDLen <= 0 ||
+ i_iExternalUniqueIDIDLen > KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE))
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ExternalUniqueID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pExternalTag && strlen(i_pExternalTag) > KMS_MAX_EXTERNAL_TAG)
+ {
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pDescription && strlen(i_pDescription) > KMS_MAX_DESCRIPTION)
+ {
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__CreateDataUnitResponse oResponse;
+
+ char * pExternalUniqueID = NULL;
+ if (i_pExternalUniqueID)
+ {
+ pExternalUniqueID = ConvertBinaryDataFromRequest(pstSoap,
+ i_pExternalUniqueID,
+ i_iExternalUniqueIDIDLen);
+ if (pExternalUniqueID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pExternalTag = NULL;
+ if (i_pExternalTag)
+ {
+ pExternalTag = ConvertUTF8StringFromRequest(pstSoap,
+ i_pExternalTag,
+ strlen(i_pExternalTag) + 1);
+ if (pExternalTag == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pDescription = NULL;
+ if (i_pDescription)
+ {
+ pDescription = ConvertUTF8StringFromRequest(pstSoap,
+ i_pDescription,
+ strlen(i_pDescription) + 1);
+ if (pDescription == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+ int iIndex = pLoadBalancer->Balance();
+
+ if (iIndex >= 0)
+ {
+ do
+ {
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__CreateDataUnit(
+ pstSoap,
+ sURL,
+ NULL,
+ i_pExternalUniqueID ? pExternalUniqueID : (char *) "",
+ i_pExternalTag ? pExternalTag : (char *) "",
+ i_pDescription ? pDescription : (char *) "",
+ oResponse) == SOAP_OK;
+
+ if (!bSuccess)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+
+ }
+ while (iIndex >= 0 && (!bSuccess));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ if (bSuccess)
+ {
+ int iDataUnitIDLength;
+ iDataUnitIDLength = ConvertUTF8HexStringToBinary(
+ oResponse.DataUnit.DataUnitID, o_pDataUnit->m_acDataUnitID);
+
+ if (iDataUnitIDLength != KMS_DATA_UNIT_ID_SIZE)
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("iDataUnitIDLength (%x) != KMS_DATA_UNIT_ID_SIZE (%x)",
+ iDataUnitIDLength,
+ KMS_DATA_UNIT_ID_SIZE);
+#endif
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_RESPONSE_INVALID_DU_ID_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ o_pDataUnit->m_iExternalUniqueIDLength = ConvertUTF8HexStringToBinary(
+ oResponse.DataUnit.ExternalUniqueID, o_pDataUnit->m_acExternalUniqueID);
+
+ if (strlen(oResponse.DataUnit.ExternalTag) > KMS_MAX_EXTERNAL_TAG)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_RESPONSE_INVALID_EXTERNAL_TAG_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strncpy(o_pDataUnit->m_acExternalTag,
+ oResponse.DataUnit.ExternalTag,
+ sizeof(o_pDataUnit->m_acExternalTag));
+ o_pDataUnit->m_acExternalTag[sizeof(o_pDataUnit->m_acExternalTag)-1] = '\0';
+ }
+
+ if (strlen(oResponse.DataUnit.Description) > KMS_MAX_DESCRIPTION)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_RESPONSE_INVALID_DESCRIPTION_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strcpy(o_pDataUnit->m_acDescription,
+ oResponse.DataUnit.Description);
+ }
+
+ o_pDataUnit->m_iDataUnitState =
+ (KMS_AGENT_DATA_UNIT_STATE) oResponse.DataUnit.DataUnitState;
+ }
+
+ if (bSuccess)
+ {
+ // add data unit ID and the creating KMA IP address to the DU cache
+ CDataUnitCache* pDataUnitCache = (CDataUnitCache*) i_pProfile->m_pDataUnitCache;
+
+ if (i_pProfile->m_iClusterDiscoveryFrequency != 0) // load balancing enabled
+ {
+ bSuccess = pDataUnitCache->Insert(
+ o_pDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE,
+ NULL, 0,
+ pLoadBalancer->GetApplianceNetworkAddress(iIndex));
+ }
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_DisassociateDataUnitKeys (
+ KMSClientProfile * const i_pProfile,
+ const KMSAgent_DataUnit * const i_pDataUnit)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_DisassociateDataUnitKeys);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!i_pDataUnit)
+ {
+ Log(AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnit arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ struct KMS_Agent::KMS_Agent__DataUnit stDataUnit = {"", "", "", "",
+ (KMS_Agent::KMS_Agent__DataUnitState) 0};
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__DisassociateDataUnitKeysResponse oResponse;
+
+ if (!CopyDataUnitFromRequest(pstSoap,
+ &stDataUnit,
+ i_pDataUnit))
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+ int iIndex = pLoadBalancer->BalanceByDataUnitID(
+ i_pDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+
+ if (iIndex >= 0)
+ {
+ do
+ {
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__DisassociateDataUnitKeys(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ oResponse) == SOAP_OK;
+
+ if (!bSuccess)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ // no response data for this transaction
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_RetrieveKey (
+ KMSClientProfile * const i_pProfile,
+ const unsigned char * const i_pKeyID,
+ const KMSAgent_DataUnit * const i_pDataUnit,
+ utf8cstr const i_pKeyGroupID,
+ KMSAgent_Key * const o_pKey)
+{
+ bool bSuccess;
+
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_RetrieveKey);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pKeyID)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "KeyID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_pKey)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Key arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ if (i_pKeyGroupID &&
+ strlen(i_pKeyGroupID) > KMS_MAX_KEY_GROUP_ID_SIZE)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "GroupID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ struct KMS_Agent::KMS_Agent__DataUnit stDataUnit = {"", "", "", "",
+ (KMS_Agent::KMS_Agent__DataUnitState) 0};
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__RetrieveKeyResponse oResponse;
+
+ char * pKeyID = NULL;
+ pKeyID = ConvertBinaryDataFromRequest(pstSoap,
+ i_pKeyID,
+ KMS_KEY_ID_SIZE);
+ if (pKeyID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+
+ if (i_pDataUnit != NULL)
+ {
+ if (!CopyDataUnitFromRequest(pstSoap,
+ &stDataUnit,
+ i_pDataUnit))
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pKeyGroupID = NULL;
+ if (i_pKeyGroupID)
+ {
+ pKeyGroupID = ConvertUTF8StringFromRequest(pstSoap,
+ i_pKeyGroupID,
+ KMS_MAX_KEY_GROUP_ID_SIZE + 1);
+ if (pKeyGroupID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ UTF8_KEYID acKWKID;
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ bool bClientAESKeyWrapSetupError = false;
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+ int iIndex = pLoadBalancer->BalanceByDataUnitKeyID(i_pKeyID, KMS_KEY_ID_SIZE);
+
+ if (iIndex >= 0)
+ {
+ do
+ {
+ bSuccess = true;
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ Long64 lKMAID = pLoadBalancer->GetKMAID(iIndex);
+
+ if (bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // if this fails we want to utilize normal failover logic, GetKWKID
+ // logs error
+ bSuccess = pLoadBalancer->GetKWKID(iIndex, lKMAID, pstSoap,
+ acKWKID, &bClientAESKeyWrapSetupError) ? true : false;
+ if (bSuccess)
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveKey2(
+ pstSoap,
+ sURL,
+ NULL,
+ pKeyID,
+ stDataUnit,
+ i_pKeyGroupID ? i_pKeyGroupID : (char *) "",
+ acKWKID,
+ //NOTE: this is ugly but the soap response struct's are the same for both flavors of CreateKey
+ *(reinterpret_cast<struct KMS_Agent::KMS_Agent__RetrieveKey2Response *>(&oResponse))) == SOAP_OK;
+ }
+ }
+ else if (bSuccess) // NO AES Key Wrap
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveKey(
+ pstSoap,
+ sURL,
+ NULL,
+ pKeyID,
+ stDataUnit,
+ i_pKeyGroupID ? i_pKeyGroupID : (char *) "",
+ oResponse) == SOAP_OK;
+ }
+
+ // don'f failover for Client side AES Key Wrap setup problems
+ if (!bSuccess && !bClientAESKeyWrapSetupError)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ if (bSuccess)
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess) && (!bClientAESKeyWrapSetupError));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ if (bSuccess)
+ {
+ if (KMS_KEY_ID_SIZE != ConvertUTF8HexStringToBinary(
+ oResponse.Key.KeyID, NULL))
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEYID_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ }
+
+ if (bSuccess)
+ {
+ ConvertUTF8HexStringToBinary(
+ oResponse.Key.KeyID, o_pKey->m_acKeyID);
+
+ //if ( oResponse.Key.KeyState < (KMS_Agent__KeyState)KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS ||
+ // oResponse.Key.KeyState > (KMS_Agent__KeyState)KMS_KEY_STATE_COMPROMISED )
+ if ((KMS_AGENT_KEY_STATE) oResponse.Key.KeyState < KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS ||
+ (KMS_AGENT_KEY_STATE) oResponse.Key.KeyState > KMS_KEY_STATE_COMPROMISED)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_STATE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+
+ o_pKey->m_iKeyState = (KMS_AGENT_KEY_STATE) oResponse.Key.KeyState;
+
+ if ((KMS_KEY_TYPE) oResponse.Key.KeyType != KMS_KEY_TYPE_AES_256)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_TYPE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+
+ o_pKey->m_iKeyType = (KMS_KEY_TYPE) oResponse.Key.KeyType;
+
+ if (strlen(oResponse.Key.KeyGroupID) > KMS_MAX_KEY_GROUP_ID_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_GROUP_ID_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strncpy(o_pKey->m_acKeyGroupID,
+ oResponse.Key.KeyGroupID,
+ sizeof(o_pKey->m_acKeyGroupID));
+ o_pKey->m_acKeyGroupID[sizeof(o_pKey->m_acKeyGroupID)-1] = '\0';
+ }
+
+ if ( bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // verify KWK ID matches what was registered
+ if (oResponse.Key.Key.__size != KMS_MAX_WRAPPED_KEY_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_WRAPPED_KEY_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ if (pLoadBalancer->AESKeyUnwrap(&iIndex, oResponse.Key.Key.__ptr,
+ o_pKey->m_acKey) == false)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_AESKEYUNWRAP_ERROR,
+ NULL,
+ sKmaAddress,
+ NULL);
+
+ bSuccess = false;
+ }
+ }
+ }
+ else if (bSuccess) // non-AES key wrap
+ {
+ if (oResponse.Key.Key.__size != KMS_MAX_KEY_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ memcpy(o_pKey->m_acKey,
+ oResponse.Key.Key.__ptr,
+ KMS_MAX_KEY_SIZE);
+ }
+ }
+
+ if (bSuccess)
+ {
+ o_pKey->m_iKeyLength = KMS_MAX_KEY_SIZE;
+
+ if (KMSAgentKeyCallout(o_pKey->m_acKey) != 0)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_KEY_KEY_CALLOUT_ERROR,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ }
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile,
+ bClientAESKeyWrapSetupError ?
+ CAgentLoadBalancer::AES_KEY_WRAP_SETUP_ERROR : iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_RetrieveDataUnit (
+ KMSClientProfile * const i_pProfile,
+ const unsigned char * const i_pDataUnitID,
+ const unsigned char * const i_pExternalUniqueID,
+ int i_iExternalUniqueIDLen,
+ utf8cstr const i_pExternalTag,
+ utf8cstr const i_pDescription,
+ KMSAgent_DataUnit * const o_pDataUnit)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_RetrieveDataUnit);
+#endif
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSAgent_RetrieveDataUnit entered\n");
+#endif
+
+ // required parms
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pDataUnitID)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnitID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_pDataUnit)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnit arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSAgent_RetrieveDataUnit profile not loaded\n");
+#endif
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ // validate input parms
+
+ if (i_pExternalUniqueID &&
+ (i_iExternalUniqueIDLen <= 0 ||
+ i_iExternalUniqueIDLen > KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE))
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ExternalUniqueID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pExternalTag && strlen(i_pExternalTag) > KMS_MAX_EXTERNAL_TAG)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ExternalTag arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pDescription &&
+ strlen(i_pDescription) > KMS_MAX_DESCRIPTION)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Description arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ // prepare args to soap transaction
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__RetrieveDataUnitResponse oResponse;
+
+ char * pDataUnitID = NULL;
+ pDataUnitID = ConvertBinaryDataFromRequest(pstSoap,
+ i_pDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+ //sizeof(DATA_UNIT_ID) );
+ if (pDataUnitID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+
+ char * pExternalUniqueID = NULL;
+ if (i_pExternalUniqueID)
+ {
+ pExternalUniqueID = ConvertBinaryDataFromRequest(pstSoap,
+ i_pExternalUniqueID,
+ i_iExternalUniqueIDLen);
+ if (pExternalUniqueID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pExternalTag = NULL;
+ if (i_pExternalTag)
+ {
+ pExternalTag = ConvertUTF8StringFromRequest(pstSoap,
+ i_pExternalTag,
+ KMS_MAX_EXTERNAL_TAG + 1);
+ if (pExternalTag == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pDescription = NULL;
+ if (i_pDescription)
+ {
+ pDescription = ConvertUTF8StringFromRequest(pstSoap,
+ i_pDescription,
+ KMS_MAX_DESCRIPTION + 1);
+ if (pDescription == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+ int iIndex = pLoadBalancer->BalanceByDataUnitID(i_pDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+
+ if ( iIndex >= 0 )
+ {
+ do
+ {
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveDataUnit(
+ pstSoap,
+ sURL,
+ NULL,
+ pDataUnitID,
+ i_pExternalUniqueID ? pExternalUniqueID : (char *) "",
+ i_pExternalTag ? pExternalTag : (char *) "",
+ i_pDescription ? pDescription : (char *) "",
+ oResponse) == SOAP_OK;
+
+ if (!bSuccess)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ if (bSuccess)
+ {
+ ConvertUTF8HexStringToBinary(
+ oResponse.DataUnit.DataUnitID, o_pDataUnit->m_acDataUnitID);
+
+ o_pDataUnit->m_iExternalUniqueIDLength = ConvertUTF8HexStringToBinary(
+ oResponse.DataUnit.ExternalUniqueID, o_pDataUnit->m_acExternalUniqueID);
+
+ if (strlen(oResponse.DataUnit.ExternalTag) > KMS_MAX_EXTERNAL_TAG)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_RESPONSE_INVALID_EXTERNAL_TAG_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strncpy(o_pDataUnit->m_acExternalTag,
+ oResponse.DataUnit.ExternalTag,
+ sizeof(o_pDataUnit->m_acExternalTag));
+ o_pDataUnit->m_acExternalTag[sizeof(o_pDataUnit->m_acExternalTag)-1] = '\0';
+ }
+
+ if (strlen(oResponse.DataUnit.Description) > KMS_MAX_DESCRIPTION)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_RESPONSE_INVALID_DESCRIPTION_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strcpy(o_pDataUnit->m_acDescription,
+ oResponse.DataUnit.Description);
+ }
+
+ o_pDataUnit->m_iDataUnitState =
+ (KMS_AGENT_DATA_UNIT_STATE) oResponse.DataUnit.DataUnitState;
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_RetrieveDataUnitByExternalUniqueID (
+ KMSClientProfile * const i_pProfile,
+ const unsigned char* const i_pExternalUniqueID,
+ int i_iExternalUniqueIDLen,
+ utf8cstr const i_pExternalTag,
+ utf8cstr const i_pDescription,
+ KMSAgent_DataUnit * const o_pDataUnit)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_RetrieveDataUnitByExternalUniqueID);
+#endif
+
+ // required parms
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pExternalUniqueID)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ExternalUniqueID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_pDataUnit)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnit arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ // validate input parms
+
+ if (i_iExternalUniqueIDLen <= 0 ||
+ i_iExternalUniqueIDLen > KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ExternalUniqueIDLen arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pExternalTag && strlen(i_pExternalTag) > KMS_MAX_EXTERNAL_TAG)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "ExternalTag arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pDescription &&
+ strlen(i_pDescription) > KMS_MAX_DESCRIPTION)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Description arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ // prepare args to soap transaction
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse oResponse;
+
+ char * pExternalUniqueID = NULL;
+ pExternalUniqueID = ConvertBinaryDataFromRequest(pstSoap,
+ i_pExternalUniqueID,
+ i_iExternalUniqueIDLen);
+ if (pExternalUniqueID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+
+ char * pExternalTag = NULL;
+ if (i_pExternalTag)
+ {
+ pExternalTag = ConvertUTF8StringFromRequest(pstSoap,
+ i_pExternalTag,
+ KMS_MAX_EXTERNAL_TAG + 1);
+ if (pExternalTag == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pDescription = NULL;
+ if (i_pDescription)
+ {
+ pDescription = ConvertUTF8StringFromRequest(pstSoap,
+ i_pDescription,
+ KMS_MAX_DESCRIPTION + 1);
+ if (pDescription == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+ int iIndex = pLoadBalancer->Balance();
+
+ if ( iIndex >= 0 )
+ {
+ do
+ {
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ bSuccess = KMS_Agent::
+ soap_call_KMS_Agent__RetrieveDataUnitByExternalUniqueID(
+ pstSoap,
+ sURL,
+ NULL,
+ pExternalUniqueID,
+ i_pExternalTag ? pExternalTag : (char *) "",
+ i_pDescription ? pDescription : (char *) "",
+ oResponse) == SOAP_OK;
+
+ if (!bSuccess)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ if (bSuccess)
+ {
+ ConvertUTF8HexStringToBinary(
+ oResponse.DataUnit.DataUnitID, o_pDataUnit->m_acDataUnitID);
+
+ o_pDataUnit->m_iExternalUniqueIDLength = ConvertUTF8HexStringToBinary(
+ oResponse.DataUnit.ExternalUniqueID,
+ o_pDataUnit->m_acExternalUniqueID);
+
+ if (strlen(oResponse.DataUnit.ExternalTag) > KMS_MAX_EXTERNAL_TAG)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_RESPONSE_INVALID_EXTERNAL_TAG_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strncpy(o_pDataUnit->m_acExternalTag,
+ oResponse.DataUnit.ExternalTag,
+ sizeof(o_pDataUnit->m_acExternalTag));
+ o_pDataUnit->m_acExternalTag[sizeof(o_pDataUnit->m_acExternalTag)-1] = '\0';
+ }
+
+ if (strlen(oResponse.DataUnit.Description) > KMS_MAX_DESCRIPTION)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_RESPONSE_INVALID_DESCRIPTION_LENGTH,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strcpy(o_pDataUnit->m_acDescription,
+ oResponse.DataUnit.Description);
+ }
+
+ o_pDataUnit->m_iDataUnitState =
+ (KMS_AGENT_DATA_UNIT_STATE) oResponse.DataUnit.DataUnitState;
+
+ if (bSuccess)
+ {
+ // RetrieveDataUnitByExternalUniqueID may create a DU so add data unit ID
+ // and the KMA IP address to the DU cache
+ CDataUnitCache* pDataUnitCache = (CDataUnitCache*) i_pProfile->m_pDataUnitCache;
+
+ if (i_pProfile->m_iClusterDiscoveryFrequency != 0) // load balancing enabled
+ {
+ bSuccess = pDataUnitCache->Insert(
+ o_pDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE,
+ NULL, 0,
+ pLoadBalancer->GetApplianceNetworkAddress(iIndex));
+ }
+ }
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_RetrieveDataUnitKeys (
+ KMSClientProfile * const i_pProfile,
+ const KMSAgent_DataUnit * const i_pDataUnit,
+ int i_iPageSize,
+ int i_iPageOffset,
+ int* const o_piKeysRemaining,
+ const unsigned char * const i_pKeyID,
+ KMSAgent_ArrayOfKeys* * const o_ppKeys)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_RetrieveDataUnitKeys);
+#endif
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pDataUnit)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnit arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_piKeysRemaining)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "KeysRemaining arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_ppKeys)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Keys arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (i_pKeyID && i_iPageOffset != 0)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "KeyID and PageOffset are mutually exclusive");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ // validate input parms
+
+ if (i_iPageSize <= 0 || i_iPageSize > KMS_MAX_PAGE_SIZE)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "PageSize arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_iPageOffset < 0)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "PageOffset arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ // prepare args to soap transaction
+
+ struct KMS_Agent::KMS_Agent__DataUnit stDataUnit = {"", "", "", "",
+ (KMS_Agent::KMS_Agent__DataUnitState) 0};
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__RetrieveDataUnitKeysResponse oResponse;
+
+ if (!CopyDataUnitFromRequest(pstSoap,
+ &stDataUnit,
+ i_pDataUnit))
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+
+ char * pKeyID = NULL;
+ if (i_pKeyID)
+ {
+ pKeyID = ConvertBinaryDataFromRequest(pstSoap,
+ i_pKeyID,
+ KMS_KEY_ID_SIZE);
+ if (pKeyID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ UTF8_KEYID acKWKID;
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ bool bClientAESKeyWrapSetupError = false;
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+
+ int iIndex = pLoadBalancer->BalanceByDataUnitID(i_pDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+
+ if (iIndex >= 0)
+ {
+ do
+ {
+ bSuccess = true;
+
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = 0;
+
+ Long64 lKMAID = pLoadBalancer->GetKMAID(iIndex);
+
+ if (bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // if this fails we want to utilize normal failover logic, GetKWKID
+ // logs error
+ bSuccess = pLoadBalancer->GetKWKID(iIndex, lKMAID, pstSoap,
+ acKWKID, &bClientAESKeyWrapSetupError) ? true : false;
+ if (bSuccess)
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveDataUnitKeys2(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ i_iPageSize,
+ i_iPageOffset,
+ pKeyID,
+ acKWKID,
+ *(reinterpret_cast<struct KMS_Agent::KMS_Agent__RetrieveDataUnitKeys2Response *>(&oResponse))) == SOAP_OK;
+ }
+ }
+ else if (bSuccess) // No AES Key Wrap
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveDataUnitKeys(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ i_iPageSize,
+ i_iPageOffset,
+ pKeyID,
+ oResponse) == SOAP_OK;
+ }
+
+ // don'f failover for Client side AES Key Wrap setup problems
+ if (!bSuccess && !bClientAESKeyWrapSetupError)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ if (bSuccess)
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess) && (!bClientAESKeyWrapSetupError));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ // validate response
+
+ if (bSuccess && oResponse.KeysRemaining < 0)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEYS_REMAINING_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+
+ if (bSuccess &&
+ (oResponse.Keys.__size < 0 ||
+ oResponse.Keys.__size > i_iPageSize))
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEYS_SIZE_RESPONSE,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+
+ if ( bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // verify KWK ID matches what was registered
+ }
+
+ if (bSuccess)
+ {
+ *o_ppKeys = CopyDataUnitKeysResponse(i_pProfile, &iIndex, &oResponse.Keys);
+
+ if (*o_ppKeys == NULL)
+ {
+ // CopyDataUnitKeysResponse logs errors
+ bSuccess = false;
+ }
+ *o_piKeysRemaining = (int) oResponse.KeysRemaining;
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile,
+ bClientAESKeyWrapSetupError ?
+ CAgentLoadBalancer::AES_KEY_WRAP_SETUP_ERROR : iIndex));
+}
+
+extern "C"
+KMS_AGENT_STATUS KMSAgent_RetrieveProtectAndProcessKey (
+ KMSClientProfile * const i_pProfile,
+ const KMSAgent_DataUnit * const i_pDataUnit,
+ utf8cstr const i_pKeyGroupID,
+ KMSAgent_Key * const o_pKey)
+{
+ bool bSuccess;
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_RetrieveProtectAndProcessKey);
+#endif
+
+ if (!i_pProfile || !i_pDataUnit || !o_pKey)
+ {
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!i_pDataUnit)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "DataUnit arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!o_pKey)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Key arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_pKeyGroupID &&
+ strlen(i_pKeyGroupID) > KMS_MAX_KEY_GROUP_ID_SIZE)
+ {
+ Log(AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "GroupID arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ struct KMS_Agent::KMS_Agent__DataUnit stDataUnit ={"", "", "", "",
+ (KMS_Agent::KMS_Agent__DataUnitState) 0};
+
+ struct soap *pstSoap = (struct soap *) i_pProfile->m_pvSoap;
+ struct KMS_Agent::KMS_Agent__RetrieveProtectAndProcessKeyResponse oResponse;
+
+ if (i_pDataUnit != NULL)
+ {
+ if (!CopyDataUnitFromRequest(pstSoap,
+ &stDataUnit,
+ i_pDataUnit))
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char * pKeyGroupID = NULL;
+ if (i_pKeyGroupID)
+ {
+ pKeyGroupID = ConvertUTF8StringFromRequest(pstSoap,
+ i_pKeyGroupID,
+ KMS_MAX_KEY_GROUP_ID_SIZE + 1);
+ if (pKeyGroupID == NULL)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ // no memory dont' log
+ RETURN(KMS_AGENT_STATUS_NO_MEMORY);
+ }
+ }
+
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ bool bClientAESKeyWrapSetupError = false;
+ UTF8_KEYID acKWKID;
+
+ CAgentLoadBalancer *pLoadBalancer = (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+ int iIndex = pLoadBalancer->BalanceByDataUnitID(i_pDataUnit->m_acDataUnitID,
+ KMS_DATA_UNIT_ID_SIZE);
+
+ if (iIndex >= 0)
+ {
+ do
+ {
+ bSuccess = true;
+ const char* sURL = pLoadBalancer->GetHTTPSURL(
+ iIndex,
+ i_pProfile->m_iPortForAgentService);
+
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ Long64 lKMAID = pLoadBalancer->GetKMAID(iIndex);
+
+ if (bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // if this fails we want to utilize normal failover logic, GetKWKID
+ // logs error
+ bSuccess = pLoadBalancer->GetKWKID(iIndex, lKMAID, pstSoap,
+ acKWKID, &bClientAESKeyWrapSetupError)
+ ? true : false;
+ if (bSuccess)
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveProtectAndProcessKey2(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ i_pKeyGroupID ? i_pKeyGroupID : (char *) "",
+ acKWKID,
+ *(reinterpret_cast<struct KMS_Agent::KMS_Agent__RetrieveProtectAndProcessKey2Response *>(&oResponse))) == SOAP_OK;
+ }
+ }
+ else if (bSuccess) // No AES Key Wrap
+ {
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RetrieveProtectAndProcessKey(
+ pstSoap,
+ sURL,
+ NULL,
+ stDataUnit,
+ i_pKeyGroupID ? i_pKeyGroupID : (char *) "",
+ oResponse) == SOAP_OK;
+ }
+
+ // don'f failover for Client side AES Key Wrap setup problems
+ if (!bSuccess && !bClientAESKeyWrapSetupError)
+ {
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess) && (!bClientAESKeyWrapSetupError));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ if (bSuccess)
+ {
+ if (KMS_KEY_ID_SIZE != ConvertUTF8HexStringToBinary(
+ oResponse.Key.KeyID, NULL))
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEYID_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ }
+
+ if (bSuccess)
+ {
+ ConvertUTF8HexStringToBinary(
+ oResponse.Key.KeyID, o_pKey->m_acKeyID);
+
+ if ((KMS_AGENT_KEY_STATE) oResponse.Key.KeyState < KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS ||
+ (KMS_AGENT_KEY_STATE) oResponse.Key.KeyState > KMS_KEY_STATE_COMPROMISED)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_STATE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+
+ o_pKey->m_iKeyState = (KMS_AGENT_KEY_STATE) oResponse.Key.KeyState;
+
+ if ((KMS_KEY_TYPE) oResponse.Key.KeyType != KMS_KEY_TYPE_AES_256)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_TYPE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+
+ o_pKey->m_iKeyType = (KMS_KEY_TYPE) oResponse.Key.KeyType;
+
+ if (strlen(oResponse.Key.KeyGroupID) > KMS_MAX_KEY_GROUP_ID_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_GROUP_ID_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ strncpy(o_pKey->m_acKeyGroupID,
+ oResponse.Key.KeyGroupID,
+ sizeof(o_pKey->m_acKeyGroupID));
+ o_pKey->m_acKeyGroupID[sizeof(o_pKey->m_acKeyGroupID)-1] = '\0';
+ }
+
+ if ( bSuccess && pLoadBalancer->AESKeyWrapSupported(iIndex))
+ {
+ // verify KWK ID matches what was registered
+ if (oResponse.Key.Key.__size != KMS_MAX_WRAPPED_KEY_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_WRAPPED_KEY_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ if (pLoadBalancer->AESKeyUnwrap(&iIndex, oResponse.Key.Key.__ptr,
+ o_pKey->m_acKey) == false)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_AESKEYUNWRAP_ERROR,
+ NULL,
+ sKmaAddress,
+ NULL);
+
+ bSuccess = false;
+ }
+ }
+ }
+ else if (bSuccess) // non-AES key wrap
+ {
+ if (oResponse.Key.Key.__size != KMS_MAX_KEY_SIZE)
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_LENGTH_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ bSuccess = false;
+ }
+ else
+ {
+ memcpy(o_pKey->m_acKey,
+ oResponse.Key.Key.__ptr,
+ KMS_MAX_KEY_SIZE);
+ }
+ }
+
+ if (bSuccess)
+ {
+ o_pKey->m_iKeyLength = KMS_MAX_KEY_SIZE;
+
+ if (KMSAgentKeyCallout(o_pKey->m_acKey) != 0)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_KEY_CALLOUT_ERROR,
+ NULL,
+ NULL,
+ NULL);
+ bSuccess = false;
+ }
+ }
+ }
+
+ if (bSuccess)
+ {
+ // add Key ID and the creating KMA IP address to the DU cache
+ CDataUnitCache* pDataUnitCache = (CDataUnitCache*) i_pProfile->m_pDataUnitCache;
+
+ if (i_pProfile->m_iClusterDiscoveryFrequency != 0) // load balancing enabled
+ {
+ bSuccess = pDataUnitCache->Insert(
+ NULL,
+ 0,
+ o_pKey->m_acKeyID,
+ KMS_KEY_ID_SIZE,
+ pLoadBalancer->GetApplianceNetworkAddress(iIndex));
+ }
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile,
+ bClientAESKeyWrapSetupError ?
+ CAgentLoadBalancer::AES_KEY_WRAP_SETUP_ERROR : iIndex));
+}
+
+extern "C"
+void KMSAgent_FreeArrayOfKeys (
+ KMSAgent_ArrayOfKeys* i_pArrayOfKeys)
+{
+#if defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_FreeArrayOfKeys);
+#endif
+ if (!i_pArrayOfKeys)
+ {
+ return;
+ }
+
+ // free memory for all information groups
+ if (i_pArrayOfKeys->m_pKeys)
+ {
+ free(i_pArrayOfKeys->m_pKeys);
+ }
+
+ free(i_pArrayOfKeys);
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSAgent_CreateAuditLog
+ *
+ *--------------------------------------------------------------------------*/
+extern "C"
+KMS_AGENT_STATUS KMSAgent_CreateAuditLog (
+ KMSClientProfile* i_pProfile,
+ enum KMS_AUDIT_LOG_RETENTION i_iRetention,
+ enum KMS_AUDIT_LOG_CONDITION i_iCondition,
+ int i_bIssueAlert,
+ utf8cstr i_pMessage)
+{
+ bool bSuccess = true;
+#ifdef DEBUG_TIMING
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE(trace, KMSAgent_CreateAuditLog);
+#endif
+
+ // START_STACK_CHECK;
+
+ if (!i_pProfile)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATED_AUDIT_LOG_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Profile arg");
+
+ // END_STACK_CHECK;
+
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ // check arguments
+ if (i_iRetention > KMS_AUDIT_LOG_SHORT_TERM_RETENTION)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Retention arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (i_iCondition > KMS_AUDIT_LOG_WARNING_CONDITION)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Condition arg");
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+
+ if (!i_pMessage || (strlen(i_pMessage) <= 0))
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_INVALID_PARAMETERS,
+ NULL,
+ NULL,
+ "Message arg");
+ // END_STACK_CHECK;
+ RETURN(KMS_AGENT_STATUS_INVALID_PARAMETER);
+ }
+ if (!KMSClient_ProfileLoaded(i_pProfile))
+ {
+ // END_STACK_CHECK;
+ RETURN(KMS_AGENT_STATUS_PROFILE_NOT_LOADED);
+ }
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ struct soap* pstSoap = (struct soap*) i_pProfile->m_pvSoap;
+
+ // Create Audit Log
+
+ KMS_Agent::KMS_Agent__CreateAuditLogResponse oResponse;
+
+ CAgentLoadBalancer *pLoadBalancer =
+ (CAgentLoadBalancer *) i_pProfile->m_pAgentLoadBalancer;
+
+ int iIndex = pLoadBalancer->Balance();
+ if (iIndex >= 0)
+ {
+ do
+ {
+ const char* sURL = pLoadBalancer->
+ GetHTTPSURL(iIndex, i_pProfile->m_iPortForAgentService);
+ strncpy(i_pProfile->m_sURL, sURL, sizeof(i_pProfile->m_sURL));
+ i_pProfile->m_sURL[sizeof(i_pProfile->m_sURL)-1] = '\0';
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__CreateAuditLog(
+ pstSoap,
+ sURL,
+ NULL,
+ (enum KMS_Agent::KMS_Agent__AuditLogRetention)i_iRetention,
+ (enum KMS_Agent::KMS_Agent__AuditLogCondition)i_iCondition,
+ i_bIssueAlert ? true : false,
+ i_pMessage,
+ oResponse) == SOAP_OK;
+
+
+ if (!bSuccess)
+ {
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+
+ GetSoapFault(sSoapFaultMsg, pstSoap);
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+
+ iIndex = pLoadBalancer->FailOver(iIndex, pstSoap);
+
+ LogError(i_pProfile, AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ }
+ else
+ {
+ pLoadBalancer->UpdateResponseStatus(iIndex);
+ }
+ }
+ while (iIndex >= 0 && (!bSuccess));
+ }
+ else
+ {
+ bSuccess = false;
+ }
+
+ // free allocated memory for output if error condition
+ // Clean up SOAP
+
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+
+ if (bSuccess)
+ {
+ // END_STACK_CHECK;
+ RETURN(KMS_AGENT_STATUS_OK);
+ }
+
+ // END_STACK_CHECK;
+ RETURN(KMSAgent_GetLastStatusCode(i_pProfile, iIndex));
+}
+
+#ifdef KMSUSERPKCS12
+/*
+ * This function allows the user to change the PIN on the PKCS12
+ * file that holds the clients private key and cert.
+ */
+extern "C"
+KMS_AGENT_STATUS KMSAgent_ChangeLocalPWD(
+ KMSClientProfile* i_pProfile,
+ utf8cstr const i_pOldPassphrase,
+ utf8cstr const i_pNewPassphrase)
+{
+ CCertificate *pCert;
+ CPrivateKey *pKey;
+ bool bSuccess;
+
+ pCert = new CCertificate;
+ pKey = new CPrivateKey;
+
+ bSuccess = GetPKCS12CertAndKey(i_pProfile, i_pOldPassphrase,
+ pCert, pKey);
+ if (!bSuccess)
+ return(KMSAgent_GetLastStatusCode(i_pProfile, 0));
+
+ bSuccess = StoreAgentPKI(i_pProfile, pCert, pKey, i_pNewPassphrase);
+ if (!bSuccess)
+ return(KMSAgent_GetLastStatusCode(i_pProfile, 0));
+
+ return (KMS_AGENT_STATUS_OK);
+}
+#endif /* KMSUSERPKCS12 */
diff --git a/usr/src/lib/libkmsagent/common/KMSAgent.h b/usr/src/lib/libkmsagent/common/KMSAgent.h
new file mode 100644
index 0000000000..b06da4b6a8
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgent.h
@@ -0,0 +1,1163 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/** @file KMSAgent.h
+ * @defgroup EncryptionAgent Encryption Agent API
+ *
+ * The Agent API is used to communicate with the KMS Appliance for the
+ * purpose of registering storage devices, obtaining device keys, and
+ * receiving notifications of storage device events such as destruction.
+ *
+ */
+#ifndef KMS_AGENT_H
+#define KMS_AGENT_H
+
+#include "KMSClientProfile.h"
+
+/*---------------------------------------------------------------------------
+ * The following ifdef block is the standard way of creating macros which
+ * make exporting from a DLL simpler. All files within this DLL are compiled
+ * with the KMS_AGENT_EXPORT symbol defined on the command line. this symbol
+ * should not be defined on any project that uses this DLL. This way any
+ * other project whose source files include this file see KMS Agent API functions
+ * as being imported from a DLL, wheras this DLL sees symbols defined with
+ * this macro as being exported.
+ *--------------------------------------------------------------------------*/
+#ifdef KMS_AGENT_EXPORT
+#define KMS_AGENT_API __declspec(dllexport)
+#else
+#define KMS_AGENT_API __declspec(dllimport)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------------------
+ * Return Codes
+ *--------------------------------------------------------------------------*/
+
+/**
+ * The status type returned on API calls
+ */
+typedef int KMS_AGENT_STATUS;
+
+/**
+ * successful status
+ */
+#define KMS_AGENT_STATUS_OK 0
+
+/* error status values */
+/**
+ * generic error is a catch all for a wide variety of errors, see the specific
+ * entry in the audit log for the details. In general, the client API will return
+ * one of the specific status codes.
+ */
+#define KMS_AGENT_STATUS_GENERIC_ERROR 100
+
+/**
+ * insufficient memory for the agent library to complete the request
+ */
+#define KMS_AGENT_STATUS_NO_MEMORY 102
+
+/**
+ * parameter error, invalid input
+ */
+#define KMS_AGENT_STATUS_INVALID_PARAMETER 103
+
+/**
+ * an API call was made before the profile was loaded
+ */
+#define KMS_AGENT_STATUS_PROFILE_NOT_LOADED 104
+
+/**
+ * upon receipt of a key the callout function returned an error
+ */
+#define KMS_AGENT_STATUS_KEY_CALLOUT_FAILURE 105
+
+/**
+ * the specified profile failover attempts have been exceeded or no KMAs are available within the cluster
+ */
+#define KMS_AGENT_STATUS_KMS_UNAVAILABLE 106
+
+/**
+ * the KMS does not have any keys in the READY state, this is a KMS issue that requires attention
+ * from a KMS administrator.
+ */
+#define KMS_AGENT_STATUS_KMS_NO_READY_KEYS 107
+
+/**
+ * the FIPS 140-2 known answer test (KAK) failed for AES Key wrap.
+ */
+#define KMS_AGENT_STATUS_FIPS_KAT_AES_KEYWRAP_ERROR 108
+
+/**
+ * #FIPS_MODE was specified on #KMSAgent_LoadProfile
+ * but no FIPS compatible KMAs are currently
+ * available. Also, it may be that no FIPS compatible KMAs have been
+ * configured within the KMS.
+ */
+#define KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE 109
+
+/**
+ * the profile was already successfully loaded and should be unloaded
+ * before attempting to load it again
+ */
+#define KMS_AGENT_STATUS_PROFILE_ALREADY_LOADED 110
+
+/**
+ * the FIPS 140-2 known answer test (KAK) failed for AES ECB.
+ */
+#define KMS_AGENT_STATUS_FIPS_KAT_AES_ECB_ERROR 111
+
+/**
+ * the FIPS 140-2 known answer test (KAK) failed for HMAC-SHA1.
+ */
+#define KMS_AGENT_STATUS_FIPS_KAT_HMAC_SHA1_ERROR 112
+
+/*
+ * SOAP Sender Errors - client errors associated with a KMS SOAP service
+ */
+
+/**
+ * the following conditions can result in access denied being returned by the KMSAgent Soap service:
+ * <ul>
+ * <li>Agent is not enabled on the KMS
+ * <li>Invalid DataUnitID or DataUnit does not exist
+ * <li>Invalid ExternalUniqueID or DataUnit does not exist with specified ID
+ * <li>Invalid ExternalTag
+ * <li>Invalid KeyID
+ * <li>Invalid KeyGroup or KeyGroup does not exist
+ * <li>The Agent ID is not recognized as an agent by the KMS, i.e. the agent may not exist or the
+ * ID represents another kind of entity.
+ * <li>No KeyGroup specified and the Agent is not configured to have a default KeyGroup
+ * <li>Agent does not have access to the specified KeyGroup
+ * </ul>
+ * to prevent leakage of information the specific details for access being denied are not
+ * disclosed. Audit log entries at the KMS can be used to determine specific reasons for
+ * access being denied.
+ */
+#define KMS_AGENT_STATUS_ACCESS_DENIED 200
+
+/**
+ * This error status is only returned when received from the KMS and the transaction
+ * timeout has been exceeded.
+ */
+#define KMS_AGENT_STATUS_SERVER_BUSY 201
+
+/**
+ * a data unit already exists with the specified external unique identifier
+ */
+#define KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS 202
+
+/**
+ * The external unique ID specified was found to exist but the corresponding
+ * DataUnitID did not exist.
+ */
+#define KMS_AGENT_STATUS_DATA_UNIT_ID_NOT_FOUND_EXTERNAL_ID_EXISTS 203
+
+
+/**
+ * The specified key has been destroyed or is unknown to the KMS
+ */
+#define KMS_AGENT_STATUS_KEY_DOES_NOT_EXIST 204
+
+/**
+ * The requested key has been destroyed.
+ */
+#define KMS_AGENT_STATUS_KEY_DESTROYED 205
+
+/**
+ * The key received from a KMA encountered an error during AES Key Unwrapping
+ */
+#define KMS_AGENT_AES_KEY_UNWRAP_ERROR 206
+
+/**
+ * An error occurred during establishment of an AES Key-Encryption Key
+ */
+#define KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR 207
+
+/*
+ * Failed to decrypt the client private key data file due to incorrect PIN
+ */
+#define KMS_AGENT_LOCAL_AUTH_FAILURE 208
+
+/**
+ * supported key types
+ */
+enum KMS_KEY_TYPE
+{
+ /**
+ * AES 256 key type
+ */
+ KMS_KEY_TYPE_AES_256
+};
+
+/**
+ * This enumerator type defines the various Key States.
+ */
+enum KMS_AGENT_KEY_STATE
+{
+ KMS_KEY_STATE_GENERATED = 0,
+ KMS_KEY_STATE_READY,
+
+ /**
+ * A key in this state can be used for both encryption and decryption.
+ * A key is placed into this state when it is assigned. The assignment is done when an encryption agent requests a new key be created.
+ */
+ KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS,
+
+ /**
+ * A key in this state can be used for decryption but not encryption. When an agent determines that none of the keys available to
+ * it (e.g., for a specific data unit that is being read or written) are in the protect-and-process state, it should create a new key.
+ * Keys transition from protect-and-process to process only when the encryption period for the key expires.
+ */
+ KMS_KEY_STATE_ACTIVE_PROCESS_ONLY,
+
+ /**
+ * The key has passed its cryptoperiod but may still be needed to process (decrypt) information. Auditable events are generated
+ * when keys in this state are provided to the agent.
+ */
+ KMS_KEY_STATE_DEACTIVATED,
+
+ /**
+ * Keys are compromised when they are released to or discovered by an unauthorized entity.
+ * Compromised keys should not be used to protect information, but may be used to process information.
+ * Auditable events are generated
+ * when keys in this state are provided to the agent.
+ */
+ KMS_KEY_STATE_COMPROMISED,
+
+ KMS_KEY_STATE_DESTROYED_INCOMPLETE,
+ KMS_KEY_STATE_DESTROYED_COMPLETE,
+ KMS_KEY_STATE_DESTROYED_COMPROMISED_INCOMPLETE,
+ KMS_KEY_STATE_DESTROYED_COMPROMISED_COMPLETE
+
+};
+
+/*---------------------------------------------------------------------------
+ * Data Unit State
+ *--------------------------------------------------------------------------*/
+
+/**
+ * this enumeration defines the DataUnit states
+ */
+enum KMS_AGENT_DATA_UNIT_STATE
+{
+ /**
+ * When a data unit has been created, but has not yet had any keys created it will be in "no key" state.
+ * This should be a short, transient condition that will be exited as soon as a key has been created.
+ */
+ KMS_DATA_UNIT_STATE_NO_KEY = 0,
+
+ /**
+ * Normal is a substate of readable. In this state, a data unit has at least one protect-and-process state key that can be used to encrypt data.
+ * The data unit is therefore writable.
+ */
+ KMS_DATA_UNIT_STATE_READABLE_NORMAL,
+
+ /**
+ * Needs rekey is a substate of readable. In this state, the data unit has no protect-and-process keys.
+ * Data should not be encrypted and written to the data unit unless the data unit is rekeyed and a new, active key is assigned.
+ * Its the responsibility of the agent to avoid using a key that is not in protect-and-process state for encryption.
+ * The data unit may have keys that are in process only, deactivated, or compromised state. Any of these keys can be used for decryption.
+ */
+ KMS_DATA_UNIT_STATE_READABLE_NEEDS_REKEY,
+
+ /**
+ * When all of the keys for a data unit are destroyed, the data unit is shredded. The data unit cannot be read or written.
+ * However, a new key can be created for the data unit. This will return the data unit to normal state, allowing it to be read and written.
+ */
+ KMS_DATA_UNIT_STATE_SHREDDED
+};
+
+/**
+ * This enumeration type defines Audit Log Retention values
+ */
+enum KMS_AUDIT_LOG_RETENTION
+{
+ /**
+ * specifies that an audit log entry should have long term retention
+ */
+ KMS_AUDIT_LOG_LONG_TERM_RETENTION = 0,
+ /**
+ * specifies that an audit log entry should have medium term retention
+ */
+ KMS_AUDIT_LOG_MEDIUM_TERM_RETENTION,
+ /**
+ * specifies that an audit log entry should have short term retention
+ */
+ KMS_AUDIT_LOG_SHORT_TERM_RETENTION
+};
+
+/**
+ * This enumeration type defines Audit Log Condition values
+ */
+enum KMS_AUDIT_LOG_CONDITION
+{
+ /**
+ * specifies that an audit log entry should should indicate a success condition
+ */
+ KMS_AUDIT_LOG_SUCCESS_CONDITION = 0,
+
+ /**
+ * specifies that an audit log entry should should indicate an error condition
+ */
+ KMS_AUDIT_LOG_ERROR_CONDITION,
+
+ /**
+ * specifies that an audit log entry should should indicate a warning condition
+ */
+ KMS_AUDIT_LOG_WARNING_CONDITION
+};
+
+/**
+ * supported security modes
+ */
+enum KMS_SECURITY_MODE
+{
+ /**
+ * agent will work with any level of KMA
+ */
+ DEFAULT_MODE = 0,
+
+ /**
+ * agent will only communicate with KMAs supporting FIPS 140-2 so that
+ * keys are encrypted at the KMA using AES Key Wrap.
+ */
+ FIPS_MODE
+};
+
+/*---------------------------------------------------------------------------
+ * API Input/Output Data Structures
+ *--------------------------------------------------------------------------*/
+/**
+ * typedef for descriptions used in various places within the API
+ */
+typedef utf8char DESCRIPTION [KMS_MAX_DESCRIPTION+1];
+
+/**
+ * typedef for key group ID
+ */
+typedef utf8char KEY_GROUP_ID[KMS_MAX_ID+1];
+
+/**
+ * typedef for the Key Group struct
+ */
+typedef struct KMSAgent_KeyGroup KMSAgent_KeyGroup;
+
+/** \struct KMSAgent_KeyGroup
+ * a Key Group with its ID and description
+ */
+struct KMSAgent_KeyGroup
+{
+ /**
+ * the unique ID of the KeyGroup
+ */
+ KEY_GROUP_ID m_acKeyGroupID;
+
+ /**
+ * the description of the KeyGroup
+ */
+ DESCRIPTION m_acDescription;
+};
+
+/**
+ * An array of Key Groups
+ */
+typedef struct KMSAgent_ArrayOfKeyGroups KMSAgent_ArrayOfKeyGroups;
+
+/** \struct KMSAgent_ArrayOfKeyGroups
+ * An array of Key Groups
+ */
+struct KMSAgent_ArrayOfKeyGroups
+{
+ /**
+ * pointer to an array of Key Groups
+ */
+ KMSAgent_KeyGroup* m_pKeyGroups;
+
+ /**
+ * the number of Key Groups in the array
+ */
+ int m_iSize;
+};
+
+
+/**
+ * typedef for a Key struct
+ */
+typedef struct KMSAgent_Key KMSAgent_Key;
+
+/** \struct KMSAgent_Key
+ * key and its associated properites: KeyID, state, type, lenth, KeyGroup and the Key value
+ */
+struct KMSAgent_Key
+{
+ /**
+ * the unique ID of the key
+ */
+ KEY_ID m_acKeyID;
+
+ /**
+ * the state of the Key
+ */
+ enum KMS_AGENT_KEY_STATE m_iKeyState;
+
+ /**
+ * the type of the key, e.g. AES_256
+ */
+ enum KMS_KEY_TYPE m_iKeyType;
+
+ /**
+ * the unique ID of the KeyGroup
+ */
+ KEY_GROUP_ID m_acKeyGroupID;
+
+ /**
+ * the key in plaintext.
+ */
+ KEY m_acKey;
+
+ /**
+ * length of #m_acKey
+ */
+ int m_iKeyLength;
+};
+
+/**
+ * typedef for the External Unique ID
+ */
+typedef unsigned char EXTERNAL_UNIQUE_ID [KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE];
+
+/**
+ * typedef for the Data Unit ID
+ */
+typedef unsigned char DATA_UNIT_ID [KMS_DATA_UNIT_ID_SIZE];
+
+/**
+ * typedef for the External Tag
+ */
+typedef utf8char EXTERNAL_TAG [KMS_MAX_EXTERNAL_TAG+1];
+
+/**
+ * typedef for aData Unit structure.
+ */
+typedef struct KMSAgent_DataUnit KMSAgent_DataUnit;
+
+/** \struct KMSAgent_DataUnit
+ * struct for a DataUnit and its associated properties: DataUnitID, external unique ID,
+ * external tag, description and state. Data units are associated with zero or more keys.
+ */
+struct KMSAgent_DataUnit
+{
+ /**
+ * the unique DataUnit ID provided by the KMS
+ */
+ DATA_UNIT_ID m_acDataUnitID;
+
+ /**
+ * a unique external ID for the data unit that is provided by the agent, may be NULL if one is not provided.
+ * The KMS will enforce the uniqueness of this identifier and not allow multiple data units having the same
+ * #m_acExternalUniqueID value.
+ */
+ EXTERNAL_UNIQUE_ID m_acExternalUniqueID;
+ /**
+ * the length in bytes of the #m_acExternalUniqueID field that represents the
+ * ID. The length
+ * must be less than or equal to #KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE
+ */
+ int m_iExternalUniqueIDLength;
+
+ /**
+ * an external tag representing information pertinent to the data unit, for example a volume serial number
+ */
+ EXTERNAL_TAG m_acExternalTag;
+
+ /**
+ * a description of the data unit
+ */
+ DESCRIPTION m_acDescription;
+
+ /**
+ * the state of the DataUnit
+ */
+ enum KMS_AGENT_DATA_UNIT_STATE m_iDataUnitState;
+
+};
+
+/**
+ * typedef for a list of keys
+ */
+typedef struct KMSAgent_ArrayOfKeys KMSAgent_ArrayOfKeys;
+
+/** \struct KMSAgent_ArrayOfKeys
+ * struct for an array of keys
+ */
+struct KMSAgent_ArrayOfKeys
+{
+ /**
+ * keys are in chronological order based upon key creation date. However,
+ * when page offset argument to #KMSAgent_RetrieveDataUnitKeys
+ * is 0 the first key in the array will be the key in the
+ * #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS.
+ */
+ KMSAgent_Key* m_pKeys;
+
+ /**
+ * the number of keys in the list
+ */
+ int m_iSize;
+};
+
+/**
+ * @return the version string for the KMS Agent Library
+ */
+const char * KMSAgent_GetVersion();
+
+/**
+ *
+ * This function initializes the KMS Agent API library. It
+ * should be called before any other functions are invoked. Internally,
+ * sets up the SSL library and Logging module.
+ *
+ * @param i_pWorkingDirectory Working directory of the program which uses the
+ * library. Default is "." if NULL is passed.
+ * @param i_bUseFileLog: True(1) if errors should go to a log file in the working directory.
+ * If false(0) then errors will not be logged to a file.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR if library initialization fails
+ */
+KMS_AGENT_STATUS KMSAgent_InitializeLibrary(
+ const utf8cstr i_pWorkingDirectory,
+ int i_bUseFileLog );
+
+/**
+ * This function exercises FIPS 140-2 Known Answer Tests for certified algorithms
+ * used in the agent toolkit. This function should only be called once and may
+ * be called prior to #KMSAgent_InitializeLibrary.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_FIPS_KAT_AES_KEYWRAP_ERROR
+ * @return #KMS_AGENT_STATUS_FIPS_KAT_AES_ECB_ERROR
+ * @return #KMS_AGENT_STATUS_FIPS_KAT_HMAC_SHA1_ERROR
+ */
+KMS_AGENT_STATUS KMSAgent_KnownAnswerTests();
+
+/**
+ * This function finalizes the KMS Agent API library. It should
+ * be called when the library is not needed by the program. Internally it
+ * cleans up the SSL library and Logging module.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR if library finalization fails
+ *
+ */
+KMS_AGENT_STATUS KMSAgent_FinalizeLibrary();
+
+/**
+ * This function can be used to get the last error message when
+ * an API function encounters an error. These error messages also
+ * are written to the log, if file logging was enabled during library
+ * initialization.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile; the failed
+ * function must have used this profile.
+ * @return the pointer to the last error message or NULL
+ *
+ */
+utf8cstr KMSAgent_GetLastErrorMessage(
+ KMSClientProfile* i_pProfile );
+
+
+ /**
+ * Get the cluster information by calling the KMS_Discovery service using the KMA specified in the
+ * profile, no load balancing will occur. If discovery to this KMA fails then discovery will be
+ * attempted using previously retrieved cluster information.
+ *
+ * If #KMSAgent_LoadProfile was called with an IPv6 address for
+ * the <code>i_pInitialApplianceAddress</code> argument then the <code>o_pClusterEntryArray</code> will contain
+ * IPv6 addresses instead of IPv4 addresses for each KMA that has an IPv6 address.
+ * @see #KMSAgent_LoadProfile and #KMSAgent_SelectAppliance.
+ *
+ * If the size of the cluster returned by the KMS_Discovery servic exceeds <code>i_iClusterEntryArraySize</code>
+ * then the KMA list is filtered to contain the
+ * first <code>i_iClusterEntryArraySize</code> KMAs that meet the profile's FIPS setting, agent site and are reported as responding by the
+ * KMS discover cluster response.
+ *
+ * @param i_pProfile a pointer to an initialized #KMSClientProfile structure
+ * @param i_iEntitySiteIDSize the buffer size of the entity site ID including null terminator
+ * (should be greater than #KMS_MAX_ENTITY_SITE_ID )
+ * @param i_iClusterEntryArraySize the array size for cluster entries (must be less than or equal to #KMS_MAX_CLUSTER_NUM )
+ * @param o_pEntitySiteID a buffer allocated by the caller to store the agent's (aka entity) Site ID
+ * @param o_pApplianceNum the returned number of appliances in the cluster
+ * @param o_pClusterEntryArray a buffer allocated by the caller to store the array of cluster entries
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+ KMS_AGENT_STATUS KMSAgent_GetClusterInformation(
+ KMSClientProfile * const i_pProfile,
+ int i_iEntitySiteIDSize,
+ int i_iClusterEntryArraySize,
+ utf8cstr const o_pEntitySiteID,
+ int * const o_pApplianceNum,
+ KMSClusterEntry * const o_pClusterEntryArray);
+
+/**
+ * Specifies the Key Management Appliance to be used
+ * for retrieving cluster information.
+ *
+ * @param i_pProfile a pointer to an initialized #KMSClientProfile
+ * structure
+ * @param i_pApplianceAddress the IP address of the appliance. IPv6 addresses
+ * must be enclosed in brackets, [], see #KMSAgent_LoadProfile.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ *
+ */
+KMS_AGENT_STATUS KMSAgent_SelectAppliance(
+ KMSClientProfile* const i_pProfile,
+ utf8cstr const i_pApplianceAddress );
+
+/**
+ * Load profile handles both agent enrollment with the KMS and post enrollment setup.
+ * <p>
+ * <b>Enrollment Behavior</b>
+ * <br>
+ * When a passphrase is supplied enrollment, or reenrollment, with a KMS cluster is attempted in order
+ * to establish a mutual trust relationship. Enrollment occurs with the KMA in the cluster specified
+ * by <code>i_pApplianceAddress</code>.
+ * <p>
+ * The KMS CA web service is used for CA certificate retrieval prior to
+ * invoking the KMS Certificate web service. Certficate retrieval via these services
+ * uses the <code>i_pApplianceAddress</code> for enrollment. Cluster discovery is then performed to
+ * identify the set of KMAs within the cluster.
+ * Successful enrollment results in
+ * persistent storage of the CA X.509 certificate, agent X.509 certificate and private key.
+ * </p>
+ * Once enrolled successfully the KMS
+ * will then disable usage of the agent's passphrase for enrollment as a security precaution.
+ * Subsequent enrollment will require a new passphrase.
+ * <p>
+ * <b>Post Enrollment Behavior</b>
+ * <br>
+ * When a passphrase is not provided a profile is assumed to exist and the library profile structure
+ * is initialized from persistent storage with the configuration settings(agent ID,
+ * KMA service port numbers, KMA Address, transaction timeout, discovery frequency, transaction timeout
+ * and failover limit), cluster information(agent's site ID and KMA cluster information and KMA status) and
+ * enrollment items: the CA certificate, Agent Certificate and agent private key.
+ * <p>
+ * Finally, cluster discovery is performed(unless disabled), and a load balancer is initialized
+ * for balancing transactions across KMAs within the
+ * cluster and for handling transaction failover scenarios.
+ * Subsequent API calls using the profile will invoke cluster discovery at the frequency specified
+ * by <code>iClusterDiscoveryFrequency</code>. Updated discovery information is persisted with the
+ * profile. The load balancer maintains affinity to KMAs within the same site as the agent for
+ * agent transactions unless an error requires failover
+ * to another KMA in the cluster. An agent's site ID may also be updated by a discovery
+ * operation.
+ *
+ * @param io_pProfile a pointer to a #KMSClientProfile buffer allocated by the caller
+ * @param i_pProfileName the profile name
+ * @param i_pAgentID Optional. For a new profile the encryption agent's ID is required.
+ * @param i_pPassphrase Optional. For a new profile the encryption agent's passphrase is required. This passphrase
+ * may only be used once for a successful retrieval of the Certificate and agent private key.
+ * @param i_pInitialApplianceAddress the initial IP Address of an Appliance in the KMS Cluster that is reachable by this agent. If
+ * enrollment has previously occurred specification of an initial IP address that is not
+ * a member of the profile's cluster information will force the cluster information
+ * to be deleted and discovery to be performed with the new IP address.
+ * An IPv6 address may be supplied but must be enclosed with brackets, [], in accordance
+ * with RFC 2396, "Format for Literal IPv6 Addresses in URL's". Supplying an IPv6 address will cause
+ * the agent library to utilize KMA IPv6 addresses over IPv4 addresses when they are available,
+ * otherwise IPv4 KMA addresses will be used.
+ * @param i_iTransactionTimeout the timeout setting for a transaction in seconds, must be a positive value.
+ * @param i_iFailOverLimit Failed KMA transactions will be retried up to this limit. Once this limit
+ * has been reached API calls will return #KMS_AGENT_STATUS_KMS_UNAVAILABLE.
+ * Specify -1 for unlimited failover attempts, 0 for no failover. The worst case completion time for
+ * an API call is approximately equal to <code>i_iFailOverLimit</code> * <code>i_iTransactionTimeout</code>.
+ *
+ * @param i_iClusterDiscoveryFrequency
+ * frequency of calling cluster discovery service
+ * in seconds (use 0 to disable load balancing and periodic cluster discovery)
+ * @param i_eKMSmode specifies the KMS operational mode that the
+ * agent should enforce. Setting this to #FIPS_MODE
+ * causes the agent to only communicate with KMAs in the
+ * cluster that support AES key wrapping for key requests.
+ * This is not a persisted setting and is only applicable
+ * to the current session.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_PROFILE_ALREADY_LOADED
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+KMS_AGENT_STATUS KMSAgent_LoadProfile(
+ KMSClientProfile* const io_pProfile,
+ utf8cstr const i_pProfileName,
+ utf8cstr const i_pAgentID,
+ utf8cstr const i_pPassphrase,
+ utf8cstr const i_pInitialApplianceAddress,
+ int i_iTransactionTimeout,
+ int i_iFailOverLimit,
+ int i_iClusterDiscoveryFrequency,
+ int i_eKMSmode );
+
+
+/**
+ * Destroy the profile information in memory, the agent's profile configuration,
+ * cluster information, certificate and
+ * private key are retained in persistant storage.
+ *
+ * @param i_pProfile a pointer to an initialized KMSClientProfile
+ * structure.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ *
+ */
+KMS_AGENT_STATUS KMSAgent_UnloadProfile(
+ KMSClientProfile* const i_pProfile );
+
+/**
+ * Delete the profile information from persistent storage. The agent's profile configuration,
+ * cluster information, certificate and
+ * private key are discared, see #KMSAgent_LoadProfile for how to initialize
+ * the profile again. The profile should be unloaded prior to making this call.
+ *
+ * @param i_pProfileName the profile name
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ */
+KMS_AGENT_STATUS KMSAgent_DeleteProfile(
+ utf8cstr i_pProfileName );
+
+/**
+ * Fetch the key groups this agent is allowed to access. The caller should invoke #KMSAgent_FreeArrayOfKeyGroups
+ * to release the allocated memory resources for the array. Up to #KMS_MAX_LIST_KEY_GROUPS key groups will be
+ * returned.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param o_ppKeyGroups a buffer allocated by this routine for the array of Key Groups and individual key groups
+ * that this agent is allowed to access
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+KMS_AGENT_STATUS KMSAgent_ListKeyGroups(
+ KMSClientProfile* const i_pProfile,
+ KMSAgent_ArrayOfKeyGroups** const o_ppKeyGroups );
+
+/**
+ * Helper function which frees memory allocated for the output
+ * to #KMSAgent_ListKeyGroups.
+ *
+ * @param i_pArrayOfKeyGroups a pointer to #KMSAgent_ArrayOfKeyGroups
+ *
+ * @return void
+ *
+ */
+void KMSAgent_FreeArrayOfKeyGroups(
+ KMSAgent_ArrayOfKeyGroups* i_pArrayOfKeyGroups );
+
+/**
+ * Creates a Key for the specified data unit. If a data unit is provided then the key will be associated with
+ * the data unit. The type of key created is dictated by the KMS key policy for the key group. This policy is set up by KMS
+ * administrators to be compatible with agents associated with the key group.
+ * If KeyGroup is provided then the new key is associated with the specified KeyGroup, otherwise the agent's
+ * default KeyGroup is associated with the key.
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pDataUnit Optional. a pointer to a data unit to be associated with the key, if known.
+ * @param i_pKeyGroupID Optional, the KeyGroup ID to be assigned to the new Key, if known. Pass NULL
+ * if unknown and the new key will be associated with the agent's default key group
+ * @param o_pKey A pointer to a buffer for returning the new key and key associated data.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_KEY_CALLOUT_FAILURE
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_KMS_NO_READY_KEYS
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ * @return #KMS_AGENT_AES_KEY_UNWRAP_ERROR
+ * @return #KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR
+ */
+KMS_AGENT_STATUS KMSAgent_CreateKey(
+ KMSClientProfile* const i_pProfile,
+ const KMSAgent_DataUnit* const i_pDataUnit,
+ KEY_GROUP_ID const i_pKeyGroupID,
+ KMSAgent_Key* const o_pKey);
+
+/**
+ * Creates a DataUnit with the specified external unique id and external tag.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pExternalUniqueID Optional. A unique data unit identifier to be associated with
+ * the data unit. Uniqueness is enforced by the KMS. See also #KMSAgent_RetrieveDataUnit.
+ * @param i_iExternalUniqueIDIDLen Length in bytes of the external unique identifier. If
+ * <code>i_pExternalUniqueID</code> is NULL then this field is ignored, otherwise a positive length must be provided.
+ * @param i_pExternalTag Optional, but recommended. Pointer to an External Tag for the data unit, e.g. a volume serial number.
+ * @param i_pDescription Optional, a textual description of the data unit.
+ * @param o_pDataUnit a pointer to a DataUnit buffer where
+ * data unit information is returned
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+*/
+KMS_AGENT_STATUS KMSAgent_CreateDataUnit(
+ KMSClientProfile* const i_pProfile,
+ const unsigned char * i_pExternalUniqueID,
+ int i_iExternalUniqueIDIDLen,
+ utf8cstr const i_pExternalTag,
+ utf8cstr const i_pDescription,
+ KMSAgent_DataUnit* const o_pDataUnit);
+
+/**
+ * The agent may use this function to inform the KMS that the DataUnit has, or will be, overwritten.
+ * The KMS will remove the association from the specified DataUnit to all its keys, excluding its key
+ * in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS state. By utilizing this API, agent's can help keep the
+ * number of keys returned by #KMSAgent_RetrieveDataUnitKeys to just the keys being used on the Data Unit.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pDataUnit A pointer to the data unit
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+KMS_AGENT_STATUS KMSAgent_DisassociateDataUnitKeys(
+ KMSClientProfile* const i_pProfile,
+ const KMSAgent_DataUnit* const i_pDataUnit);
+
+
+/**
+ * retrieve a key by the Key's ID, optionally specifying the Data Unit and KeyGroup to be
+ * associated with the key. Supplying the Data Unit information allows the KMS to add an
+ * association between the Key and the Data Unit. The assumption being made is that the key being
+ * retrieved has been used on the specified Data Unit and needs to be associated with it. This
+ * side affect allows the KMS to build up its knowledge of key usage as it relies upon agents
+ * for discovering and reporting how keys are being used on Data Units. For example, when keys
+ * are imported into a KMS the information associating keys with DataUnits may not be provided,
+ * consequently the KMS is unaware of what DataUnits were encrypted with a particular key.
+ *
+ * @param i_pProfile an initialized KMSClientProfile
+ * @param i_pKeyID The ID of the Key being requested
+ * @param i_pDataUnit Optional. If non-NULL, the KMS will verify that an association exists between the key and the Data Unit and create
+ * the association if it is missing.
+ * @param i_pKeyGroupID Optional. If non-NULL, and the key is not already associated with a KeyGroup, then the KMS will associate the key with the specified KeyGroup.
+ * @param o_pKey A pointer to a buffer allcoated by the caller for returning the new key and key associated data.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_KEY_CALLOUT_FAILURE
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KEY_DOES_NOT_EXIST
+ * @return #KMS_AGENT_STATUS_KEY_DESTROYED
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ * @return #KMS_AGENT_AES_KEY_UNWRAP_ERROR
+ * @return #KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR
+ */
+KMS_AGENT_STATUS KMSAgent_RetrieveKey(
+ KMSClientProfile* const i_pProfile,
+ const unsigned char * const i_pKeyID,
+ const KMSAgent_DataUnit* const i_pDataUnit,
+ utf8cstr const i_pKeyGroupID,
+ KMSAgent_Key* const o_pKey);
+
+/**
+ * Retrieve a Data Unit by its data unit identifier.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pDataUnitID the data unit ID by which retrieval will be performed
+ * @param i_pExternalUniqueID Optional, a unique data unit identifier to be associated with
+ * the data unit. Uniqueness is enforced by the KMS.
+ * @param i_iExternalUniqueIDLen Length in bytes of the external unique identifier, must be positive. If
+ * <code>i_pExternalUniqueID</code> is NULL then this field is ignored.
+ * @param i_pExternalTag Optional, but recommended. Pointer to a data unit external tag, e.g. volser
+ * @param i_pDescription Optional, a textual description of the data unit.
+ * @param o_pDataUnit a pointer to a DataUnit buffer allocated by the caller where
+ * data unit information is returned
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+KMS_AGENT_STATUS KMSAgent_RetrieveDataUnit(
+ KMSClientProfile* const i_pProfile,
+ const unsigned char * const i_pDataUnitID,
+ const unsigned char * const i_pExternalUniqueID,
+ int i_iExternalUniqueIDLen,
+ utf8cstr const i_pExternalTag,
+ utf8cstr const i_pDescription,
+ KMSAgent_DataUnit* const o_pDataUnit);
+
+/**
+ * Retrieve a Data Unit by its external unique identifier.
+ * If the KMS does not contain a data unit with the specified unique identifier then a data unit will
+ * be created. The new data unit will contain the external unique identifier and the external tag, if
+ * provided.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pExternalUniqueID A unique data unit identifier to be associated with
+ * the data unit. Uniqueness is enforced by the KMS.
+ * @param i_iExternalUniqueIDLen Length in bytes of the external unique identifier, must be positive.
+ * @param i_pExternalTag Optional, but recommended. Pointer to a data unit external tag, e.g. volser
+ * @param i_pDescription Optional, a textual description of the data unit.
+ * @param o_pDataUnit a pointer to a DataUnit buffer allocated by the caller where
+ * data unit information is returned
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+KMS_AGENT_STATUS KMSAgent_RetrieveDataUnitByExternalUniqueID(
+ KMSClientProfile* const i_pProfile,
+ const unsigned char* const i_pExternalUniqueID,
+ int i_iExternalUniqueIDLen,
+ utf8cstr const i_pExternalTag,
+ utf8cstr const i_pDescription,
+ KMSAgent_DataUnit* const o_pDataUnit);
+
+/**
+ * retrieve keys assigned to a Data Unit.
+ * Agents should consult the state of each key that is returned and only
+ * use the key in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS state for encryption. The agent service
+ * attempts to return the most recently created key in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS state
+ * as the first key in the list when a <code>i_pKeyID</code> is not specified. This cannot be guaranteed as
+ * there may not be a key in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS state for the specified
+ * data unit. The rest of the keys returned are sorted in ascending order by the time in which
+ * they were created on the server.
+ * #KMSAgent_DisassociateDataUnitKeys may be used to manage the
+ * size of the key list associated with a data unit.
+ * The <code>i_iPageSize</code>, <code>i_iPageOffset</code> and <code>o_piKeysRemaining</code> parameters may be used for retrieving
+ * subsets of the list. For the <code>i_pKeyID</code> argument see the parameter's description.
+ * Callers should invoke#KMSAgent_FreeArrayOfKeys when finished with the buffer of keys.
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pDataUnit The Data Unit for which all keys will be retrieved.
+ * @param i_iPageSize the number of keys to be retrieved, up to #KMS_MAX_PAGE_SIZE.
+ * @param i_iPageOffset the offset from the start of the data unit's key list. Set this to zero for
+ * retrieval from the start of the list or if <code>i_pKeyID</code> is non-null.
+ * When set to zero the first key returned in the list
+ * will be the most recently created key in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS state.
+ * @param o_piKeysRemaining a pointer to an integer where the number of keys remaining in the list will be returned
+ * @param i_pKeyID Optional. If non-null, the caller provides a pointer to a KeyID that is used for
+ * the retrieval and the list returned begins with the specified data unit's KeyID and up to
+ * <code>i_iPageSize</code> keys associated with the data unit having an activation date greater than the key
+ * corresponding to <code>i_pKeyID</code>. The first key in the list is not guaranteed
+ * to be in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS state. If the specified <code>i_pKeyID</code>
+ * is not associated with the Data Unit then the behavior is like #KMSAgent_RetrieveKey and
+ * a single key is returned.
+ * When non-null the <code>i_iPageOffset</code>
+ * argument must be 0, these arguments are mutually exclusive.
+ * @param o_ppKeys a pointer to pointer to a #KMSAgent_ArrayOfKeys struct allocated by this routine for returning the specified number of
+ * Data Unit's keys and key associated data. Up to <code>i_iPageSize</code>
+ * keys will be returned. Callers should invoke #KMSAgent_FreeArrayOfKeys
+ * when finished with the buffer of keys.
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_KEY_CALLOUT_FAILURE
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_KEY_DOES_NOT_EXIST if <code>i_pKeyID</code> does not exist in the KMS.
+ * @return #KMS_AGENT_STATUS_KEY_DESTROYED if <code>i_pKeyID</code> has been destroyed.
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ * @return #KMS_AGENT_AES_KEY_UNWRAP_ERROR
+ * @return #KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR
+ */
+KMS_AGENT_STATUS KMSAgent_RetrieveDataUnitKeys(
+ KMSClientProfile* const i_pProfile,
+ const KMSAgent_DataUnit* const i_pDataUnit,
+ int i_iPageSize,
+ int i_iPageOffset,
+ int* const o_piKeysRemaining,
+ const unsigned char * const i_pKeyID,
+ KMSAgent_ArrayOfKeys** const o_ppKeys);
+
+/**
+ * returns a key in the #KMS_KEY_STATE_ACTIVE_PROTECT_AND_PROCESS for the specified data unit. A new
+ * key will be created if the data unit does not have a key in the protect and process state or if the
+ * agent is not authorized to access the key in the protect and process state.
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_pDataUnit The Data Unit for which a key in the protect and process state will be returned.
+ * @param i_pKeyGroupID Optional. If non-NULL and a new key is to be created, the KMS will associate the key with the specified KeyGroup
+ * @param o_pKey A pointer to a buffer for returning the protect and process key. If the data unit
+ * is associated with multiple keys in the protect and process state then the
+ * most recently created protect and process key is returned.
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_NO_MEMORY
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_KEY_CALLOUT_FAILURE
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_KMS_NO_READY_KEYS
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ * @return #KMS_AGENT_AES_KEY_UNWRAP_ERROR
+ * @return #KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR
+ */
+KMS_AGENT_STATUS KMSAgent_RetrieveProtectAndProcessKey(
+ KMSClientProfile* const i_pProfile,
+ const KMSAgent_DataUnit* const i_pDataUnit,
+ utf8cstr const i_pKeyGroupID,
+ KMSAgent_Key* const o_pKey);
+
+/**
+ * Helper function which frees memory allocated for the output to #KMSAgent_RetrieveDataUnitKeys.
+ * @param i_pArrayOfKeys The array of keys to be freed
+ */
+void KMSAgent_FreeArrayOfKeys(
+ KMSAgent_ArrayOfKeys* i_pArrayOfKeys);
+
+/**
+ * create an entry in the KMS audit log
+ *
+ * @param i_pProfile an initialized #KMSClientProfile
+ * @param i_iRetention the retention of audit log, can be one of:
+ * #KMS_AUDIT_LOG_LONG_TERM_RETENTION
+ * #KMS_AUDIT_LOG_MEDIUM_TERM_RETENTION
+ * #KMS_AUDIT_LOG_SHORT_TERM_RETENTION
+ * @param i_iCondition the condition of audit log, can be one of:
+ * #KMS_AUDIT_LOG_SUCCESS_CONDITION
+ * #KMS_AUDIT_LOG_ERROR_CONDITION
+ * #KMS_AUDIT_LOG_WARNING_CONDITION
+ * @param i_bIssueAlert issue alert (SNMP INFORM) for this audit
+ * @param i_pMessage the message text to be logged
+ *
+ * @return #KMS_AGENT_STATUS_OK
+ * @return #KMS_AGENT_STATUS_INVALID_PARAMETER
+ * @return #KMS_AGENT_STATUS_PROFILE_NOT_LOADED
+ * @return #KMS_AGENT_STATUS_GENERIC_ERROR
+ * @return #KMS_AGENT_STATUS_ACCESS_DENIED
+ * @return #KMS_AGENT_STATUS_SERVER_BUSY
+ * @return #KMS_AGENT_STATUS_KMS_UNAVAILABLE
+ * @return #KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE
+ */
+KMS_AGENT_STATUS KMSAgent_CreateAuditLog(
+ KMSClientProfile* i_pProfile,
+ enum KMS_AUDIT_LOG_RETENTION i_iRetention,
+ enum KMS_AUDIT_LOG_CONDITION i_iCondition,
+ int i_bIssueAlert,
+ utf8cstr i_pMessage );
+
+
+#ifdef KMSUSERPKCS12
+#include <sys/types.h>
+KMS_AGENT_STATUS KMSAgent_ChangeLocalPWD(
+ KMSClientProfile* i_pProfile,
+ utf8cstr const i_pOldPassphrase,
+ utf8cstr const i_pNewPassphrase);
+
+#define KMSAGENT_PROFILE_FLAGS uint32_t
+
+KMS_AGENT_STATUS
+KMSAgent_GetProfileStatus(
+ char *i_pProfileName,
+ KMSAGENT_PROFILE_FLAGS *flags);
+
+
+#define KMSAGENT_PROFILE_EXISTS_FLAG 0x01
+#define KMSAGENT_CLIENTKEY_EXISTS_FLAG 0x02
+#endif /* KMSUSERPKCS12 */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentAESKeyWrap.h b/usr/src/lib/libkmsagent/common/KMSAgentAESKeyWrap.h
new file mode 100644
index 0000000000..0a77573a00
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentAESKeyWrap.h
@@ -0,0 +1,85 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ * \file KMSAgentAESKeyWrap.h
+ */
+
+#ifndef KMSAgentAESKeyWrap_H
+#define KMSAgentAESKeyWrap_H
+
+#ifdef WIN32
+#include <string.h>
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * AES Key Wrap (see RFC 3394). No logging is performed since this
+ * functions must execute in a Known Answer Test prior to
+ * #KMSAgent_InitializeLibrary.
+ * @param kek The AES symmetric key-encryption key
+ * @param kek_len The size, in bytes, of the KEK
+ * @param pt The plain text key to be AES key wrapped
+ * @param len The "n" parameter from RFC3394, i.e. the number of 64-bit key data
+ * blocks. For example, with 256 bit plain text keys n=4.
+ * @param ct The resulting AES wrapped key. The size of ct needs to allow
+ * for the 64-bit integrity check value, i.e. sizeof(pt+8)
+ */
+ void aes_key_wrap (const uint8_t *kek,
+ size_t kek_len,
+ const uint8_t *pt,
+ size_t len,
+ uint8_t *ct);
+
+ /**
+ * AES Key Unwrap (see RFC 3394). No logging is performed since this
+ * functions must execute in a Known Answer Test prior to
+ * #KMSAgent_InitializeLibrary.
+ * @param kek The AES symmetric key-encryption key
+ * @param kek_len The size, in bytes, of the KEK
+ * @param ct The AES wrapped key.
+ * @param pt The resulting, unwrapped, plain text key.
+ * @param len The "n" parameter from RFC3394, i.e. the number of 64-bit key data
+ * blocks. For example, with 256 bit plain text keys n=4.
+ * @return 0 on success, non-zero otherwise
+ */
+ int aes_key_unwrap (const uint8_t *kek,
+ size_t kek_len,
+ const uint8_t *ct,
+ uint8_t *pt,
+ size_t len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* KMSAgentAESKeyWrap_H */
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentChallenge.cpp b/usr/src/lib/libkmsagent/common/KMSAgentChallenge.cpp
new file mode 100644
index 0000000000..637191a2af
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentChallenge.cpp
@@ -0,0 +1,317 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentChallenge.cpp
+ */
+
+#include "KMSAgentChallenge.h"
+#include "KMSAgentCryptoUtilities.h"
+#include "KMSAgentStringUtilities.h"
+#include "ApplianceParameters.h"
+#include "SYSCommon.h"
+
+extern "C" int Log2(char* msg1,
+ char* msg2);
+
+#ifdef METAWARE
+#include "debug.h"
+#endif
+
+
+/**
+ * ComputeChallengeResponse
+ */
+bool ComputeChallengeResponse(
+ const unsigned char* i_pAuthenticationSecret,
+ int i_iAuthenticationSecretLength,
+ const unsigned char* i_pRootCACertificate,
+ int i_iRootCACertificateLength,
+ const unsigned char* i_pAuthenticationChallenge,
+ int i_iAuthenticationChallengeLength,
+ unsigned char* o_pAuthenticationChallengeResponse,
+ int i_iAuthenticationChallengeResponseLength )
+{
+
+ bool rc;
+
+#ifdef DEBUG
+ Log2 ("KMSAgent_LoadProfile::ComputeChallengeResponse", "Entered");
+#endif
+ FATAL_ASSERT( i_iAuthenticationChallengeResponseLength == HMAC_LENGTH );
+
+ // challenge response is HMAC-SHA1( RootCACertificate ||
+ // AuthenticationChallenge, AuthenticationSecret )
+ const unsigned char* aBuffersToHMAC[2];
+ int aBuffersToHMACSize[2];
+
+ aBuffersToHMAC[0] = i_pRootCACertificate;
+ aBuffersToHMACSize[0] = i_iRootCACertificateLength;
+
+ aBuffersToHMAC[1] = i_pAuthenticationChallenge;
+ aBuffersToHMACSize[1] = i_iAuthenticationChallengeLength;
+
+ rc = HMACBuffers(
+ 2,
+ aBuffersToHMAC,
+ aBuffersToHMACSize,
+ i_pAuthenticationSecret,
+ i_iAuthenticationSecretLength,
+ o_pAuthenticationChallengeResponse );
+
+#if defined(METAWARE) && defined(DEBUG)
+ int j=0;
+
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "length=%x\n",
+ i_iAuthenticationSecretLength);
+
+ for (int i=0 ; i< i_iAuthenticationSecretLength; i++)
+ {
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "%x",
+ i_pAuthenticationSecret[i]);
+ }
+ snprintf(outmsg+j, OUTMSG_SIZE, "\n");
+
+ Log2("Secret = ",outmsg);
+#endif
+
+#if defined(METAWARE) && defined(DEBUG)
+ j=0;
+
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "length=%x\n",
+ i_iRootCACertificateLength);
+
+ for (i=0 ; i< i_iRootCACertificateLength; i++)
+ {
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "%x",
+ i_pRootCACertificate[i]);
+ }
+ snprintf(outmsg+j, OUTMSG_SIZE, "\n");
+
+ Log2("i_pRootCACertificate = ",outmsg);
+#endif
+
+#if defined(METAWARE) && defined(DEBUG)
+ j=0;
+
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "length=%x\n",
+ i_iAuthenticationChallengeLength);
+
+ for (i=0 ; i< i_iAuthenticationChallengeLength; i++)
+ {
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "%x",
+ i_pAuthenticationChallenge[i]);
+ }
+ snprintf(outmsg+j, OUTMSG_SIZE, "\n");
+
+ Log2("i_pAuthenticationChallenge = ",outmsg);
+#endif
+
+#if defined(METAWARE) && defined(DEBUG)
+ j=0;
+
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "length=%x\n",
+ i_iAuthenticationChallengeResponseLength);
+
+ for (i=0 ; i< i_iAuthenticationChallengeResponseLength; i++)
+ {
+ j+=snprintf(outmsg+j, OUTMSG_SIZE,
+ "%x",
+ o_pAuthenticationChallengeResponse[i]);
+ }
+ snprintf(outmsg+j, OUTMSG_SIZE, "\n");
+
+ Log2("o_pAuthenticationChallengeResponse = ",outmsg);
+#endif
+
+ return rc;
+
+#undef __IAM__
+}
+
+/**
+ * ComputeEntityHashedPassphraseAndAuthenticationSecret
+ */
+bool ComputeEntityHashedPassphraseAndAuthenticationSecret(
+ const char* i_sPassphrase,
+ char* const o_sHexHashedPassphrase,
+ int* const o_piAuthenticationHashIterationCount,
+ char* const o_sHexAuthenticationSecret )
+{
+ // HashedPassphrase is SHA1( Passphrase-UTF-8 )
+ // Using UTF-8 ensures the same result on different platforms with
+ // different wide character representations.
+ // This hashed passphrase value is used to wrap entity
+ // private key materials.
+#if defined(METAWARE) && defined(DEBUG)
+ Log2 ("KMSAgent_LoadProfile::ComputeEntityHashedPassphraseAndAuthenticationSecret",
+ "Entered");
+#endif
+
+ unsigned char aHashedPassphrase[HASH_LENGTH];
+
+ memset(aHashedPassphrase, 0, HASH_LENGTH);
+
+ if ( strlen(i_sPassphrase) > 0 )
+ {
+ if ( !HashBuffer(
+ (unsigned char*)i_sPassphrase,
+ strlen(i_sPassphrase),
+ aHashedPassphrase) )
+ {
+ return false;
+ }
+ }
+
+ ConvertBinaryToUTF8HexString( o_sHexHashedPassphrase,
+ aHashedPassphrase,
+ HASH_LENGTH );
+
+ // HexAuthenticationSecret is SHA1( SHA1( ... ( SHA1(
+ // HashedPassphrase ) ) ) The number of iterations is time bounded
+ // at 1/10 of a second, and also bounded by fixed minimum and
+ // maximum values (to prevent too weak of a computation and to
+ // prevent a DoS, respectively). This value is used as the shared
+ // secret in challenge-response authentication exchanges.
+
+ *o_piAuthenticationHashIterationCount = 0;
+
+ unsigned long iStartTickCount = K_GetTickCount();
+
+ while ( *o_piAuthenticationHashIterationCount <
+ MAX_AUTHENTICATION_ITERATION_COUNT
+ && ( *o_piAuthenticationHashIterationCount <
+ MIN_AUTHENTICATION_ITERATION_COUNT
+ || iStartTickCount +
+ AUTHENTICATION_ITERATION_TIME_IN_MILLISECONDS >
+ K_GetTickCount() ) )
+ {
+ if ( !HashBuffer(
+ aHashedPassphrase,
+ HASH_LENGTH,
+ aHashedPassphrase) )
+ {
+ return false;
+ }
+
+ (*o_piAuthenticationHashIterationCount)++;
+ }
+
+ ConvertBinaryToUTF8HexString( o_sHexAuthenticationSecret,
+ aHashedPassphrase, HASH_LENGTH );
+
+#if defined(METAWARE) && defined(DEBUG)
+ snprintf(outmsg, OUTMSG_SIZE,
+ "o_sHexAuthenticationSecret=%x o_piAuth..."
+ "= %x aHashedPassphrase=%s\n",
+ o_sHexAuthenticationSecret,
+ *o_piAuthenticationHashIterationCount,
+ aHashedPassphrase);
+ Log2("ComputeEntityHashedPassphraseAndAuthenticationSecret ",
+ outmsg);
+#endif
+
+ return true;
+}
+
+/**
+ * ComputeFixedEntityHashedPassphraseAndAuthenticationSecret
+ */
+bool ComputeFixedEntityHashedPassphraseAndAuthenticationSecret(
+ const char* i_sPassphrase,
+ char* const o_sHexHashedPassphrase,
+ int i_iAuthenticationHashIterationCount,
+ char* const o_sHexAuthenticationSecret )
+{
+ // compute same values as
+ // ComputeEntityHashedPassphraseAndAuthenticationSecret, except
+ // iteration count is fixed
+#if defined(METAWARE) && defined(DEBUG)
+ Log2 ("KMSAgent_LoadProfile::"
+ "ComputeFixedEntityHashedPassphraseAndAuthenticationSecret", "Entered");
+#endif
+
+ // detect attempts to cause weak computation or DoS attack
+ if ( i_iAuthenticationHashIterationCount <
+ MIN_AUTHENTICATION_ITERATION_COUNT ||
+ i_iAuthenticationHashIterationCount >
+ MAX_AUTHENTICATION_ITERATION_COUNT )
+ {
+ return false;
+ }
+
+
+ unsigned char aHashedPassphrase[HASH_LENGTH];
+
+ memset(aHashedPassphrase, 0, HASH_LENGTH);
+
+ if ( strlen(i_sPassphrase) > 0 )
+ {
+ if ( !HashBuffer(
+ (unsigned char*)i_sPassphrase,
+ strlen(i_sPassphrase),
+ aHashedPassphrase) )
+ {
+ return false;
+ }
+ }
+
+ ConvertBinaryToUTF8HexString( o_sHexHashedPassphrase,
+ aHashedPassphrase, HASH_LENGTH );
+
+ int i;
+ for ( i = 0; i < i_iAuthenticationHashIterationCount; i++ )
+ {
+ if ( !HashBuffer(
+ aHashedPassphrase,
+ HASH_LENGTH,
+ aHashedPassphrase) )
+ {
+ return false;
+ }
+ }
+
+ ConvertBinaryToUTF8HexString( o_sHexAuthenticationSecret,
+ aHashedPassphrase, HASH_LENGTH );
+
+#if defined(METAWARE) && defined(DEBUG)
+ snprintf(outmsg, OUTMSG_SIZE,
+ "i_iAuth %x \n",
+ i_iAuthenticationHashIterationCount);
+
+ Log2("ComputeEntityHashedPassphraseAndAuthenticationSecret ",
+ outmsg);
+#endif
+
+
+ return true;
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentChallenge.h b/usr/src/lib/libkmsagent/common/KMSAgentChallenge.h
new file mode 100644
index 0000000000..b259f13e69
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentChallenge.h
@@ -0,0 +1,111 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentChallenge.h
+ */
+
+#ifndef KMSAagentChallenge_H
+#define KMSAagentChallenge_H
+
+/**
+ * computes the response to the KMA's challenge using
+ * HMAC-SHA1( RootCACertificate || AuthenticationChallenge,
+ * AuthenticationSecret ). The AuthenticationSecret is
+ * used as the key in the HMAC-SHA1 computation.
+ *
+ * @param i_pAuthenticationSecret
+ * @param i_iAuthenticationSecretLength
+ * @param i_pRootCACertificate
+ * @param i_iRootCACertificateLength
+ * @param i_pAuthenticationChallenge
+ * @param i_iAuthenticationChallengeLength
+ * @param o_pAuthenticationChallengeResponse
+ * @param i_iAuthenticationChallengeResponseLength
+ *
+ * @return boolean success indicator
+ */
+bool ComputeChallengeResponse(
+ const unsigned char* i_pAuthenticationSecret,
+ int i_iAuthenticationSecretLength,
+ const unsigned char* i_pRootCACertificate,
+ int i_iRootCACertificateLength,
+ const unsigned char* i_pAuthenticationChallenge,
+ int i_iAuthenticationChallengeLength,
+ unsigned char* o_pAuthenticationChallengeResponse,
+ int i_iAuthenticationChallengeResponseLength );
+
+/**
+ * computes the SHA1 hash of the specified passphrase.
+ * The number of SHA1 iterations
+ * is recorded in <code>o_iAuthenticationHashIterationCount</code> and the result
+ * stored in o_sHexAuthenticationSecret as a UTF8 hex string.
+ * HexAuthenticationSecret is SHA1( SHA1( ... ( SHA1( HashedPassphrase ) ) )
+ * The number of iterations is time bounded at 1/10 of a second, and also
+ * bounded by fixed minimum and maximum values (to prevent too weak of a
+ * computation and to prevent a DoS, respectively).
+ * This value is used as the shared secret in challenge-response
+ * authentication exchanges.
+
+ * @param i_sPassphrase the passphrase to be hashed
+ * @param o_sHexHashedPassphrase the hashed passphrase
+ * returned in UTF8 hexadecimal, this
+ * buffer should be at least
+ * 2*HASH_LENGTH+1 bytes
+ * @param o_iAuthenticationHashIterationCount
+ * @param o_sHexAuthenticationSecret
+ *
+ * @return boolean success indicator
+ */
+bool ComputeEntityHashedPassphraseAndAuthenticationSecret(
+ const char* const i_sPassphrase,
+ char* const o_sHexHashedPassphrase,
+ int* const o_piAuthenticationHashIterationCount,
+ char* const o_sHexAuthenticationSecret );
+
+/**
+ * computes the SHA1 hash of the specified passphrase. The SHA1 is
+ * performed a "fixed" number of times as specified by
+ * <code>i_iAuthenticationHashIterationCount</code>.
+ *
+ * @param i_sPassphrase the passprhase to be SHA1 hashed
+ * @param o_sHexHashedPassphrase the SHA1 hash
+ * of i_sPassphrase stored as a UTF8 hex string
+ * @param i_iAuthenticationHashIterationCount the number
+ * of times to SHA1 hash the passphrase
+ * @param o_sHexAuthenticationSecret the passphrase hashed
+ * the fixed number of times and stored as a UTF8
+ * hex string
+ *
+ * @return boolean success indicator
+ */
+bool ComputeFixedEntityHashedPassphraseAndAuthenticationSecret(
+ const char* i_sPassphrase,
+ char* const o_sHexHashedPassphrase,
+ int i_iAuthenticationHashIterationCount,
+ char* const o_sHexAuthenticationSecret );
+
+#endif /* KMSAagentChallenge_H */
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.cpp b/usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.cpp
new file mode 100644
index 0000000000..3ae811bc9d
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.cpp
@@ -0,0 +1,115 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentCryptoUtilities.cpp
+ */
+
+#include <openssl/rand.h>
+#include <openssl/hmac.h>
+#include <openssl/err.h>
+#include <openssl/sha.h>
+
+#include "KMSAgentCryptoUtilities.h"
+#include "SYSCommon.h"
+#include "KMSAgentStringUtilities.h"
+//#include "ApplianceParameters.h"
+
+// Find header in CryptoUtilities.h
+bool GetPseudorandomBytes(
+ int i_iNumBytes,
+ unsigned char* o_pBytes )
+{
+ if ( 1 != RAND_bytes( o_pBytes, i_iNumBytes) )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+// assumes o_pHashedBuffer points to HASH_LENGTH bytes
+bool HashBuffer(
+ const unsigned char* i_pBufferToHash,
+ int i_iBufferToHashSize,
+ unsigned char* o_pHashedBuffer )
+{
+
+ FATAL_ASSERT( HASH_LENGTH == SHA_DIGEST_LENGTH );
+ FATAL_ASSERT( i_pBufferToHash && (i_iBufferToHashSize > 0) && o_pHashedBuffer );
+
+ unsigned char aDigest[HASH_LENGTH];
+
+ if ( NULL == SHA1( i_pBufferToHash, i_iBufferToHashSize, aDigest ) )
+ {
+ return false;
+ }
+
+ memcpy( o_pHashedBuffer, aDigest, HASH_LENGTH );
+
+ return true;
+}
+
+// assumes o_pHMACBuffer points to HMAC_LENGTH bytes
+bool HMACBuffers(
+ int i_iBufferCount,
+ const unsigned char** i_pBufferToHMAC,
+ int* i_pBufferToHMACSize,
+ const unsigned char* i_pHMACKey,
+ int i_iHMACKeySize,
+ unsigned char* o_pHMACBuffer )
+{
+ // assumes o_pHMACBuffer points to HMAC_LENGTH bytes
+
+ FATAL_ASSERT( HMAC_LENGTH == SHA_DIGEST_LENGTH );
+ FATAL_ASSERT( (i_iBufferCount > 0) &&
+ i_pBufferToHMAC &&
+ i_pBufferToHMACSize &&
+ i_pHMACKey &&
+ (i_iHMACKeySize > 0) && o_pHMACBuffer );
+
+ HMAC_CTX stContext;
+
+ HMAC_CTX_init( &stContext );
+
+ HMAC_Init_ex( &stContext, i_pHMACKey, i_iHMACKeySize, EVP_sha1(), NULL );
+
+ int i;
+ for ( i = 0; i < i_iBufferCount; i++ )
+ {
+ HMAC_Update( &stContext, i_pBufferToHMAC[i], i_pBufferToHMACSize[i] );
+ }
+
+ unsigned int iHMACSize = HMAC_LENGTH;
+
+ HMAC_Final( &stContext, o_pHMACBuffer, &iHMACSize );
+
+ FATAL_ASSERT( iHMACSize == HMAC_LENGTH );
+
+ HMAC_CTX_cleanup( &stContext );
+
+ return true;
+}
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.h b/usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.h
new file mode 100644
index 0000000000..40a80ac93f
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentCryptoUtilities.h
@@ -0,0 +1,100 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentCryptoUtilities.h
+ */
+
+#ifndef KMSAgentCryptoUtilities_H
+#define KMSAgentCryptoUtilities_H
+
+#ifdef WIN32
+#pragma warning(disable: 4786)
+#endif
+
+#define HASH_LENGTH 20
+#define HMAC_LENGTH 20
+
+/**
+ * Generates a random set of bytes of the specified length.
+ *
+ * @return boolean success indicator
+ */
+bool GetPseudorandomBytes(
+ int i_iNumBytes,
+ unsigned char* o_pBytes );
+
+/**
+ * computes SHA-1 hash of the buffer
+ * @param i_pBufferToHash
+ * @param i_iBufferToHashSize
+ * @param o_pHashedBuffer buffer to recieve the SHA-1 hash and must be
+ * #HASH_LENGTH bytes
+ * @return boolean success indicator
+ */
+bool HashBuffer(
+ const unsigned char* i_pBufferToHash,
+ int i_iBufferToHashSize,
+ unsigned char* o_pHashedBuffer );
+
+#ifdef METAWARE
+
+// implemented in KMSAgentCryptoUtilitiesTreckHmac.c
+extern "C" int HMACBuffers(
+ int i_iBufferCount,
+ const unsigned char** i_pBufferToHMAC,
+ int* i_pBufferToHMACSize,
+ const unsigned char* i_pHMACKey,
+ int i_iHMACKeySize,
+ unsigned char* o_pHMACBuffer );
+
+#else
+/**
+ * computes HMAC on the supplied buffers using SHA-1
+ * hashing and the key supplied. No logging is performed since this
+ * functions must execute in a Known Answer Test prior to
+ * #KMSAgent_InitializeLibrary.
+ * @param i_iBufferCount number of buffers provided in #i_pBufferToHMAC
+ * @param i_pBufferToHMAC array of buffers
+ * @param i_pBufferToHMACSize array of sizes corresponding to buffers in
+ * #i_pBufferToHMAC
+ * @param i_pHMACKey secret key
+ * @param i_iHMACKeySize length of the key in bytes
+ * @param o_pHMACBuffer buffer to contain the HMAC, this buffer must be
+ * #HASH_LENGTH bytes
+ * @return boolean success indicator
+ */
+bool HMACBuffers(
+ int i_iBufferCount,
+ const unsigned char** i_pBufferToHMAC,
+ int* i_pBufferToHMACSize,
+ const unsigned char* i_pHMACKey,
+ int i_iHMACKeySize,
+ unsigned char* o_pHMACBuffer );
+#endif
+
+
+
+#endif //KMSAgentCryptoUtilities_H
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.cpp b/usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.cpp
new file mode 100644
index 0000000000..278554545a
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.cpp
@@ -0,0 +1,202 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentDataUnitCache.cpp
+ */
+
+#include <stdio.h>
+#include "SYSCommon.h"
+#include "KMSClientProfile.h"
+#include "KMSAgentDataUnitCache.h"
+
+CDataUnitCache::CDataUnitCache(int i_iMaxSize)
+{
+ m_iSize = 0;
+ m_iIndex = 0;
+ m_iMaxSize = i_iMaxSize;
+ m_pCache = 0;
+
+ K_CreateMutex(&m_Lock);
+}
+
+CDataUnitCache::~CDataUnitCache()
+{
+ delete[] m_pCache;
+ K_DestroyMutex(m_Lock);
+}
+
+bool CDataUnitCache::Insert(
+ const unsigned char* const i_pDataUnitID,
+ int i_iDataUnitIDMaxLen,
+ const unsigned char* const i_pDataUnitKeyID ,
+ int i_iDataUnitKeyIDMaxLen,
+ const utf8char* const i_wsApplianceNetworkAddress )
+{
+ FATAL_ASSERT( (i_pDataUnitID && i_iDataUnitIDMaxLen == KMS_DATA_UNIT_ID_SIZE) ||
+ (i_pDataUnitKeyID && i_iDataUnitKeyIDMaxLen == KMS_KEY_ID_SIZE));
+ FATAL_ASSERT( i_wsApplianceNetworkAddress &&
+ strlen( i_wsApplianceNetworkAddress ) < KMS_MAX_NETWORK_ADDRESS );
+
+ Lock();
+
+ if ( m_pCache == 0 )
+ {
+ m_pCache = new DataUnitCacheEntry[m_iMaxSize];
+
+ if ( !m_pCache )
+ {
+ // no error logged on out of memory
+ Unlock();
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("CDataUnitCache::Insert new DataUnitCacheEntry alloc failure\n");
+#endif
+ return false;
+ }
+ }
+
+ if( m_iSize >= m_iMaxSize )
+ {
+ // the cache is full, so reuse an old slot
+
+ m_iIndex = (m_iIndex + 1) % m_iMaxSize;
+ }
+ else
+ {
+ m_iIndex = m_iSize;
+
+ m_iSize++;
+ }
+
+ strncpy( m_pCache[m_iIndex].m_wsApplianceNetworkAddress,
+ i_wsApplianceNetworkAddress,
+ sizeof(m_pCache[m_iIndex].m_wsApplianceNetworkAddress) );
+ m_pCache[m_iIndex].m_wsApplianceNetworkAddress[sizeof(m_pCache[m_iIndex].m_wsApplianceNetworkAddress)-1] = '\0';
+
+ if ( i_pDataUnitID )
+ {
+ memcpy( m_pCache[m_iIndex].m_aDataUnitID,
+ i_pDataUnitID,
+ i_iDataUnitIDMaxLen );
+ }
+ else
+ {
+ memset( m_pCache[m_iIndex].m_aDataUnitID,0,KMS_DATA_UNIT_ID_SIZE);
+ }
+
+ if ( i_pDataUnitKeyID )
+ {
+ memcpy( m_pCache[m_iIndex].m_aDataUnitKeyID,
+ i_pDataUnitKeyID,
+ i_iDataUnitKeyIDMaxLen );
+ }
+ else
+ {
+ memset(m_pCache[m_iIndex].m_aDataUnitKeyID,0,KMS_KEY_ID_SIZE);
+ }
+
+ Unlock();
+
+ return true;
+}
+
+bool CDataUnitCache::GetApplianceByDataUnitID(
+ const unsigned char* const i_pDataUnitID,
+ int i_iDataUnitIDMaxLen,
+ utf8char* const o_wsApplianceNetworkAddress,
+ int i_iMaxApplianceNetworkAddressLen )
+{
+ FATAL_ASSERT( i_pDataUnitID );
+ FATAL_ASSERT( i_iDataUnitIDMaxLen == KMS_DATA_UNIT_ID_SIZE );
+ FATAL_ASSERT( i_iMaxApplianceNetworkAddressLen <= KMS_MAX_NETWORK_ADDRESS );
+
+ // assumes o_wsApplianceNetworkAddress points to at least KMS_MAX_NETWORK_ADDRESS
+
+ Lock();
+
+ int i;
+ for( i = 0; i < m_iSize; i++ )
+ {
+ if( memcmp(m_pCache[i].m_aDataUnitID, i_pDataUnitID, KMS_DATA_UNIT_ID_SIZE) == 0 )
+ {
+ strncpy( o_wsApplianceNetworkAddress,
+ m_pCache[i].m_wsApplianceNetworkAddress,
+ i_iMaxApplianceNetworkAddressLen );
+ o_wsApplianceNetworkAddress[i_iMaxApplianceNetworkAddressLen-1] = '\0';
+ Unlock();
+ return true;
+ }
+ }
+
+ Unlock();
+
+ return false;
+}
+
+bool CDataUnitCache::GetApplianceByDataUnitKeyID(
+ const unsigned char* const i_pDataUnitKeyID,
+ int i_iDataUnitKeyIDMaxLen,
+ utf8char* const o_wsApplianceNetworkAddress,
+ int i_iMaxApplianceNetworkAddressLen )
+{
+ FATAL_ASSERT( i_pDataUnitKeyID );
+ FATAL_ASSERT( i_iDataUnitKeyIDMaxLen == KMS_KEY_ID_SIZE );
+ FATAL_ASSERT( i_iMaxApplianceNetworkAddressLen <= KMS_MAX_NETWORK_ADDRESS );
+
+ // assumes o_wsApplianceNetworkAddress points to at least KMS_MAX_NETWORK_ADDRESS
+
+ Lock();
+
+ int i;
+ for( i = 0; i < m_iSize; i++ )
+ {
+ if( memcmp(m_pCache[i].m_aDataUnitKeyID,
+ i_pDataUnitKeyID, KMS_KEY_ID_SIZE) == 0 )
+ {
+ strncpy( o_wsApplianceNetworkAddress,
+ m_pCache[i].m_wsApplianceNetworkAddress,
+ i_iMaxApplianceNetworkAddressLen );
+ o_wsApplianceNetworkAddress[i_iMaxApplianceNetworkAddressLen-1] = '\0';
+
+ Unlock();
+
+ return true;
+ }
+ }
+
+ Unlock();
+
+ return false;
+}
+
+void CDataUnitCache::Lock()
+{
+ K_LockMutex(m_Lock);
+}
+
+void CDataUnitCache::Unlock()
+{
+ K_UnlockMutex(m_Lock);
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.h b/usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.h
new file mode 100644
index 0000000000..cacec08c74
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentDataUnitCache.h
@@ -0,0 +1,99 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/** @file KMSAgentDataUnitCache.h
+ * @defgroup EncryptionAgent Encryption Agent API
+ *
+ */
+#ifndef KMSAGENT_DATA_UNIT_CACHE_H
+#define KMSAGENT_DATA_UNIT_CACHE_H
+
+#define DATA_UNIT_CACHE_MAX_SIZE 128
+
+typedef struct DataUnitCacheEntry
+{
+ utf8char m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS+1];
+ unsigned char m_aDataUnitID[KMS_DATA_UNIT_ID_SIZE];
+ unsigned char m_aDataUnitKeyID[KMS_KEY_ID_SIZE];
+
+} DataUnitCacheEntry;
+
+/**
+ * Maintains an affinity list between KMAs and DUs and KeyIDs.
+ */
+class CDataUnitCache
+{
+
+public:
+ CDataUnitCache(int i_iMaxSize = DATA_UNIT_CACHE_MAX_SIZE);
+ ~CDataUnitCache();
+
+ /**
+ * insert a new DataUnitCacheEntry into the cache list, either i_pDataUnitID or
+ * i_pDataUnitKeyID must be specified for affinity with the specified i_wsApplianceNetworkAddress
+ * @param i_pDataUnitID optional, specifies a DU ID cache entry if specified
+ * @param i_iDataUnitIDMaxLen ignored if i_pDataUnitID not specified, otherwise
+ * specifies the length of i_pDataUnitID
+ * @param i_pDataUnitKeyID optional, specifies a Key ID cache entry if specified
+ * @param i_iDataUnitKeyIDMaxLen ignored if i_pDataUnitKeyID is not specified,
+ * otherwise specifies the length of i_pDataUnitKeyID
+ * @param i_wsApplianceNetworkAddress required and specifies the KMA affiliated
+ * with the DU ID or Key ID
+ * @return True if successfully inserted into the cache
+ */
+ bool Insert(
+ const unsigned char* const i_pDataUnitID,
+ int i_iDataUnitIDMaxLen,
+ const unsigned char* const i_pDataUnitKeyID ,
+ int i_iDataUnitKeyIDMaxLen,
+ const utf8char* const i_wsApplianceNetworkAddress );
+
+ bool GetApplianceByDataUnitID(
+ const unsigned char* const i_pDataUnitID,
+ int i_iDataUnitIDMaxLen,
+ utf8char* const o_wsApplianceNetworkAddress,
+ int i_iMaxApplianceNetworkAddressLen );
+
+ bool GetApplianceByDataUnitKeyID(
+ const unsigned char* const i_pDataUnitKeyID,
+ int i_iDataUnitKeyIDMaxLen,
+ utf8char* const o_wsApplianceNetworkAddress,
+ int i_iMaxApplianceNetworkAddressLen );
+
+protected:
+ void Lock();
+ void Unlock();
+
+private:
+ K_MUTEX_HANDLE m_Lock;
+
+ int m_iIndex;
+ int m_iSize;
+ int m_iMaxSize;
+ DataUnitCacheEntry *m_pCache;
+
+};
+
+#endif
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentFatalState.cpp b/usr/src/lib/libkmsagent/common/KMSAgentFatalState.cpp
new file mode 100644
index 0000000000..37a1620fd7
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentFatalState.cpp
@@ -0,0 +1,79 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentFatalState.cpp
+ */
+#include <stdio.h>
+#include <string.h>
+
+#include "SYSCommon.h"
+#include "KMSAgentStringUtilities.h"
+#include "KMSAuditLogger.h"
+
+#define MAX_TIME_STAMP_LENGTH 30
+
+#ifndef METAWARE
+/**
+ * append the state of the application in the <KMSAgentAuditLogger> log file.
+ */
+void process_fatal_application_state(const char* sFile,
+ const char* sFunction,
+ int iLine,
+ const char* sAdditionalText)
+{
+
+ // File format: <date/time>,<operation>,<retention>,<audit id>,<network adddress>,<message>
+ char sFileLogEntry[MAX_LOG_FILE_LINE_LENGTH];
+ char sTimeStamp[MAX_TIME_STAMP_LENGTH];
+ char sLine[20];
+
+ GetCurrentDateTimeISO8601UTC(sTimeStamp, MAX_TIME_STAMP_LENGTH);
+ Int64ToUTF8(sLine, iLine, false, false);
+
+ strncpy(sFileLogEntry, "A fatal application error has occurred. Date: ", sizeof(sFileLogEntry));
+
+ sFileLogEntry[sizeof(sFileLogEntry)-1] = '\0';
+
+ strncat(sFileLogEntry, sTimeStamp, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ strncat(sFileLogEntry, " File: ", MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ strncat(sFileLogEntry, sFile, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ strncat(sFileLogEntry, " Function: ", MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ strncat(sFileLogEntry, sFunction, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ strncat(sFileLogEntry, " Line: ", MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ strncat(sFileLogEntry, sLine, MAX_LOG_FILE_LINE_LENGTH - strlen(sFileLogEntry));
+
+ LogToFile( 0, sFileLogEntry );
+
+ exit( -1 );
+}
+
+#endif
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.cpp b/usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.cpp
new file mode 100644
index 0000000000..6a2bfc9f43
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.cpp
@@ -0,0 +1,43 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "KMSAgentKeyCallout.h"
+
+#ifdef METAWARE
+extern "C" int ecpt_get_pc_key_and_xor( unsigned char * key );
+#endif
+
+/**
+ * Hook function to get the key in the clear (XOR is presently used)
+ * @returns 0=ok, nonzero = bad
+ */
+int KMSAgentKeyCallout( unsigned char io_aKey[KMS_MAX_KEY_SIZE] )
+{
+#ifndef METAWARE
+ return 0;
+#else
+ return ecpt_get_pc_key_and_xor( io_aKey );
+#endif
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.h b/usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.h
new file mode 100644
index 0000000000..d4a66f4a05
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentKeyCallout.h
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentKeyCallout.h
+ *
+ */
+
+#ifndef KMSAGENT_KEYCALLOUT_H
+#define KMSAGENT_KEYCALLOUT_H
+
+#include "KMSAgent.h"
+
+/**
+ * Behavior is up to customizers of the KMS Agent reference implementation.
+ * A possible usage of this function is to encrypt the plaintext
+ * key value. This function will be invoked by the following KMS Agent API
+ * functions upon successful receipt of a key from a KMS transaction:
+ * <ul>
+ * <li>KMSAgent_CreateKey
+ * <li>KMSAgent_RetrieveKey
+ * <li>KMSAgent_RetrieveDataUnitKeys - once for each key retrieved
+ * <li>KMSAgent_RetrieveProtectAndProcessKey
+ * </ul>
+ *
+ * @param io_pKey a plaintext key
+ * @return 0 if success
+ */
+int KMSAgentKeyCallout( unsigned char io_aKey[KMS_MAX_KEY_SIZE] );
+
+
+#endif
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.cpp b/usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.cpp
new file mode 100644
index 0000000000..eea2fbb098
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.cpp
@@ -0,0 +1,454 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentKnownAnswerTests.cpp
+ */
+
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+#include <aes_impl.h>
+#define AES_MAXKEYBYTES AES_MAX_KEY_BYTES
+#define AES_MAXKEYBITS AES_MAXBITS
+#else
+#include "rijndael.h"
+#endif
+#include "KMSAgentCryptoUtilities.h"
+#include "KMSAgentStringUtilities.h"
+
+#ifdef METAWARE
+#include "debug.h"
+#include "sizet.h"
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#endif
+
+#include "KMSAgentAESKeyWrap.h"
+#include "KMSAgentKnownAnswerTests.h"
+
+int KnownAnswerTestAESKeyWrap (void)
+{
+
+ /*
+ * Test Vectors from RFC3394 for 256 bit KEK and 256 bit Key
+ * Wrap Input:
+ KEK:
+ 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
+ Key Data:
+ 00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F
+
+ Output:
+ Ciphertext 28C9F404C4B810F4 CBCCB35CFB87F826 3F5786E2D80ED326
+ CBC7F0E71A99F43B FB988B9B7A02DD21
+
+ Unwrap:
+ Plaintext A6A6A6A6A6A6A6A6 0011223344556677 8899AABBCCDDEEFF
+ 0001020304050607 08090A0B0C0D0E0F
+
+ Output:
+ Key Data:
+ 00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F
+
+ */
+
+ static char sKEK[] = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F";
+ static char sKey[] = "00112233445566778899AABBCCDDEEFF000102030405060708090A0B0C0D0E0F";
+ static char sKnownCiphertext[] = "28C9F404C4B810F4CBCCB35CFB87F8263F5786E2D80ED326CBC7F0E71A99F43BFB988B9B7A02DD21";
+
+ //#ifdef KAT_DEBUG
+ // printf("\nAES Key Wrap Test using Test Vectors from RFC 3394 for 256b KEK and 256b Key\n\n");
+ // printf("KEK=%s\n", sKEK);
+ // printf("Key=%s\n", sKey);
+ //#endif
+
+ // key-encryption key
+ unsigned char acKEK[AES_MAXKEYBYTES];
+
+ // plaintext key
+ unsigned char acKey[AES_MAXKEYBYTES];
+
+ // the wrapped key includes an extra 64bits for the integrity check register
+ unsigned char acWrappedKey[AES_MAXKEYBYTES + 8];
+ unsigned char acUnWrappedKey[AES_MAXKEYBYTES];
+ unsigned char acExpectedWrappedKey[AES_MAXKEYBYTES + 8];
+
+ if ((size_t) ConvertUTF8HexStringToBinary(
+ sKnownCiphertext,
+ acExpectedWrappedKey) != strlen(sKnownCiphertext) / 2)
+ {
+ return -1;
+ }
+
+ if (ConvertUTF8HexStringToBinary(
+ sKEK,
+ acKEK) != AES_MAXKEYBYTES)
+ {
+ return -1;
+ }
+
+ if (ConvertUTF8HexStringToBinary(
+ sKey,
+ acKey) != AES_MAXKEYBYTES)
+ {
+ return -1;
+ }
+
+ // for 256 bit Key n=64
+ aes_key_wrap(acKEK, sizeof (acKEK), acKey,
+ 4, acWrappedKey);
+
+ if (memcmp(acWrappedKey, acExpectedWrappedKey, sizeof (acWrappedKey)) != 0)
+ {
+ return -1;
+ }
+
+ if (aes_key_unwrap(acKEK, sizeof (acKEK), acWrappedKey,
+ acUnWrappedKey, 4) != 0)
+ {
+ return -1;
+ }
+
+ if (memcmp(acKey, acUnWrappedKey, sizeof (acKey)) != 0)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int AES_ECB_TestExecution (
+ const char * const i_sPlainText,
+ const char * const i_sKnownCypherText,
+ const unsigned char * const i_pKey)
+{
+ unsigned char acPlainText[256];
+ unsigned char acCypherText[sizeof (acPlainText)];
+ unsigned char acKnownCypherText[sizeof (acPlainText)];
+ unsigned char acDecryptedCypherText[sizeof (acPlainText)];
+ memset(acDecryptedCypherText, 0, sizeof (acDecryptedCypherText));
+
+#ifdef KAT_DEBUG
+ char sComputedCypherText[256];
+#endif
+
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+ void *ks;
+ size_t ks_size;
+#else
+ rijndael_ctx ctx;
+#endif
+
+ if ((size_t) ConvertUTF8HexStringToBinary(
+ i_sPlainText,
+ acPlainText) != strlen(i_sPlainText) / 2)
+ {
+ return -1;
+ }
+ if ((size_t) ConvertUTF8HexStringToBinary(
+ i_sKnownCypherText,
+ acKnownCypherText) != strlen(i_sKnownCypherText) / 2)
+ {
+ return -1;
+ }
+
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+ ks = aes_alloc_keysched(&ks_size, 0);
+ if (ks == NULL)
+ return (-1);
+ aes_init_keysched(i_pKey, AES_MAXKEYBITS, ks);
+ (void) aes_encrypt_block(ks, acPlainText, acCypherText);
+#else
+ rijndael_set_key_enc_only(&ctx, (uint8_t *) i_pKey, AES_MAXKEYBITS);
+
+ rijndael_encrypt(&ctx, acPlainText, (uint8_t *) acCypherText);
+#endif
+
+#ifdef KAT_DEBUG
+ ConvertBinaryToUTF8HexString(sComputedCypherText,
+ acCypherText,
+ strlen(i_sPlainText) / 2);
+ printf("PlainText=%s\n", i_sPlainText);
+ printf("CypherText=%s\n", sComputedCypherText);
+#endif
+
+ if (memcmp(acCypherText, acKnownCypherText, strlen(i_sKnownCypherText) / 2) != 0)
+ {
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+ free(ks);
+#endif
+ return -1;
+ }
+
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+ aes_init_keysched(i_pKey, AES_MAXKEYBITS, ks);
+ (void) aes_decrypt_block(ks, acCypherText, acDecryptedCypherText);
+ free(ks);
+#else
+ rijndael_set_key(&ctx, (uint8_t *) i_pKey, AES_MAXKEYBITS);
+ rijndael_decrypt(&ctx, (uint8_t *) acCypherText, acDecryptedCypherText);
+#endif
+
+ if (memcmp(acPlainText, acDecryptedCypherText, strlen(i_sPlainText) / 2) != 0)
+ {
+ return -1;
+ }
+
+ return 0;
+
+}
+
+static int KnownAnswerTestAESECB_GFSbox (void)
+{
+ /*
+ * Test Vectors from AES Algorithm Validation Suite(AESAVS)
+ */
+ unsigned char acKey[AES_MAXKEYBYTES];
+ memset(acKey, 0, sizeof (acKey));
+
+ /*
+ # CAVS 6.1
+ # Config info for Sun 1820 AES
+ # AESVS GFSbox test data for ECB
+ # State : Encrypt and Decrypt
+ # Key Length : 256
+ # Generated on Wed Aug 13 13:39:06 2008
+ */
+ const size_t GFSboxCount = 5;
+ static char sPlainText[GFSboxCount][33];
+ static char sKnownCypherText[GFSboxCount][33];
+ strcpy(sPlainText[0], "014730f80ac625fe84f026c60bfd547d");
+ strcpy(sPlainText[1], "0b24af36193ce4665f2825d7b4749c98");
+ strcpy(sPlainText[2], "761c1fe41a18acf20d241650611d90f1");
+ strcpy(sPlainText[3], "8a560769d605868ad80d819bdba03771");
+ strcpy(sPlainText[4], "91fbef2d15a97816060bee1feaa49afe");
+
+ strcpy(sKnownCypherText[0], "5c9d844ed46f9885085e5d6a4f94c7d7");
+ strcpy(sKnownCypherText[1], "a9ff75bd7cf6613d3731c77c3b6d0c04");
+ strcpy(sKnownCypherText[2], "623a52fcea5d443e48d9181ab32c7421" );
+ strcpy(sKnownCypherText[3], "38f2c7ae10612415d27ca190d27da8b4" );
+ strcpy(sKnownCypherText[4], "1bc704f1bce135ceb810341b216d7abe" );
+
+
+ for (size_t i = 0; i < GFSboxCount; i++)
+ {
+ if (AES_ECB_TestExecution(sPlainText[i], sKnownCypherText[i], acKey) != 0)
+ {
+#ifdef KAT_DEBUG
+ printf("GFSbox[%d]: failed\n", i);
+#endif
+ return -1;
+ }
+#ifdef KAT_DEBUG
+ printf("GFSbox[%d]: passed\n", i);
+#endif
+ }
+ return 0;
+}
+
+static int KnownAnswerTestAESECB_KeySbox (void)
+{
+ unsigned char acKey[AES_MAXKEYBYTES];
+ memset(acKey, 0, sizeof (acKey));
+
+ /*
+ # CAVS 6.1
+ # Config info for Sun 1820 AES
+ # AESVS KeySbox test data for ECB
+ # State : Encrypt and Decrypt
+ # Key Length : 256
+ # Generated on Wed Aug 13 13:39:07 2008
+ */
+ const size_t KeySboxCount = 16;
+ static char sKey[KeySboxCount][65];
+ static char sKnownCypherText[KeySboxCount][33];
+ static char sPlainText[] = "00000000000000000000000000000000";
+
+ strcpy(sKey[0], "c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558");
+ strcpy(sKey[1], "28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64");
+ strcpy(sKey[2], "c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c");
+ strcpy(sKey[3], "984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627");
+ strcpy(sKey[4], "b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f");
+ strcpy(sKey[5], "1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9");
+ strcpy(sKey[6], "dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf");
+ strcpy(sKey[7], "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9");
+ strcpy(sKey[8], "797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e");
+ strcpy(sKey[9], "6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707");
+ strcpy(sKey[10], "ccd1bc3c659cd3c59bc437484e3c5c724441da8d6e90ce556cd57d0752663bbc");
+ strcpy(sKey[11], "13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887");
+ strcpy(sKey[12], "07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee");
+ strcpy(sKey[13], "90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1");
+ strcpy(sKey[14], "b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07");
+ strcpy(sKey[15], "fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e");
+ strcpy(sKnownCypherText[0], "46f2fb342d6f0ab477476fc501242c5f");
+ strcpy(sKnownCypherText[1], "4bf3b0a69aeb6657794f2901b1440ad4");
+ strcpy(sKnownCypherText[2], "352065272169abf9856843927d0674fd");
+ strcpy(sKnownCypherText[3], "4307456a9e67813b452e15fa8fffe398");
+ strcpy(sKnownCypherText[4], "4663446607354989477a5c6f0f007ef4");
+ strcpy(sKnownCypherText[5], "531c2c38344578b84d50b3c917bbb6e1");
+ strcpy(sKnownCypherText[6], "fc6aec906323480005c58e7e1ab004ad");
+ strcpy(sKnownCypherText[7], "a3944b95ca0b52043584ef02151926a8");
+ strcpy(sKnownCypherText[8], "a74289fe73a4c123ca189ea1e1b49ad5");
+ strcpy(sKnownCypherText[9], "b91d4ea4488644b56cf0812fa7fcf5fc");
+ strcpy(sKnownCypherText[10], "304f81ab61a80c2e743b94d5002a126b");
+ strcpy(sKnownCypherText[11], "649a71545378c783e368c9ade7114f6c");
+ strcpy(sKnownCypherText[12], "47cb030da2ab051dfc6c4bf6910d12bb");
+ strcpy(sKnownCypherText[13], "798c7c005dee432b2c8ea5dfa381ecc3");
+ strcpy(sKnownCypherText[14], "637c31dc2591a07636f646b72daabbe7");
+ strcpy(sKnownCypherText[15], "179a49c712154bbffbe6e7a84a18e220");
+
+ for (size_t i = 0; i < KeySboxCount; i++)
+ {
+#ifdef KAT_DEBUG
+ printf("KeySbox[%d]: \n", i);
+#endif
+ unsigned char acKey[256];
+ if ((size_t) ConvertUTF8HexStringToBinary(
+ sKey[i],
+ acKey) != strlen(sKey[i]) / 2)
+ {
+#ifdef KAT_DEBUG
+ printf("KeySbox[%d]: failed hex to binary conversion\n", i);
+#endif
+ return -1;
+ }
+ if (AES_ECB_TestExecution(sPlainText, sKnownCypherText[i], acKey) != 0)
+ {
+#ifdef KAT_DEBUG
+ printf("KeySbox[%d]: failed test\n", i);
+#endif
+ return -1;
+ }
+#ifdef KAT_DEBUG
+ printf("KeySbox[%d]: passed\n", i);
+#endif
+ }
+ return 0;
+}
+
+int KnownAnswerTestHMACSHA1 (void)
+{
+ /* Test Data from RFC2202 */
+ const static char sKey[] = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";
+ unsigned char acKey[HMAC_LENGTH];
+ const static char sPlainText[] = "Hi There";
+ const static char sCypherText[] = "b617318655057264e28bc0b6fb378c8ef146be00";
+ const unsigned char* aBuffersToHMAC[1];
+ int aBuffersToHMACSize[1];
+ unsigned char acCypherText[HMAC_LENGTH];
+ unsigned char acComputedCypherText[HMAC_LENGTH];
+ if ((size_t) ConvertUTF8HexStringToBinary(
+ sKey,
+ acKey) != sizeof (acKey))
+ {
+#ifdef KAT_DEBUG
+ printf("HMAC-SHA1: failed hex to binary conversion for Key\n");
+#endif
+ return -1;
+ }
+ if ((size_t) ConvertUTF8HexStringToBinary(
+ sCypherText,
+ acCypherText) != sizeof (acCypherText))
+ {
+#ifdef KAT_DEBUG
+ printf("HMAC-SHA1: failed hex to binary conversion for CypherText\n");
+#endif
+ return -1;
+ }
+
+ aBuffersToHMAC[0] = (unsigned char *) sPlainText;
+ aBuffersToHMACSize[0] = strlen(sPlainText);
+
+ if (!HMACBuffers(
+ 1,
+ aBuffersToHMAC,
+ aBuffersToHMACSize,
+ acKey,
+ sizeof (acKey),
+ acComputedCypherText))
+ {
+#ifdef KAT_DEBUG
+ printf("HMAC-SHA1: failed in HMACBuffers\n");
+#endif
+ return -1;
+ }
+ if (memcmp(acCypherText, acComputedCypherText, sizeof (acCypherText)) != 0)
+ {
+#ifdef KAT_DEBUG
+ printf("HMAC-SHA1: failed comparison with expected cycphertext\n");
+#endif
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int KnownAnswerTestAESECB (void)
+{
+ if (KnownAnswerTestAESECB_GFSbox() != 0)
+ {
+#ifdef KAT_DEBUG
+ printf("GFSbox: test suite failed\n");
+#endif
+ return -1;
+ }
+
+ if (KnownAnswerTestAESECB_KeySbox() != 0)
+ {
+#ifdef KAT_DEBUG
+ printf("KeySbox: test suite failed\n");
+#endif
+ return -1;
+ }
+
+ return 0;
+}
+
+#ifdef STAND_ALONE_TEST
+
+int main ()
+{
+ // Known Answer Test on AES Key Wrap code
+ if (KnownAnswerTestAESKeyWrap() != 0)
+ {
+ return -1;
+ }
+
+ if (KnownAnswerTestAESECB() != 0)
+ {
+ return -1;
+ }
+
+ if (KnownAnswerTestHMACSHA1() != 0)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.h b/usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.h
new file mode 100644
index 0000000000..1d5f7c4fe1
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentKnownAnswerTests.h
@@ -0,0 +1,63 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/** @file KMSAgent.h
+ * @defgroup EncryptionAgent Encryption Agent API
+ *
+ * The Agent API is used to communicate with the KMS Appliance for the
+ * purpose of registering storage devices, obtaining device keys, and
+ * receiving notifications of storage device events such as destruction.
+ *
+ */
+#ifndef KMS_AGENT_KNOWN_ANSWER_TESTS_H
+#define KMS_AGENT_KNOWN_ANSWER_TESTS_H
+
+/**
+ * This function exercises both <code>aes_key_wrap</code> and <code>aes_key_unwrap</code>
+ * in order to satisfy a FIPS 140-2 requirement for a known answer test, aka KAT. Test
+ * vectors from RFC 3394 are used for this test.
+ * @return 0 on success, non-zero otherwise
+ */
+int KnownAnswerTestAESKeyWrap(void);
+
+/**
+ * This function exercises both <code>rijndael_encrypt</code> and <code>rijndael_decrypt</code>
+ * in order to satisfy a FIPS 140-2 requirement for a known answer test, aka KAT. Test
+ * vectors from Infoguard are used for this test.
+ * @return 0 if KAT passed, non-zero otherwise
+ */
+int KnownAnswerTestAESECB(void);
+
+/**
+ * This function exercises #HMACBuffers
+ * in order to satisfy a FIPS 140-2 requirement for a known answer test, aka KAT. Test
+ * vectors from Infoguard are used for this test.
+ * @return 0 if KAT passed, non-zero otherwise
+ */
+int KnownAnswerTestHMACSHA1(void);
+
+#endif
+
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.cpp b/usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.cpp
new file mode 100644
index 0000000000..9f2c8dcf49
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.cpp
@@ -0,0 +1,1169 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentLoadBalancer.cpp
+ */
+
+#ifdef WIN32
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+#include <process.h>
+#endif
+
+#include <stdlib.h>
+
+#include "KMS_AgentH.h"
+#include "KMSClientProfile.h"
+#include "KMSAgentSoapUtilities.h"
+#include "KMSAgentStringUtilities.h"
+#include "KMSClientProfileImpl.h"
+#include "KMSAgent.h"
+#include "KMSAuditLogger.h"
+#include "ApplianceParameters.h"
+#include "KMSAgentCryptoUtilities.h"
+
+#ifdef METAWARE
+#include "debug.h"
+#include "sizet.h"
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#endif
+#include "KMSAgentAESKeyWrap.h"
+
+#ifdef METAWARE
+#include "stdsoap2.h" /* makes fewer platform assumptions
+ than the standard stdsoap2.h */
+
+int time (char *);
+#include "literals.h"
+#else
+#include "stdsoap2.h"
+#endif
+
+#include "AutoMutex.h"
+
+// real declaration of soap *
+#include "KMSAgentDataUnitCache.h"
+
+#include "ClientSoapFaultCodes.h"
+#include "KMSAgentPKICommon.h"
+#include "KMSAgentLoadBalancer.h" // needs to be after stdsoap2.h to use the
+
+CAgentLoadBalancer::CAgentLoadBalancer (KMSClientProfile * const i_pProfile)
+: m_pProfile (i_pProfile),
+m_iTransactionStartTimeInMilliseconds (0),
+m_bFIPS (false),
+m_iKWKEntryNum (0),
+m_iLastAttemptedWhenNoneResponding (0)
+{
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) m_pProfile->m_pLock);
+
+ // initialize the aCluster, let it contain the default appliance
+ m_iClusterNum = 1;
+ memset(&(m_aCluster[0]), 0, sizeof (KMSClusterEntry));
+ strncpy(m_aCluster[0].m_wsApplianceNetworkAddress,
+ i_pProfile->m_wsApplianceAddress,
+ sizeof(m_aCluster[0].m_wsApplianceNetworkAddress));
+ m_aCluster[0].m_wsApplianceNetworkAddress[sizeof(m_aCluster[0].m_wsApplianceNetworkAddress)-1] = '\0';
+
+ // This may not be known because the initial
+ // appliance's Alias is not yet entered.
+ strcpy(m_aCluster[0].m_wsApplianceAlias, "");
+ strcpy(m_sURL, "");
+ memset(m_aKWKEntries, 0, KMS_MAX_CLUSTER_NUM * sizeof(struct KWKEntry *));
+}
+
+CAgentLoadBalancer::~CAgentLoadBalancer ()
+{
+ // free up KWK entries
+ for( int i=0; i < m_iKWKEntryNum && i < KMS_MAX_CLUSTER_NUM; i++)
+ {
+ if (m_aKWKEntries[i] != NULL)
+ {
+ delete m_aKWKEntries[i];
+ }
+ }
+ return;
+}
+
+char *CAgentLoadBalancer::GetHTTPSURL (int i_iIndex, int i_iPort)
+{
+ if (i_iIndex < 0 || i_iIndex >= m_iClusterNum)
+ {
+ strcpy(m_sURL, "");
+ }
+ else
+ {
+ K_snprintf(m_sURL, KMS_MAX_URL, "https://%s:%d",
+ m_aCluster[i_iIndex].m_wsApplianceNetworkAddress,
+ i_iPort);
+ }
+
+ return m_sURL;
+}
+
+char *CAgentLoadBalancer::GetHTTPURL (int i_iIndex, int i_iPort)
+{
+ if (i_iIndex < 0 || i_iIndex >= m_iClusterNum)
+ {
+ strcpy(m_sURL, "");
+ }
+ else
+ {
+ K_snprintf(m_sURL, KMS_MAX_URL, "http://%s:%d",
+ m_aCluster[i_iIndex].m_wsApplianceNetworkAddress,
+ i_iPort);
+ }
+
+ return m_sURL;
+}
+
+int CAgentLoadBalancer::Balance ()
+{
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) m_pProfile->m_pLock);
+
+ int i;
+ unsigned int iSelected = 0;
+ unsigned int iSelected2 = 0;
+
+ // clear the failover attempts
+ m_pProfile->m_iFailoverAttempts = 0;
+
+ // This assumes Balance()/BalanceBy...() are called at the top of
+ // each Agent Library transaction
+ // m_iTransactionStartTimeInMilliseconds is used to determine if
+ // enough time remains
+ // (vs. KMSClientProfile::m_iTransactionTimeout) to retry a
+ // request if there was a Server Busy error.
+
+ m_iTransactionStartTimeInMilliseconds = K_GetTickCount();
+
+ // if not enabling load balancing, return the default appliance & if
+ // its FIPS compatible when running in FIPS_MODE
+
+ if (m_pProfile->m_iClusterDiscoveryFrequency == 0)
+ {
+ if (m_bFIPS && !FIPScompatibleKMA(m_aCluster[0].m_sKMAVersion))
+ {
+ return NO_FIPS_KMA_AVAILABLE;
+ }
+ return 0;
+ }
+
+ int iCurrentTime = K_GetTickCount() / 1000;
+
+ // if it is the first time or time to get cluster information
+ if ((!m_pProfile->m_bIsClusterDiscoveryCalled) ||
+ ((iCurrentTime - m_pProfile->m_iLastClusterDiscoveryTime) >
+ m_pProfile->m_iClusterDiscoveryFrequency))
+ {
+ if (!KMSClient_GetClusterInformation(m_pProfile,
+ m_pProfile->m_wsEntitySiteID,
+ sizeof (m_pProfile->m_wsEntitySiteID),
+ &(m_pProfile->m_iClusterNum),
+ m_pProfile->m_aCluster,
+ KMS_MAX_CLUSTER_NUM))
+ {
+ // if failed due to some error, return default one
+ // KMSClient_GetClusterInformation logs
+
+ return 0;
+ }
+
+ m_pProfile->m_bIsClusterDiscoveryCalled = true;
+
+ // Reset the transaction start time to not include the time spent
+ // calling KMSClient_GetClusterInformation.
+
+ m_iTransactionStartTimeInMilliseconds = K_GetTickCount();
+
+ // reset this index since cluster size may have changed
+ m_iLastAttemptedWhenNoneResponding = 0;
+
+ // TODO: Adjust timeouts to guarentee a response to the Agent
+ // Library called in m_iTransactionTimeout seconds? This means
+ // not adjusting m_iTransactionStartTimeInMilliseconds, but also
+ // reducing socket timeouts for subsequent calls.
+ }
+
+ // sort the cluster array by Load
+
+ KMSClient_SortClusterArray(m_pProfile);
+
+ // copy all Appliances to this object
+
+ for (i = 0; i < m_pProfile->m_iClusterNum; i++)
+ {
+ m_aCluster[i] = m_pProfile->m_aCluster[i];
+ }
+
+ m_iClusterNum = m_pProfile->m_iClusterNum;
+
+ int iCandidateAppliances = 0;
+
+ // the initial set of candidates for load balancing are all enabled,
+ // responding and unlocked KMAs (assumes they are at the top of the sort
+ // order) & FIPS compatible if we're in that mode
+
+ for (i = 0; i < m_iClusterNum; i++)
+ {
+ if ((m_aCluster[i].m_iResponding == TRUE) &&
+ (m_aCluster[i].m_iEnabled == TRUE ) &&
+ (m_aCluster[i].m_iKMALocked == FALSE))
+ {
+ iCandidateAppliances++;
+ }
+ }
+
+ // check if there are any enabled and responding Appliances in the
+ // same site as this Agent, and if so make those the candidates
+ // (assumes they are at the top of the sort order)
+
+ int iCandidateAppliancesInSameSite = 0;
+
+ if (strlen(m_pProfile->m_wsEntitySiteID) > 0)
+ {
+ for (i = 0; i < iCandidateAppliances; i++)
+ {
+ if (strncmp(m_aCluster[i].m_wsApplianceSiteID,
+ m_pProfile->m_wsEntitySiteID,
+ sizeof(m_aCluster[i].m_wsApplianceSiteID)) == 0)
+ {
+ iCandidateAppliancesInSameSite++;
+ }
+ }
+ }
+
+ // reduce the candidate set to just KMAs within the site
+ if (iCandidateAppliancesInSameSite > 0)
+ {
+ iCandidateAppliances = iCandidateAppliancesInSameSite;
+ }
+
+ // constrain the candidate set to just FIPS compatible KMAs
+ if (m_bFIPS)
+ {
+ int iCandidateFIPSKMAs = 0;
+
+ for (i = 0; i < iCandidateAppliances; i++)
+ {
+ if ( FIPScompatibleKMA(m_aCluster[i].m_sKMAVersion ))
+ {
+ iCandidateFIPSKMAs++;
+ }
+ }
+
+ // select only from FIPS capable KMAs
+ iCandidateAppliances = iCandidateFIPSKMAs;
+ }
+
+ // if there are no candidate Appliances, use the default Appliance unless
+ // we're in FIPS mode
+
+ if (!m_bFIPS && iCandidateAppliances <= 1)
+ {
+ return 0;
+ }
+
+ // FIPS mode
+ else if (iCandidateAppliances <= 0)
+ {
+ return NO_FIPS_KMA_AVAILABLE;
+ }
+ else if (iCandidateAppliances == 1)
+ {
+ return 0;
+ }
+
+ // randomly select two candidate Appliances and select the one
+ // with the smaller load
+
+ // choose one random number between 0 -- iCandidateAppliances - 1
+ iSelected = rand() % iCandidateAppliances;
+ iSelected2 = (iSelected + 1) % iCandidateAppliances;
+
+ // select the one with the smaller load
+
+ if (m_aCluster[iSelected2].m_lLoad < m_aCluster[iSelected].m_lLoad)
+ {
+ iSelected = iSelected2;
+ }
+
+ return iSelected;
+}
+
+int CAgentLoadBalancer::BalanceByDataUnitID (
+ const unsigned char * const i_pDataUnitID,
+ int i_iDataUnitIDMaxLen)
+{
+ FATAL_ASSERT(i_pDataUnitID);
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) m_pProfile->m_pLock);
+
+ // clear the failover attempts
+ m_pProfile->m_iFailoverAttempts = 0;
+
+ // This assumes Balance(), or BalanceBy...(),
+ // is called at the top of each Agent Library transaction
+ // m_iTransactionStartTimeInMilliseconds is used to determine if enough time remains
+ // (vs. KMSClientProfile::m_iTransactionTimeout) to retry a request if there was
+ // a Server Busy error.
+
+ m_iTransactionStartTimeInMilliseconds = K_GetTickCount();
+
+ // look in cache
+
+ CDataUnitCache *pDataUnitCache = (CDataUnitCache *) m_pProfile->m_pDataUnitCache;
+
+ // if not enabling load balancing, return the default appliance & if
+ // its FIPS compatible when running in FIPS_MODE
+
+ if (m_pProfile->m_iClusterDiscoveryFrequency == 0)
+ {
+ if (m_bFIPS && !FIPScompatibleKMA(m_aCluster[0].m_sKMAVersion))
+ {
+ return NO_FIPS_KMA_AVAILABLE;
+ }
+ return 0;
+ }
+
+ // if the Data Unit ID is in the server affinity cache, use that Appliance
+
+ utf8char wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS];
+ int iIndex = CLIENT_SIDE_ERROR;
+
+ if (pDataUnitCache->GetApplianceByDataUnitID(
+ i_pDataUnitID,
+ i_iDataUnitIDMaxLen,
+ wsApplianceNetworkAddress,
+ sizeof(wsApplianceNetworkAddress)))
+ {
+ iIndex = FindIndexByNetworkAddress(wsApplianceNetworkAddress);
+ }
+
+ if (iIndex != CLIENT_SIDE_ERROR)
+ {
+ if (m_bFIPS && !FIPScompatibleKMA(m_aCluster[iIndex].m_sKMAVersion))
+ {
+ // in spite of caching we need to attempt an alternate KMA due
+ // to the FIPS mode setting
+ return Balance();
+ }
+ return iIndex;
+ }
+
+ // normal balancing
+ return Balance();
+}
+
+int CAgentLoadBalancer::BalanceByDataUnitKeyID (
+ const unsigned char * const i_pDataUnitKeyID,
+ int i_iDataUnitKeyIDMaxLen)
+{
+ FATAL_ASSERT(i_pDataUnitKeyID);
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) m_pProfile->m_pLock);
+
+ // clear the failover attempts
+ m_pProfile->m_iFailoverAttempts = 0;
+
+ // This assumes Balance()/BalanceBy...()
+ // are called at the top of each Agent Library transaction
+ // m_iTransactionStartTimeInMilliseconds is used to determine if enough time remains
+ // (vs. KMSClientProfile::m_iTransactionTimeout) to retry a request if there was
+ // a Server Busy error.
+
+ m_iTransactionStartTimeInMilliseconds = K_GetTickCount();
+
+ // look in cache
+
+ CDataUnitCache *pDataUnitCache = (CDataUnitCache *) m_pProfile->m_pDataUnitCache;
+
+ // if not enabling load balancing, return the default appliance & if
+ // its FIPS compatible when running in FIPS_MODE
+
+ if (m_pProfile->m_iClusterDiscoveryFrequency == 0)
+ {
+ if (m_bFIPS && !FIPScompatibleKMA(m_aCluster[0].m_sKMAVersion))
+ {
+ return NO_FIPS_KMA_AVAILABLE;
+ }
+ return 0;
+ }
+
+ // if the Data Unit Key ID is in the server affinity cache, use that Appliance
+
+ utf8char sApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS];
+ int iIndex = CLIENT_SIDE_ERROR;
+
+ if (pDataUnitCache->GetApplianceByDataUnitKeyID(
+ i_pDataUnitKeyID,
+ i_iDataUnitKeyIDMaxLen,
+ sApplianceNetworkAddress,
+ sizeof(sApplianceNetworkAddress)))
+ {
+ iIndex = FindIndexByNetworkAddress(sApplianceNetworkAddress);
+ }
+
+ if (iIndex != CLIENT_SIDE_ERROR)
+ {
+ if (m_bFIPS && !FIPScompatibleKMA(m_aCluster[iIndex].m_sKMAVersion))
+ {
+ // in spite of caching we need to attempt an alternate KMA due
+ // to the FIPS mode setting
+ return Balance();
+ }
+ return iIndex;
+ }
+
+ // normal balancing
+ return Balance();
+}
+
+int CAgentLoadBalancer::FindIndexByNetworkAddress
+(char * i_wsApplianceNetworkAddress)
+{
+ FATAL_ASSERT(i_wsApplianceNetworkAddress);
+
+ for (int i = 0; i < m_iClusterNum; i++)
+ {
+
+ if ((strncmp(m_aCluster[i].m_wsApplianceNetworkAddress,
+ i_wsApplianceNetworkAddress,
+ sizeof(m_aCluster[i].m_wsApplianceNetworkAddress)) == 0) &&
+ m_aCluster[i].m_iEnabled == TRUE &&
+ m_aCluster[i].m_iResponding == TRUE)
+ {
+ return i;
+ }
+
+ }
+
+ return CLIENT_SIDE_ERROR;
+}
+
+char* CAgentLoadBalancer::GetApplianceNetworkAddress (int i_iIndex)
+{
+ if (i_iIndex < 0 || i_iIndex >= m_iClusterNum)
+ {
+ return (char *)"";
+ }
+
+ return m_aCluster[i_iIndex].m_wsApplianceNetworkAddress;
+}
+
+bool CAgentLoadBalancer::FailOverLimit (void)
+{
+ if (m_pProfile->m_iFailoverLimit >= 0 &&
+ m_pProfile->m_iFailoverAttempts > m_pProfile->m_iFailoverLimit)
+ return true;
+ else
+ return false;
+}
+
+int CAgentLoadBalancer::FailOver (int i_iFailedApplianceIndex,
+ struct soap *i_pstSoap)
+{
+ FATAL_ASSERT(i_pstSoap);
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) m_pProfile->m_pLock);
+
+ const char *strError = GET_SOAP_FAULTSTRING(i_pstSoap);
+ int iSoapErrno = i_pstSoap->errnum;
+ int iErrorCode = GET_FAULT_CODE(strError);
+ int i;
+
+ if ( m_bFIPS &&
+ KMSClient_NoFIPSCompatibleKMAs(m_pProfile))
+ {
+ return NO_FIPS_KMA_AVAILABLE;
+ }
+
+ m_pProfile->m_iFailoverAttempts++;
+
+ /*
+ * if KWK is not registered, or mismatched, most likely KMA lost its key due to a service
+ * restart. Call RegisterKWK to re-register the KWK.
+ * If RegisterKWK fails proceed from here with new failover info
+ */
+ if ( iErrorCode == CLIENT_ERROR_AGENT_KWK_NOT_REGISTERED ||
+ iErrorCode == CLIENT_ERROR_AGENT_KWK_ID_MISMATCH )
+ {
+ LogError(m_pProfile,
+ AGENT_LOADBALANCER_FAILOVER,
+ NULL,
+ m_aCluster[i_iFailedApplianceIndex].m_wsApplianceNetworkAddress,
+ "KWK not registered or ID mismatch - registering");
+ // delete the KWK entry since the KMA no longer has it
+ DeleteKWKEntry( GetKMAID(i_iFailedApplianceIndex));
+
+ return i_iFailedApplianceIndex;
+ }
+
+ bool bServerError = false;
+
+ // if the request failed due to a Server Busy error, and if
+ // - transaction timeout has not been exceeded OR
+ // - failover attempts remain
+ // then failover
+
+ if (iErrorCode == CLIENT_ERROR_SERVER_BUSY &&
+ (K_GetTickCount() < m_iTransactionStartTimeInMilliseconds + (m_pProfile->m_iTransactionTimeout * 1000) ||
+ !CAgentLoadBalancer::FailOverLimit()))
+ {
+ LogError(m_pProfile,
+ AGENT_LOADBALANCER_FAILOVER,
+ NULL,
+ m_aCluster[i_iFailedApplianceIndex].m_wsApplianceNetworkAddress,
+ "Server Busy - failing over");
+ bServerError = true;
+ }
+ else if (ServerError(strError,iSoapErrno))
+ {
+ bServerError = true;
+ }
+ else
+ {
+ if (i_iFailedApplianceIndex == AES_KEY_WRAP_SETUP_ERROR)
+ {
+ return AES_KEY_WRAP_SETUP_ERROR;
+ }
+ else
+ {
+ return CLIENT_SIDE_ERROR; // it is a client side problem, don't fail over
+ }
+ }
+
+ // disable the failed Appliance in the profile, and
+ // re-sort the cluster array, so transactions in other threads
+ // will not send requests to the same failed Appliance
+#if defined(METAWARE)
+ log_cond_printf(ECPT_LOG_AGENT, "CAgentLoadBalancer::Failover(): FailoverAttempts=%d\n",
+ m_pProfile->m_iFailoverAttempts);
+#endif
+ for (i = 0; i < m_pProfile->m_iClusterNum; i++)
+ {
+ if (m_pProfile->m_aCluster[i].m_lApplianceID ==
+ m_aCluster[i_iFailedApplianceIndex].m_lApplianceID)
+ {
+ m_pProfile->m_aCluster[i].m_iResponding = FALSE;
+ break;
+ }
+ }
+
+ KMSClient_SortClusterArray(m_pProfile);
+
+ // mark the failed Appliance as not responding (unlike the case
+ // above which is conditional on bServerError, this marking is
+ // only local to this transaction; it must be done to ensure that
+ // this transaction does not cycle in its fail-over loop.)
+
+ m_aCluster[i_iFailedApplianceIndex].m_iResponding = FALSE;
+
+ if (!CAgentLoadBalancer::FailOverLimit())
+ {
+ // now try to fail over to all other Appliances that are
+ // apparently enabled and responding
+
+ for (i = 0; i < m_iClusterNum; i++)
+ {
+ if (m_aCluster[i].m_iEnabled == TRUE &&
+ m_aCluster[i].m_iResponding == TRUE &&
+ m_aCluster[i].m_iKMALocked == FALSE)
+ {
+ Log(AGENT_LOADBALANCER_FAILOVER,
+ NULL,
+ m_aCluster[i].m_wsApplianceNetworkAddress,
+ "Failing over to this addr");
+
+ return i;
+ }
+ }
+
+ // now retry KMAs previously reported as not responding
+
+ m_iLastAttemptedWhenNoneResponding++;
+
+ if (m_iLastAttemptedWhenNoneResponding >= m_iClusterNum)
+ {
+ m_iLastAttemptedWhenNoneResponding = m_iLastAttemptedWhenNoneResponding % m_iClusterNum;
+ }
+
+ Log(AGENT_LOADBALANCER_FAILOVER,
+ NULL,
+ m_aCluster[m_iLastAttemptedWhenNoneResponding].m_wsApplianceNetworkAddress,
+ "Failing over to retry this addr");
+
+ return m_iLastAttemptedWhenNoneResponding;
+ }
+ else
+ {
+ Log(AGENT_LOADBALANCER_FAILOVER,
+ NULL,
+ NULL,
+ "Failover limit reached");
+ }
+
+ return m_bFIPS ? NO_FIPS_KMA_AVAILABLE : NO_KMA_AVAILABLE;
+}
+
+void CAgentLoadBalancer::UpdateResponseStatus(int i_iIndex)
+{
+ bool bStatusChanged = false;
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) m_pProfile->m_pLock);
+
+ // enable the responding Appliance in the profile, and
+ // re-sort the cluster array, so transactions in other threads
+ // will not send requests to the same failed Appliance
+
+ for (int i = 0; i < m_pProfile->m_iClusterNum; i++)
+ {
+ if (m_pProfile->m_aCluster[i].m_lApplianceID ==
+ m_aCluster[i_iIndex].m_lApplianceID)
+ {
+ if (m_pProfile->m_aCluster[i].m_iResponding == FALSE)
+ {
+ bStatusChanged = true;
+ }
+ m_pProfile->m_aCluster[i].m_iResponding = TRUE;
+ break;
+ }
+ }
+
+ // only resort if the responding status actually changed
+ if (bStatusChanged)
+ {
+ KMSClient_SortClusterArray(m_pProfile);
+ }
+
+ // mark the Appliance as now responding
+ m_aCluster[i_iIndex].m_iResponding = TRUE;
+
+ return;
+}
+
+Long64 CAgentLoadBalancer::GetKMAID (
+ int i_iIndex)
+{
+ if (i_iIndex < 0 || i_iIndex >= m_iClusterNum)
+ {
+ return -1;
+ }
+
+ return m_aCluster[i_iIndex].m_lApplianceID;
+}
+
+CAgentLoadBalancer::KWKEntry *CAgentLoadBalancer::GetKWK (
+ Long64 i_lKMAID)
+{
+ if (i_lKMAID == -1)
+ {
+ return NULL;
+ }
+
+ for (int i = 0; i < m_iKWKEntryNum && i < KMS_MAX_CLUSTER_NUM; i++)
+ {
+ if (m_aKWKEntries[i] != NULL &&
+ m_aKWKEntries[i]->m_lKMAID == i_lKMAID )
+ {
+ return m_aKWKEntries[i];
+ }
+ }
+
+ return NULL;
+}
+
+CAgentLoadBalancer::KWKEntry *CAgentLoadBalancer::CreateKWK (
+ Long64 i_lKMAID,
+ struct soap * const i_pstSoap,
+ const char * const i_sURL,
+ bool * const o_pbClientAESKeyWrapSetupError)
+{
+ FATAL_ASSERT(i_pstSoap);
+ FATAL_ASSERT(i_sURL);
+
+ int bSuccess = FALSE;
+ KWKEntry *oKWKEntry = new KWKEntry;
+
+ oKWKEntry->m_lKMAID = i_lKMAID;
+ *o_pbClientAESKeyWrapSetupError = false;
+
+ bSuccess = GetPseudorandomBytes(sizeof (oKWKEntry->m_acKWK),
+ oKWKEntry->m_acKWK);
+ if (!bSuccess)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_KWK_RNG_ERROR,
+ NULL,
+ NULL,
+ "Error from RNG");
+ *o_pbClientAESKeyWrapSetupError = true;
+ delete(oKWKEntry);
+ return NULL;
+ }
+
+#if defined(DEBUG)
+ char sHexKWK[2*KMS_MAX_KEY_SIZE+1];
+ ConvertBinaryToUTF8HexString( sHexKWK, oKWKEntry->m_acKWK, sizeof (oKWKEntry->m_acKWK));
+#if defined(METAWARE)
+ log_printf("CAgentLoadBalancer::CreateKWK(): KWK hex=%s\n",
+ sHexKWK);
+#else
+// printf("CAgentLoadBalancer::CreateKWK(): KWK hex=%s\n",
+// sHexKWK);
+#endif
+#endif
+
+ CPublicKey oPublicKEK;
+
+ bSuccess = GetKWKWrappingKey(i_pstSoap, i_sURL, &oPublicKEK);
+
+ if (!bSuccess)
+ {
+ // GetKWKWrappingKey logs errors
+
+ if (!ServerError(GET_SOAP_FAULTSTRING(i_pstSoap),i_pstSoap->errnum))
+ {
+ *o_pbClientAESKeyWrapSetupError = true;
+ }
+ delete(oKWKEntry);
+ return NULL;
+ }
+
+ unsigned char acWrappedKWK[MAX_RSA_PUB_KEY_LENGTH];
+ int iWrappedKWKLength;
+ bSuccess = oPublicKEK.Encrypt(sizeof (oKWKEntry->m_acKWK),
+ oKWKEntry->m_acKWK, (unsigned char *) acWrappedKWK, &iWrappedKWKLength);
+
+ if (!bSuccess)
+ {
+ Log(AUDIT_CLIENT_AGENT_CREATE_KWK_PUBLIC_ENCRYPT_ERROR,
+ NULL,
+ NULL,
+ "Error encrypting KWK with KMA public key");
+ *o_pbClientAESKeyWrapSetupError = true;
+ delete(oKWKEntry);
+ return NULL;
+ }
+//#if defined(DEBUG) && !defined(METAWARE)
+// char sHexWrappedKWK[2*MAX_RSA_PUB_KEY_LENGTH+1];
+// ConvertBinaryToUTF8HexString( sHexWrappedKWK, acWrappedKWK, iWrappedKWKLength);
+// printf("CAgentLoadBalancer::CreateKWK(): wrapped KWK hex=%s\n",
+// sHexWrappedKWK);
+//#endif
+
+ // register the new KWK
+ bSuccess = RegisterKWK(iWrappedKWKLength, acWrappedKWK, i_pstSoap,
+ i_sURL, oKWKEntry->m_acKWKID);
+
+ if (!bSuccess)
+ {
+ // RegisterKWK logs errors
+ if (!ServerError(GET_SOAP_FAULTSTRING(i_pstSoap), i_pstSoap->error))
+ {
+ *o_pbClientAESKeyWrapSetupError = true;
+ }
+ delete(oKWKEntry);
+ return NULL;
+ }
+
+ // save the new KWK entry in an empty slot in the array
+ for (int i=0; i < m_iKWKEntryNum && i < KMS_MAX_CLUSTER_NUM; i++)
+ {
+ if (m_aKWKEntries[i] == NULL)
+ {
+ m_aKWKEntries[i] = oKWKEntry;
+ return oKWKEntry;
+ }
+ }
+
+ // no empty slots so add it to the end
+ m_aKWKEntries[m_iKWKEntryNum++] = oKWKEntry;
+
+ return oKWKEntry;
+}
+
+void CAgentLoadBalancer::DeleteKWKEntry(Long64 i_lKMAID)
+{
+ for (int i=0; i < m_iKWKEntryNum && i < KMS_MAX_CLUSTER_NUM; i++)
+ {
+ if (m_aKWKEntries[i] && m_aKWKEntries[i]->m_lKMAID == i_lKMAID)
+ {
+ delete(m_aKWKEntries[i]);
+ m_aKWKEntries[i] = NULL;
+ return;
+ }
+ }
+ // should not occur
+ FATAL_ASSERT(0);
+ return;
+}
+
+bool CAgentLoadBalancer::AESKeyWrapSupported (int i_iIndex)
+{
+ if (i_iIndex < 0 || i_iIndex >= m_iClusterNum)
+ {
+ return false;
+ }
+ return (strcmp(m_aCluster[i_iIndex].m_sKMAVersion,
+ FIPS_COMPATIBLE_KMA_VERSION) >= 0);
+}
+
+int CAgentLoadBalancer::GetKWKID (
+ int i_Index,
+ Long64 i_lKMAID,
+ struct soap * const i_pstSoap,
+ UTF8_KEYID o_pKWKID,
+ bool * const o_pbClientAESKeyWrapSetupError)
+{
+ FATAL_ASSERT(i_Index >= 0 && i_Index <= m_iClusterNum);
+ FATAL_ASSERT(i_lKMAID != 0);
+ FATAL_ASSERT(i_pstSoap);
+ FATAL_ASSERT(o_pKWKID);
+ FATAL_ASSERT(o_pbClientAESKeyWrapSetupError);
+
+ *o_pbClientAESKeyWrapSetupError = false;
+
+ // check if the KMA for this cluster index is at a version supporting
+ // AES key wrap
+ if (!AESKeyWrapSupported(i_Index))
+ {
+ strcpy(o_pKWKID, "");
+ return TRUE;
+ }
+
+ // AES Key Wrap Mode
+
+ struct KWKEntry* pKWKentry = GetKWK(i_lKMAID);
+
+ if (pKWKentry == NULL)
+ {
+ const char* sURL = GetHTTPSURL(
+ i_Index,
+ m_pProfile->m_iPortForAgentService);
+
+ pKWKentry = CreateKWK(i_lKMAID, i_pstSoap, sURL, o_pbClientAESKeyWrapSetupError);
+
+ if (pKWKentry == NULL)
+ {
+ return FALSE;
+ }
+ }
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("CAgentLoadBalancer::GetKWKID(): KWK IDhex=%s\n",
+ pKWKentry->m_acKWKID,
+ sizeof (UTF8_KEYID));
+#endif
+
+ strncpy(o_pKWKID, pKWKentry->m_acKWKID, sizeof(UTF8_KEYID));
+ o_pKWKID[sizeof(UTF8_KEYID)-1] = '\0';
+
+ return TRUE;
+};
+
+int CAgentLoadBalancer::GetKWKWrappingKey (
+ struct soap * const i_pstSoap,
+ const char * const i_sURL,
+ CPublicKey * const o_opPublicKEK)
+{
+ FATAL_ASSERT(i_pstSoap);
+ FATAL_ASSERT(i_sURL);
+ FATAL_ASSERT(o_opPublicKEK);
+
+ int bSuccess = TRUE;
+ struct KMS_Agent::KMS_Agent__GetAgentKWKPublicKeyResponse oResponse;
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__GetAgentKWKPublicKey(
+ const_cast<struct soap *> (i_pstSoap),
+ i_sURL,
+ NULL,
+ oResponse) == SOAP_OK;
+
+ if (!bSuccess)
+ {
+ GetSoapFault(sSoapFaultMsg, const_cast<struct soap *> (i_pstSoap));
+ GetPeerNetworkAddress(sKmaAddress, const_cast<struct soap *> (i_pstSoap));
+
+ LogError(m_pProfile,
+ AUDIT_CLIENT_GET_KWK_WRAPPING_KEY_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+
+ return FALSE;
+ }
+
+ // Validate the response structure
+ if (bSuccess)
+ {
+ if (oResponse.KWKPublicKey.__ptr == NULL
+ || oResponse.KWKPublicKey.__size < 1)
+ {
+ bSuccess = FALSE;
+
+ GetPeerNetworkAddress(sKmaAddress, const_cast<struct soap *> (i_pstSoap));
+
+ LogError(m_pProfile,
+ AUDIT_CLIENT_GET_KWK_WRAPPING_KEY_INVALID_KEY_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL);
+ }
+ else
+ {
+ bSuccess = o_opPublicKEK->Load(oResponse.KWKPublicKey.__ptr,
+ oResponse.KWKPublicKey.__size, PKI_FORMAT);
+ if (!bSuccess)
+ {
+ GetPeerNetworkAddress(sKmaAddress, const_cast<struct soap *> (i_pstSoap));
+
+ LogError(m_pProfile,
+ AUDIT_CLIENT_GET_KWK_WRAPPING_KEY_INVALID_RSA_PUB_KEY,
+ NULL,
+ sKmaAddress,
+ NULL);
+ }
+ }
+ }
+
+ // Note: no SOAP cleanup as caller's environment will get destroyed
+
+ return bSuccess;
+};
+
+int CAgentLoadBalancer::RegisterKWK (
+ int i_iWrappedKWKSize,
+ const unsigned char * const i_acWrappedKWK,
+ struct soap * const i_pstSoap,
+ const char * const i_sURL,
+ UTF8_KEYID o_acUTF8KeyID)
+{
+ FATAL_ASSERT(i_iWrappedKWKSize > 0);
+ FATAL_ASSERT(i_acWrappedKWK);
+ FATAL_ASSERT(i_pstSoap);
+ FATAL_ASSERT(i_sURL);
+ FATAL_ASSERT(o_acUTF8KeyID);
+
+ int bSuccess;
+
+ struct KMS_Agent::xsd__hexBinary oKWK;
+
+#if defined(DEBUG) && defined(METAWARE)
+ char sHexWrappedKWK[512];
+ ConvertBinaryToUTF8HexString( sHexWrappedKWK, i_acWrappedKWK, i_iWrappedKWKSize);
+ log_printf("CAgentLoadBalancer::RegisterKWK(): Wrapped KWK hex=%s, len=%d\n",
+ sHexWrappedKWK, i_iWrappedKWKSize);
+#endif
+
+ if (!PutBinaryIntoSoapBinary(i_pstSoap,
+ i_acWrappedKWK,
+ i_iWrappedKWKSize,
+ oKWK.__ptr,
+ oKWK.__size))
+ {
+ return FALSE;
+ }
+
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+ struct KMS_Agent::KMS_Agent__RegisterAgentKWKResponse oResponse;
+
+ bSuccess = KMS_Agent::soap_call_KMS_Agent__RegisterAgentKWK(
+ const_cast<struct soap *> (i_pstSoap),
+ i_sURL, NULL, oKWK, oResponse) == SOAP_OK;
+
+ if (bSuccess)
+ {
+ // verify response
+ if (oResponse.AgentKWKID &&
+ strlen(oResponse.AgentKWKID) == 2 * KMS_KWK_KEY_ID_SIZE)
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("CAgentLoadBalancer::RegisterKWK(): KWK ID hex=%s\n",
+ oResponse.AgentKWKID,
+ sizeof (UTF8_KEYID));
+#endif
+ strncpy(o_acUTF8KeyID, oResponse.AgentKWKID, sizeof(UTF8_KEYID));
+ o_acUTF8KeyID[sizeof(UTF8_KEYID)-1] = '\0';
+ }
+ else
+ {
+ GetPeerNetworkAddress(sKmaAddress, const_cast<struct soap *> (i_pstSoap));
+ GetSoapFault(sSoapFaultMsg, const_cast<struct soap *> (i_pstSoap));
+
+ Log(AUDIT_CLIENT_AGENT_REGISTER_KWK_INVALID_KEYID_RESPONSE,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ bSuccess = FALSE;
+ }
+ }
+ else
+ {
+ GetPeerNetworkAddress(sKmaAddress, const_cast<struct soap *> (i_pstSoap));
+ GetSoapFault(sSoapFaultMsg, const_cast<struct soap *> (i_pstSoap));
+
+ Log(AUDIT_CLIENT_AGENT_REGISTER_KWK_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg);
+ bSuccess = FALSE;
+ }
+
+ // Note: Clean up SOAP must happen in caller, not here
+
+ return bSuccess;
+
+};
+
+bool CAgentLoadBalancer::AESKeyUnwrap (
+ int * const io_pIndex,
+ const WRAPPED_KEY i_pAESWrappedKey,
+ KEY o_pPlainTextKey)
+{
+ FATAL_ASSERT(io_pIndex);
+ FATAL_ASSERT(*io_pIndex >= 0);
+ FATAL_ASSERT(o_pPlainTextKey);
+ FATAL_ASSERT(i_pAESWrappedKey);
+
+ struct KWKEntry * pKWKEntry = GetKWK(GetKMAID(*io_pIndex));
+
+ if (pKWKEntry == NULL)
+ {
+ Log(AGENT_LOADBALANCER_AESKEYUNWRAP_GETKWK_RETURNED_NULL,
+ NULL,
+ m_aCluster[*io_pIndex].m_wsApplianceNetworkAddress,
+ NULL);
+ *io_pIndex = CAgentLoadBalancer::AES_KEY_UNWRAP_ERROR;
+
+ return false;
+ }
+
+#if defined(DEBUG) && defined(METAWARE)
+ char sHexKWK[2*KMS_MAX_KEY_SIZE+1];
+ ConvertBinaryToUTF8HexString( sHexKWK, pKWKEntry->m_acKWK, sizeof (pKWKEntry->m_acKWK));
+ log_printf("CAgentLoadBalancer::AESKeyUnwrap(): KWK hex=%s\n",
+ sHexKWK);
+#endif
+
+ if (aes_key_unwrap(pKWKEntry->m_acKWK,
+ sizeof (pKWKEntry->m_acKWK),
+ i_pAESWrappedKey,
+ o_pPlainTextKey, 4) != 0)
+ {
+ Log(AGENT_LOADBALANCER_AESKEYUNWRAP_KEY_UNWRAP_FAILED,
+ NULL,
+ m_aCluster[*io_pIndex].m_wsApplianceNetworkAddress,
+ NULL);
+ *io_pIndex = CAgentLoadBalancer::AES_KEY_UNWRAP_ERROR;
+ return false;
+ }
+
+ return true;
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_SortClusterArray
+ *
+ *--------------------------------------------------------------------------*/
+void CAgentLoadBalancer::KMSClient_SortClusterArray (KMSClientProfile * const i_pProfile)
+{
+ FATAL_ASSERT(i_pProfile);
+
+ CAutoMutex oAutoMutex((K_MUTEX_HANDLE) i_pProfile->m_pLock);
+
+ int i;
+
+
+ // adjust loads according to availability, site and FIPS compatibility
+ for (i = 0; i < i_pProfile->m_iClusterNum; i++)
+ {
+ if ((i_pProfile->m_aCluster[i].m_iEnabled == FALSE
+ || i_pProfile->m_aCluster[i].m_iResponding == FALSE
+ || i_pProfile->m_aCluster[i].m_iKMALocked))
+ {
+ ((unsigned char*) &(i_pProfile->m_aCluster[i].m_lLoad))[sizeof (int)+1] = 1;
+ }
+ else
+ {
+ ((unsigned char*) &(i_pProfile->m_aCluster[i].m_lLoad))[sizeof (int)+1] = 0;
+ }
+
+ if (strcmp(i_pProfile->m_aCluster[i].m_wsApplianceSiteID,
+ i_pProfile->m_wsEntitySiteID) != 0)
+ {
+ ((unsigned char*) &(i_pProfile->m_aCluster[i].m_lLoad))[sizeof (int)] = 1;
+ }
+ else
+ {
+ ((unsigned char*) &(i_pProfile->m_aCluster[i].m_lLoad))[sizeof (int)] = 0;
+ }
+
+ if ( m_bFIPS &&
+ !FIPScompatibleKMA(i_pProfile->m_aCluster[i].m_sKMAVersion))
+ {
+ ((unsigned char*) &(i_pProfile->m_aCluster[i].m_lLoad))[sizeof (int)+2] = 1;
+ }
+ else
+ {
+ ((unsigned char*) &(i_pProfile->m_aCluster[i].m_lLoad))[sizeof (int)+2] = 0;
+ }
+ }
+
+ // sort ascending by load
+
+ // gnome sort: the simplest sort algoritm
+ // http://www.cs.vu.nl/~dick/gnomesort.html
+
+ //void gnomesort(int n, int ar[]) {
+ // int i = 0;
+ //
+ // while (i < n) {
+ // if (i == 0 || ar[i-1] <= ar[i]) i++;
+ // else {int tmp = ar[i]; ar[i] = ar[i-1]; ar[--i] = tmp;}
+ // }
+ //}
+
+ i = 0;
+ while (i < i_pProfile->m_iClusterNum)
+ {
+ if (i == 0 || i_pProfile->m_aCluster[i - 1].m_lLoad <= i_pProfile->m_aCluster[i].m_lLoad)
+ {
+ i++;
+ }
+ else
+ {
+ KMSClusterEntry tmp = i_pProfile->m_aCluster[i];
+ i_pProfile->m_aCluster[i] = i_pProfile->m_aCluster[i - 1];
+ i_pProfile->m_aCluster[--i] = tmp;
+ }
+ }
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.h b/usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.h
new file mode 100644
index 0000000000..b4237e6be1
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentLoadBalancer.h
@@ -0,0 +1,339 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentLoadBalancer.h
+ */
+
+#ifndef KMS_AGENT_LOAD_BALANCER_H
+#define KMS_AGENT_LOAD_BALANCER_H
+typedef char UTF8_KEYID[2*KMS_KWK_KEY_ID_SIZE+1];
+
+class CAgentLoadBalancer
+{
+public:
+
+ /**
+ * the load balancer retains a pointer to the specified profile
+ */
+ CAgentLoadBalancer(
+ KMSClientProfile * const i_pProfile );
+
+ ~CAgentLoadBalancer ();
+
+ /**
+ * This method must be called at the top of each agent library transaction.
+ * Responsibilities:
+ * <ul>
+ * <li>clear profile failover attempts
+ * <li>sets transaction start time
+ * <li>performs discovery at the frequency specified in the profile
+ * <li>maintains the status of KMAs within the cluster
+ * </ul>
+ * @return a random KMA from the "available" KMAs within the agent's site
+ * or a random KMA from any of the "available" KMA's if none are available
+ * within the agent's site.
+ * When operating in FIPS mode then only KMAs that are
+ * FIPS compatible will be selected, see <code>FIPScompatibleKMA</code>.
+ * Available KMAs
+ * are KMAs that are enabled and responding. If no FIPS compatible KMAs
+ * are available then <code>NO_FIPS_KMA_AVAILABLE</code> is returned.
+ * When <code>m_iClusterDiscoveryFrequency</code> is set to 0 in the profile
+ * then load balancing and automatic discovery
+ * are disabled so the default KMA is returned.
+ */
+ int Balance();
+
+ /**
+ * @return a KMA from the cache that has affinity with the specified DataUnitID,
+ * if possible, otherwise return a KMA from <code>Balance</code>. See
+ * <code>Balance</code> for <code>FIPS_MODE</code> behavior and disabled load balancing.
+ */
+ int BalanceByDataUnitID(
+ const unsigned char * const i_pDataUnitID,
+ int i_iDataUnitIDMaxLen );
+
+ /**
+ * @return a KMA from the cache that has affinity with the specified DataUnitKeyID,
+ * if possible, otherwise return a KMA from <code>Balance</code>. See
+ * <code>Balance</code> for <code>FIPS_MODE</code> behavior and disabled load balancing.
+ */
+ int BalanceByDataUnitKeyID(
+ const unsigned char * const i_pDataUnitKeyID,
+ int i_iDataUnitKeyIDMaxLen );
+
+ enum ERRORS
+ {
+ CLIENT_SIDE_ERROR = -1,
+ NO_KMA_AVAILABLE = -2,
+ AES_KEY_UNWRAP_ERROR = -3,
+ AES_KEY_WRAP_SETUP_ERROR = -4,
+ NO_FIPS_KMA_AVAILABLE = -5,
+ KWK_NOT_REGISTERED = -6
+ };
+
+ /**
+ * Makes a failover determination based upon soap error information and profile settings.
+ * Responsibilities:
+ * <ul>
+ * <li>updates the status of the failed KMA within the profile's cluster array
+ * <li>Client Faults - no failover, same KMA will be returned if a Server Busy error
+ * occurred and
+ * either the transaction timeout has not been exceeded or failover limit has not been exceeded
+ * <li>Server Faults - a failover KMA is chosen if the limit specified set in the profile
+ * has not been exceed
+ * <li>For <code>CLIENT_ERROR_AGENT_KWK_NOT_REGISTERED</code> the KWK is deleted and
+ * i_iFailedApplianceIndex is returned. The caller should re-regsiter the
+ * KWK with this appliance.
+ * </ul>
+ * If all KMAs are disabled or non-responding then give up.
+ * <li>increments profile failover attempts
+ * </ul>
+ * @param i_iFailedApplianceIndex the index within the profile's cluster array of the failed KMA
+ * @param i_pstSoap the gSoap runtime from which error information can be analyzed
+ * @return index of KMA in cluster to failover to, <code>CLIENT_SIDE_ERROR</code> to give up due to client side error,
+ * <code>NO_KMA_AVAILABLE</code> or <code>NO_FIPS_KMA_AVAILABLE</code> if running in FIPS_MODE
+ * if server error but no KMA to failover to
+ */
+ int FailOver(
+ int i_iFailedApplianceIndex,
+ struct soap *i_pstSoap );
+
+ /**
+ * Updates the response status for the specified KMA to responding.
+ */
+ void UpdateResponseStatus(int i_iIndex);
+
+ /**
+ * @return HTTPS protocol URL for the KMA referenced by the specified index entry within this
+ * object's cluster array and the specified web service port.
+ */
+ char* GetHTTPSURL(
+ int i_iIndex,
+ int i_iPort );
+ /**
+ * @return HTTP protocol URL for the KMA referenced by the specified index entry within this
+ * object's cluster array and the specified web service port.
+ */
+ char* GetHTTPURL(
+ int i_iIndex,
+ int i_iPort );
+
+ /**
+ * @return the KMA IP address for the specified index entry within this object's cluster
+ * array.
+ */
+ char* GetApplianceNetworkAddress(
+ int i_iIndex );
+
+ /**
+ * @return the KMA ID for the specified index entry within this
+ * object's cluster. Returns -1 if an invalid
+ * index is provided
+ */
+ Long64 GetKMAID(
+ int i_iIndex );
+
+ /**
+ * retrieves the KWKID for a specified KMA in the cluster.
+ * @param i_Index element in this object's KMS cluster as returned by
+ * one of the Balance methods or the Failover method.
+ * @param i_lKMAID the KMAID for which a KWK is desired
+ * @param i_pstSoap non-NULL pointer to an initialized gSoap runtime to be
+ * used, if necessary, for KWK registration with the KMA.
+ * @param o_pKWKID pointer to UTF8 hex character string to receive the KWKID
+ * for the specified KMA in the cluster.
+ * @param o_pbClientAESKeyWrapSetupError this arg gets set to true if an
+ * error occurs that is client side related and pertaining to establishment
+ * of the AES Key Wrapping Keys.
+ * If the KMS cluster does not support AES KeyWrap o_pKWKID is set to
+ * a zero-length string. A new KWK may be registered with the KMA if a value
+ * has not yet been registered for this instance of CAgentLoadBalancer.
+ * @return TRUE if successful and FALSE otherwise with soap fault available
+ * in the gSoap runtime provided by the caller and io_pIndex set to
+ * AES_KEY_WRAP_SETUP_ERROR. Use ServerError() to
+ * determine if failover is appropriate.
+ */
+ int GetKWKID(
+ int i_Index,
+ Long64 i_lKMAID,
+ struct soap * const i_pstSoap,
+ UTF8_KEYID o_pKWKID,
+ bool * const o_pbClientAESKeyWrapSetupError);
+
+ /**
+ * performs AES Key unwrapping according to RFC3394.
+ * @param io_pIndex Cluster index for KMA that wrapped the key. On error
+ * the cluster index is set to AES_KEY_UNWRAP_ERROR
+ * @param i_pAESWrappedKey pointer to the wrapped key
+ * @param o_pPlainTextKey point to buffer to receive unwrapped key
+ * @return true for success, false otherwise and sets *io_pIndex to
+ * AES_KEY_UNWRAP_ERROR
+ */
+ bool AESKeyUnwrap (
+ int * const io_pIndex,
+ const WRAPPED_KEY i_pAESWrappedKey,
+ KEY o_pPlainTextKey );
+
+ /**
+ * @return true if the KMA referenced by the specified cluster
+ * index supports AES key wrap
+ */
+ bool AESKeyWrapSupported (
+ int i_iIndex);
+
+protected:
+ /**
+ * @return the cluster array index of the KMA with the specified IP address
+ * or CLIENT_SIDE_ERROR if the KMA is not responding or not enabled
+ */
+ int FindIndexByNetworkAddress (
+ char* i_wsApplianceNetworkAddress);
+
+private:
+
+ /**
+ * Sorts the cluster array ascending by load.
+ * Before sorting, the other site's KMAs' load are added by 0x10000000000 and
+ * the disabled/non-responding/locked KMAs are added by 0x1000000000000 and KMAs
+ * not matching the agent's FIPS setting the load is bumped by 0x100000000000000.
+ * This ensures that KMAs
+ * in the current site are sorted before KMAs in other sites and
+ * disabled/non-responding/locked KMAs are after those enabled KMAs. When the agent is
+ * in FIPS mode the non-FIPS KMAs are sorted last.
+ */
+ void KMSClient_SortClusterArray (
+ KMSClientProfile * const i_pProfile);
+
+ static const int MAX_RSA_PUB_KEY_LENGTH = 256;
+ int m_iClusterNum;
+
+ /**
+ * this array is reinitialized from the profile's Cluster array each time Balance() is called.
+ * Failover() will resort the profile's Cluster array so this array may not
+ * match the sort order in the profile
+ */
+ KMSClusterEntry m_aCluster[KMS_MAX_CLUSTER_NUM];
+ KMSClientProfile *m_pProfile;
+ char m_sURL[KMS_MAX_URL+1];
+ unsigned int m_iTransactionStartTimeInMilliseconds;
+ bool m_bFIPS;
+
+ /**
+ * number of elements in KWKEntries
+ */
+ int m_iKWKEntryNum;
+
+ /**
+ * in a failover scenario, if all KMAs are not responding this
+ * member variable tracks the index into m_aCluster of the last KMA attempted.
+ */
+ int m_iLastAttemptedWhenNoneResponding;
+
+ /**
+ * @return true if the failover limit has been exceeded. If failover
+ * limit of -1 is specified in the profile then always return false.
+ */
+ bool FailOverLimit(void);
+
+ /**
+ * \struct for each KMA used in a profile session there will be
+ * a KWKEntry in KWKEntries. These values do not persist
+ * beyond a profile session
+ */
+ struct KWKEntry
+ {
+ /**
+ * The KMA associated with this KWK. This KMA
+ * receives the KWK via the KMS_Agent__RegisterAgentKWK()
+ * agent service which returns the KMA assigned value for
+ * m_acKWKID
+ */
+ Long64 m_lKMAID;
+
+ /**
+ * the KeyID for this KWK, provided by the KMA
+ */
+ UTF8_KEYID m_acKWKID;
+
+ /**
+ * the plaintext value of the AES KWK
+ */
+ KEY m_acKWK;
+ };
+
+ /**
+ * set of KWKEntry ptrs for KMAs used in this profile session.
+ */
+ struct KWKEntry * m_aKWKEntries[KMS_MAX_CLUSTER_NUM];
+
+ /**
+ * retrieve the Key Wrapping Key for a KMA
+ * @param i_lKMAID KMA identifier, must not be equal to -1
+ * @return pointer to the KWKEntry for the specified KMAID, NULL
+ * if the entry does not exist
+ */
+ struct KWKEntry *GetKWK(
+ Long64 i_lKMAID );
+
+ /**
+ * creates a new KWKEntry on the heap and store a ptr to it in an
+ * unused slot in <code>m_aKWKEntries</code>.
+ * @return NULL on error, otherwise a pointer to the newly
+ * created KWKEntry
+ */
+ struct KWKEntry *CreateKWK(
+ Long64 i_lKMAID,
+ struct soap * const i_pstSoap,
+ const char * const i_sURL,
+ bool * const o_pbClientAESKeyWrapSetupError);
+
+ /**
+ * free the <code>KWKEntry</code> corresponding to the specified KMA ID
+ * and set the slot it occupied in <code>m_aKWKEntries</code> to NULL.
+ */
+ void DeleteKWKEntry(Long64 i_lKMAID);
+
+ /**
+ * retrieve the RSA public key to be used for wrapping a KWK
+ */
+ int GetKWKWrappingKey(
+ struct soap * const i_pstSoap,
+ const char * const i_sURL,
+ CPublicKey * const o_opPublicKEK );
+
+ /**
+ * register the KWK with a specified KMA and return the KWK ID
+ */
+ int RegisterKWK(
+ int i_iWrappedKWKSize,
+ const unsigned char * const i_acWrappedKWK,
+ struct soap * const i_pstSoap,
+ const char * const i_sURL,
+ UTF8_KEYID o_acUTF8KeyID );
+
+};
+
+#endif //KMS_AGENT_LOAD_BALANCER_H
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKICert.cpp b/usr/src/lib/libkmsagent/common/KMSAgentPKICert.cpp
new file mode 100644
index 0000000000..9989b26e0e
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKICert.cpp
@@ -0,0 +1,308 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentPKICert.cpp
+ *
+ * This is an implementation of PKICommon.h CCertificate class.
+ */
+
+#include <stdio.h>
+#include <memory.h>
+#include <time.h>
+#include <string.h>
+
+#ifdef KMSUSERPKCS12
+#include <openssl/bio.h>
+#include <openssl/evp.h>
+#include <openssl/conf.h>
+#include <openssl/err.h>
+#include <openssl/asn1.h>
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+#include <openssl/objects.h>
+#include <openssl/pem.h>
+#include <openssl/pkcs12.h>
+#endif
+
+#include "SYSCommon.h"
+#include "KMSAgentPKICommon.h"
+#include "KMSAgentPKIimpl.h"
+
+/////////////////////////////////////////////////////////////////////////
+// CCertificate
+//
+CCertificate::CCertificate()
+{
+ m_pCertImpl = InitializeCertImpl();
+
+ FATAL_ASSERT( m_pCertImpl != NULL );
+}
+
+
+CCertificate::~CCertificate()
+{
+ if ( m_pCertImpl != NULL )
+ {
+ FinalizeCertImpl( m_pCertImpl );
+ }
+}
+
+/**
+ * Save - This OVERLOADED method saves the Cert into a file
+ * @param i_pcFileName - filename of file to save into
+ * @param i_iFormat - IGNORED
+ *
+ * @returns bool - success (true = successful)
+ */
+bool CCertificate::Save( const char * const i_pcFileName,
+ int i_iFormat )
+{
+ return SaveX509CertTofile( m_pCertImpl, i_pcFileName );
+}
+
+/**
+ * Save - This OVERLOADED method saves the Cert into a buffer
+ * @param i_pcBuffer - buffer to save into
+ * @param i_BufferLength - length of buffer to save
+ * @param o_pActualLength - length of buffer saved
+ * @param i_iFormat - IGNORED
+ *
+ * @returns bool - success (true = successful)
+ */
+bool CCertificate::Save( unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ int i_iFormat )
+{
+ return SaveX509CertToBuffer( m_pCertImpl,
+ i_pcBuffer,
+ i_iBufferLength,
+ o_pActualLength );
+}
+
+/**
+ * Load
+ * This OVERLOADED method loads the Cert from a FILE
+ * @param i_pcFileName - name of file to load from
+ * @param i_iFormat - IGNORED
+ *
+ * @returns bool - success (true = successful)
+ */
+
+bool CCertificate::Load( const char * const i_pcFileName,
+ int i_iFormat )
+{
+ return LoadX509CertFromFile( m_pCertImpl, i_pcFileName );
+}
+
+/**
+ * Load
+ * This OVERLOADED method loads the Cert from a buffer
+ * @param i_pcBuffer - buffer to load from
+ * @param i_iLength - amount to load from buffer
+ * @param i_iFormat - IGNORED
+ *
+ * @returns bool - success (true = successful)
+ */
+bool CCertificate::Load( unsigned char * const i_pcBuffer,
+ int i_iLength,
+ int i_iFormat )
+{
+ return LoadX509CertFromBuffer( m_pCertImpl, i_pcBuffer, i_iLength );
+}
+
+/**
+ * Dump
+ * dump the readable format to standard output
+ * @returns bool - success (true = successful)
+ */
+bool CCertificate::Dump()
+{
+ return PrintX509Cert( m_pCertImpl );
+}
+
+#ifdef KMSUSERPKCS12
+bool
+CCertificate::LoadPKCS12CertAndKey(
+ char *filename,
+ int i_iFormat,
+ CPrivateKey *i_pPrivateKey,
+ char *i_pPassphrase)
+{
+ BIO *pFileBio= NULL;
+ X509 *pRequest =NULL;
+
+ pFileBio = BIO_new(BIO_s_file());
+ if (pFileBio == NULL)
+ return false;
+ if (!BIO_read_filename(pFileBio, filename)) {
+ BIO_free(pFileBio);
+ return (false);
+ }
+
+ switch( i_iFormat ) {
+ case FILE_FORMAT_DER:
+
+ pRequest=d2i_X509_bio(pFileBio, NULL);
+ if (pRequest == NULL) {
+ // fixme: log: invalid certificate format
+ return false;
+ }
+ break;
+
+ case FILE_FORMAT_PEM:
+
+ pRequest=PEM_read_bio_X509(pFileBio, NULL, NULL, NULL);
+ if (pRequest == NULL) {
+ // fixme: log: invalid certificate format
+ return false;
+ }
+ break;
+
+ case FILE_FORMAT_PKCS12:
+ PKCS12* pPKCS12Request = d2i_PKCS12_bio(pFileBio, NULL);
+ if (pPKCS12Request == NULL) {
+ // fixme: log: invalid certificate format
+ return false;
+ }
+
+ // convert PKCS12 to X509
+ EVP_PKEY *pKeyTemp = NULL;
+ if (!PKCS12_parse(pPKCS12Request, i_pPassphrase,
+ &pKeyTemp, &pRequest, NULL)) {
+ // fixme: log: invalid certificate format or passphrase
+ PKCS12_free(pPKCS12Request);
+ return false;
+ }
+
+ if (pKeyTemp && i_pPrivateKey) {
+ i_pPrivateKey->SetNative((void *)pKeyTemp);
+ } else if (pKeyTemp)
+ EVP_PKEY_free(pKeyTemp);
+
+ PKCS12_free(pPKCS12Request);
+ break;
+ }
+ if (pRequest != NULL) {
+ SetCert(m_pCertImpl, (void *)pRequest);
+ }
+
+ return (true);
+}
+
+void *
+CCertificate::SaveCertToPKCS12MemoryBIO(
+ CPrivateKey* i_pPrivateKey,
+ char *i_sPassphrase)
+{
+ BIO *pMemBio = NULL;
+ int iReturn;
+
+ // create memory BIO
+ pMemBio = BIO_new(BIO_s_mem());
+
+ if(pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return NULL;
+ }
+
+ PKCS12 *p12 = PKCS12_create(i_sPassphrase,
+ NULL,
+ (EVP_PKEY *)i_pPrivateKey->GetNative(),
+ (X509 *)GetCert(m_pCertImpl),
+ NULL,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0);
+ if ( ! p12 )
+ {
+ return NULL;
+ }
+
+ // now pMemBIO != NULL, remember to free it before exiting
+ iReturn = i2d_PKCS12_bio(pMemBio, p12);
+
+ if(!iReturn) // return 0: means error occurs
+ {
+ //fixme: log -- could not export private key
+ BIO_free(pMemBio);
+ return NULL;
+ }
+
+ return (void *)pMemBio;
+}
+
+bool
+CCertificate::SavePKCS12(
+ unsigned char *i_pcBuffer,
+ int i_iBufferLength,
+ int *o_pActualLength,
+ CPrivateKey* i_pPrivateKey,
+ char* i_sPassphrase )
+{
+ BIO *pMemBio = NULL;
+ char *pData = NULL;
+ int iLength;
+
+ // sanity check
+ if(i_pcBuffer == NULL) return false;
+ if(i_iBufferLength <= 0) return false;
+ if(o_pActualLength == NULL) return false;
+
+ // create memory BIO
+ pMemBio = (BIO *)SaveCertToPKCS12MemoryBIO(i_pPrivateKey, i_sPassphrase);
+
+ if(pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+
+ iLength = BIO_get_mem_data(pMemBio, &pData);
+
+ // If the output buffer is a string, it needs to be NULL terminated
+ // So always append a NULL to the output
+ if(iLength + 1 > i_iBufferLength)
+ {
+ //fixme: log -- buffer too small
+ BIO_free(pMemBio);
+ return false;
+ }
+ // copy the data to given buffer
+ memcpy(i_pcBuffer, pData, iLength);
+ // NULL terminate the string
+ i_pcBuffer[iLength] = '\0';
+ *o_pActualLength = iLength;
+
+ // free memory
+ BIO_free(pMemBio);
+
+ return true;
+}
+#endif /* PKCS12 */
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKICertOpenSSL.cpp b/usr/src/lib/libkmsagent/common/KMSAgentPKICertOpenSSL.cpp
new file mode 100644
index 0000000000..e26e8cb1f2
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKICertOpenSSL.cpp
@@ -0,0 +1,313 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentPKICertOpenSSL.cpp
+ */
+
+#include <stdio.h>
+#include <openssl/bio.h>
+#include <openssl/pem.h>
+
+#include "SYSCommon.h"
+#include "KMSAgentPKIimpl.h"
+
+typedef struct X509control
+{
+ X509* pX509;
+} X509control;
+
+void * InitializeCertImpl()
+{
+ X509control *pX509Control = (X509control *) malloc(sizeof(X509control));
+
+ if ( pX509Control != NULL )
+ {
+ pX509Control->pX509 = NULL;
+ }
+
+ return pX509Control;
+}
+
+/**
+ * export the Cert to a memory BIO, if error, return NULL
+ */
+BIO* SaveCertToMemoryBIO( X509control* i_pX509control )
+{
+ BIO *pMemBio = NULL;
+ int iReturn;
+
+ // create memory BIO
+ pMemBio = BIO_new(BIO_s_mem());
+
+ if(pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return NULL;
+ }
+
+ //iReturn = PEM_write_bio_X509(pMemBio, m_pNative);
+ iReturn = PEM_write_bio_X509(pMemBio, i_pX509control->pX509);
+
+ if(!iReturn) // return 0: means error occurs
+ {
+ //fixme: log -- could not export private key
+ BIO_free(pMemBio);
+ return NULL;
+ }
+
+ return pMemBio;
+}
+
+bool SaveX509CertTofile(
+ void* const i_pImplResource,
+ const char * const i_pcFileName )
+{
+ FATAL_ASSERT( i_pImplResource != NULL && i_pcFileName );
+
+ X509control* pX509control = (X509control*)i_pImplResource;
+ // the BIO for output, need cleanup when exiting
+ BIO *pMemBio = NULL;
+ int iLength;
+ unsigned char *pData;
+ FILE *fp;
+
+ // create memory BIO
+ pMemBio = SaveCertToMemoryBIO( pX509control );
+
+ if(pMemBio == NULL)
+ {
+ return false;
+ }
+
+ // now pMemBIO != NULL, remember to free it before exiting
+ iLength = BIO_get_mem_data(pMemBio, &pData);
+
+ // open the file
+ fp = fopen(i_pcFileName, "wb");
+ if(fp == NULL)
+ {
+ //fixme: log -- could not open file for exporting Cert
+ BIO_free(pMemBio);
+ return false;
+ }
+
+ fwrite(pData, 1, iLength, fp);
+ fclose(fp);
+
+ BIO_free(pMemBio); // BIO_free close the file and clean the BIO
+ return true;
+}
+
+bool SaveX509CertToBuffer(
+ void* const i_pImplResource,
+ unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength )
+{
+ FATAL_ASSERT( i_pImplResource != NULL &&
+ i_pcBuffer &&
+ o_pActualLength &&
+ i_iBufferLength > 0 );
+
+ X509control* pX509control = (X509control*)i_pImplResource;
+
+ BIO *pMemBio = NULL;
+ char *pData = NULL;
+ int iLength;
+
+ // create memory BIO
+ pMemBio = SaveCertToMemoryBIO( pX509control );
+
+ if( pMemBio == NULL )
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+
+ iLength = BIO_get_mem_data( pMemBio, &pData );
+
+ // If the output buffer is a string, it needs to be NULL terminated
+ // So always append a NULL to the output
+ if(iLength + 1 > i_iBufferLength)
+ {
+ //fixme: log -- buffer too small
+ BIO_free(pMemBio);
+ return false;
+ }
+ // copy the data to given buffer
+ memcpy(i_pcBuffer, pData, iLength);
+ // NULL terminate the string
+ i_pcBuffer[iLength] = '\0';
+ *o_pActualLength = iLength;
+
+ // free memory
+ BIO_free(pMemBio);
+
+ return true;
+}
+
+/**
+ * import the Cert from a BIO, if error, return NULL
+ */
+bool LoadCertFromBIO(X509control* i_pX509control, BIO *i_pBio)
+{
+ X509 *pRequest = NULL;
+
+ if (i_pX509control == NULL) return false;
+
+ if(i_pBio == NULL) return false;
+
+ //if(m_pNative != NULL) return false; // do not allow overwrite
+ if (i_pX509control->pX509 != NULL ) return false;
+
+ pRequest=PEM_read_bio_X509(i_pBio, NULL, NULL, NULL);
+
+ if (pRequest == NULL)
+ {
+ // fixme: log: invalid certificate format
+ return false;
+ }
+ //m_pNative = pRequest;
+ i_pX509control->pX509 = pRequest;
+
+ return true;
+}
+
+bool LoadX509CertFromFile(
+ void* const i_pImplResource,
+ const char * const i_pcFileName )
+
+{
+ X509control* pX509control = (X509control*) i_pImplResource;
+ if (pX509control == NULL)
+ {
+ return false;
+ }
+
+ BIO *pFileBio=NULL;
+ bool bReturn;
+
+ pFileBio=BIO_new(BIO_s_file());
+ if (pFileBio == NULL)
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+
+ if (!BIO_read_filename(pFileBio,i_pcFileName))
+ {
+ //fixme log -- could not open file
+ BIO_free(pFileBio);
+ return false;
+ }
+
+ bReturn = LoadCertFromBIO(pX509control, pFileBio);
+
+ BIO_free(pFileBio);
+
+ return bReturn;
+}
+
+
+bool LoadX509CertFromBuffer(
+ void* const i_pImplResource,
+ void* const i_pX509Cert,
+ int i_iLength)
+ {
+ X509control* pX509control = (X509control*)i_pImplResource;
+
+ if(pX509control == NULL)
+ {
+ return false;
+ }
+
+ BIO *pMemBio;
+ bool bReturn;
+ // create a mem bio from the given buffer
+ // Note that BIO_new_mem_buf() creates a BIO which never destroy the memory
+ // attached to it.
+ pMemBio = BIO_new_mem_buf(i_pX509Cert, i_iLength);
+ if (pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+ bReturn = LoadCertFromBIO(pX509control, pMemBio);
+
+ BIO_free(pMemBio);
+
+ return bReturn;
+}
+
+void FinalizeCertImpl( void* i_pImplResource )
+{
+ if ( i_pImplResource != NULL )
+ {
+ free(i_pImplResource);
+ }
+}
+
+bool PrintX509Cert( void* const i_pImplResource )
+{
+ BIO *pMemBio;
+ char *pData;
+ int iLength,i;
+ X509control* pX509control = (X509control*)i_pImplResource;
+ pMemBio = BIO_new(BIO_s_mem());
+ if(pMemBio == NULL)
+ {
+ return false;
+ }
+
+ //X509_print(pMemBio,m_pNative);
+ X509_print(pMemBio, pX509control->pX509);
+
+ iLength = BIO_get_mem_data(pMemBio, &pData);
+
+ for(i = 0; i < iLength; i++)
+ {
+ printf("%c", pData[i]);
+ }
+
+ BIO_free(pMemBio);
+
+ return true;
+
+}
+#ifdef K_SOLARIS_PLATFORM
+void *GetCert(void* i_pImplResource )
+{
+ X509control* pX509control = (X509control*)i_pImplResource;
+ return ((void *)pX509control->pX509);
+}
+
+void SetCert(void* i_pImplResource, void *cert)
+{
+ X509control* pX509control = (X509control*)i_pImplResource;
+ pX509control->pX509 = (X509 *)cert;
+ return;
+}
+#endif
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKICommon.cpp b/usr/src/lib/libkmsagent/common/KMSAgentPKICommon.cpp
new file mode 100644
index 0000000000..269463c6ef
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKICommon.cpp
@@ -0,0 +1,159 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentPKICommon.cpp
+ */
+#include <stdio.h>
+
+#include "SYSCommon.h"
+#include "KMSAgentPKICommon.h"
+#include "KMSAgentStringUtilities.h"
+
+#include "KMSAgent_direct.h"
+
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CPKI::CPKI()
+{
+ m_iKeyLength = DEFAULT_KEY_SIZE;
+
+ // used for CA
+ m_pCACertificate = NULL;
+ m_pCAPrivateKey = NULL;
+}
+
+// BEN - make these
+// global lengths
+int iLength1 = 0;
+int iLength2 = 0;
+
+// THIS CAN'T BE STACK DATA - TOO BIG
+static unsigned char aTempBuffer[MAX_CERT_SIZE + MAX_KEY_SIZE];
+#ifdef METAWARE
+static char aNotherTempBuffer[50];
+#endif
+
+// used by StoreAgentPKI - KMSAgentStorage.cpp
+
+bool CPKI::ExportCertAndKeyToFile(
+ CCertificate* const i_pCertificate,
+ CPrivateKey* const i_pPrivateKey,
+ const char* const i_pcFileName,
+ const char* const i_sPassphrase,
+ EnumPKIFileFormat i_eFileFormat )
+{
+ FATAL_ASSERT( i_pCertificate && i_pPrivateKey && i_pcFileName );
+
+
+ memset( aTempBuffer, 0, MAX_CERT_SIZE + MAX_KEY_SIZE );
+
+#ifdef KMSUSERPKCS12
+ if ( i_eFileFormat == FILE_FORMAT_PKCS12 )
+ {
+ if ( !i_pCertificate->SavePKCS12(aTempBuffer,
+ MAX_CERT_SIZE,
+ &iLength1,
+ i_pPrivateKey,
+ (char*)i_sPassphrase ) )
+ {
+ return false;
+ }
+ } else {
+#endif
+
+ // Overloaded Save method implemented in KMSAgentPKICert.cpp
+ // this method saves Certificate to the temporary buffer, not a file
+ // but a side effect is to get the actual file length
+ if ( !i_pCertificate->Save(aTempBuffer,
+ MAX_CERT_SIZE,
+ &iLength1, /* returned - actual length
+ written */
+ i_eFileFormat) )
+ {
+ return false;
+ }
+
+ // Overloaded Save method implemented in KMSAgentPKIKey.cpp
+ // this method saves keys to the temporary buffer, not a file,
+ // but a side effect is to get the actual file length
+ if ( !i_pPrivateKey->Save(aTempBuffer + iLength1,
+ MAX_KEY_SIZE,
+ &iLength2, /* returned - actual length
+ written */
+ i_sPassphrase,
+ i_eFileFormat) )
+ {
+ return false;
+ }
+
+#ifdef KMSUSERPKCS12
+ }
+#endif
+
+ // now write the temporary buffer to a file
+ myFILE* pFile = fopen( i_pcFileName, "wb" );
+ if ( pFile == NULL )
+ {
+ return false;
+ }
+
+#ifdef KMSUSERPKCS12
+#ifdef K_SOLARIS_PLATFORM
+ int fd = fileno(pFile);
+
+ /* Make sure this file is read/write for the OWNER only! */
+ (void) fchmod(fd, 0600);
+#endif
+#endif
+
+#ifdef METAWARE
+ // write out the two file lengths
+ snprintf(aNotherTempBuffer, sizeof(aNotherTempBuffer), "iLength1=%x\n", iLength1);
+ fputs((const char*)aNotherTempBuffer, pFile);
+
+ snprintf(aNotherTempBuffer, sizeof(aNotherTempBuffer), "iLength2=%x\n", iLength2);
+ fputs((const char*)aNotherTempBuffer, pFile);
+#endif
+
+ int iBytesWritten = fwrite( (const char*)aTempBuffer, // from
+ 1, // size
+ iLength1+iLength2, // actual file length
+ pFile ); // to-file
+
+ fclose( pFile );
+
+ return ( iBytesWritten == (iLength1+iLength2) );
+}
+
+
+CPKI::~CPKI()
+{
+ // empty
+}
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKICommon.h b/usr/src/lib/libkmsagent/common/KMSAgentPKICommon.h
new file mode 100644
index 0000000000..b9ed831485
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKICommon.h
@@ -0,0 +1,293 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*-------------------------------------------------------------------------*/
+/**
+ * \file KMSAgentPKICommon.h
+ *
+ * X.509 Certificate and Private Key Support Interface
+ *
+ * This module provides simple interfaces to support SSL communication
+ * for the KMS Agent enrollment protocol. Basic classes supporting
+ * X.509 certificates, private key management are provided and hide
+ * specific implementations from users of these classes.
+ */
+/*-------------------------------------------------------------------------*/
+
+#ifndef K_KMSAgentPKICommon_h
+#define K_KMSAgentPKICommon_h
+
+#ifdef WIN32
+#pragma warning(disable: 4786)
+#endif
+
+#define MAX_CERT_SIZE 4096
+#define MAX_KEY_SIZE 4096
+
+#define DEFAULT_KEY_SIZE 2048
+
+#ifdef KMSUSERPKCS12
+enum EnumPKIFileFormat { FILE_FORMAT_DER, FILE_FORMAT_PEM, FILE_FORMAT_PKCS12 };
+#else
+enum EnumPKIFileFormat { FILE_FORMAT_DER, FILE_FORMAT_PEM };
+#endif
+
+/**
+ * This class provides a simple interface for the management of
+ * public keys. Simple load and store operations are provided for
+ * storage and retrieval from memory buffers.
+ */
+class CPublicKey
+{
+
+public:
+
+ CPublicKey();
+
+ /**
+ * This method saves public key into a buffer,
+ * it also returns the actual used buffer length.
+ * @param i_pcBuffer Buffer to receive public key
+ * @param i_iBufferLength length of the buffer provided
+ * @param o_pActualLength actual length of the public key stored into the buffer
+ * @param i_iFormat key format, @see EnumPKIFileFormat
+ */
+ bool Save(unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ int i_iFormat);
+ /**
+ * This method loads the public key from a buffer
+ * @param i_pcBuffer
+ * @param i_iLength
+ * @param i_iFormat one of the enums from EnumPKIFileFormat,
+ * only FILE_FORMAT_PEM is supported.
+ * @return true for success, false otherwise
+ */
+ bool Load (unsigned char * const i_pcBuffer,
+ int i_iLength,
+ int i_iFormat);
+
+ /**
+ * use this object's public key to encrypt plaintext buffer
+ */
+ bool Encrypt (int i_iLength,
+ const unsigned char * const i_pcPlainText,
+ unsigned char * const o_pcCypherText,
+ int * const o_pActualLength);
+
+ ~CPublicKey();
+
+private:
+ void *m_pPublicKeyImpl;
+};
+
+/**
+ * This class provides a simple interface for the management of
+ * private keys. Simple load and store operations are provided for
+ * storage and retrieval from memory buffers.
+ *
+ */
+class CPrivateKey
+{
+
+ public:
+
+ CPrivateKey();
+
+ /**
+ * Saves the private key to a memory buffer specified by
+ * i_pcBuffer. Currently just the PEM format is supported.
+ * Specification of a passphrase allows encryption of the private
+ * key subject to the choice of the implementation.
+ *
+ * @param[in] i_pcBuffer
+ * @param[in] i_iBufferLength
+ * @param[out] o_pActualLength
+ * @param[in] i_pPassphrase optional, if non-null the private key is
+ * wrapped using this passphrase
+ * @param[in] i_iFormat one of the enums from EnumPKIFileFormat,
+ * only FILE_FORMAT_PEM is supported.
+ * @return true for success, false otherwise
+ */
+ bool Save( unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ const char * const i_pPassphrase,
+ int i_iFormat );
+
+ /**
+ * This method loads the private key from a buffer
+ * @param i_pcBuffer
+ * @param i_iLength
+ * @param i_pPassphrase optional, if non-null the private key is
+ * unwrapped using this passphrase
+ * @param i_iFormat one of the enums from EnumPKIFileFormat,
+ * only FILE_FORMAT_PEM is supported.
+ * @return true for success, false otherwise
+ */
+ bool Load(unsigned char * const i_pcBuffer,
+ int i_iLength,
+ const char * const i_pPassphrase,
+ int i_iFormat);
+
+ ~CPrivateKey();
+
+#ifdef KMSUSERPKCS12
+ void *GetNative();
+ void SetNative(void *);
+#endif
+ private:
+ void *m_pPKeyImpl;
+
+};
+
+/**
+ * This class provides a simple interface for managing X.509
+ * certificates providing only simple load and save operations for
+ * storage and retrieval.
+ *
+ */
+class CCertificate
+{
+
+public:
+ CCertificate();
+
+ ~CCertificate();
+
+ /**
+ * save the certificate to the specified file name. Currently,
+ * only FILE_FORMAT_PEM is supported.
+ */
+ bool Save( const char * const i_pcFileName,
+ int i_iFormat);
+
+ /**
+ * save the certificate to the specified buffer. Currently, only
+ * FILE_FORMAT_PEM is supported.
+ */
+ bool Save( unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ int i_iFormat);
+
+ /**
+ * load a certificate from the specified filename. Currently,
+ * only FILE_FORMAT_PEM is supported.
+ */
+ bool Load( const char * const i_pcFileName,
+ int i_iFormat );
+
+ /**
+ * load a certificate from the specified buffer. Currently, only
+ * FILE_FORMAT_PEM is supported.
+ */
+ bool Load( unsigned char * const i_pcBuffer,
+ int i_iLength,
+ int i_iFormat );
+
+ /**
+ * prints the certificate to stdout
+ */
+ bool Dump();
+
+#ifdef KMSUSERPKCS12
+ bool LoadPKCS12CertAndKey(char *filename,
+ int i_iFormat,
+ CPrivateKey *i_pPrivateKey,
+ char *i_pPassphrase);
+
+ bool SavePKCS12(
+ unsigned char *i_pcBuffer,
+ int i_iBufferLength,
+ int *o_pActualLength,
+ CPrivateKey* i_pPrivateKey,
+ char* i_sPassphrase );
+#endif
+
+private:
+ /**
+ * an opague pointer to implementation specific resources to be
+ * freed by the Destructor.
+ */
+ void *m_pCertImpl;
+#ifdef KMSUSERPKCS12
+ /**
+ * saves certificate to PKCS#12 memory BIO
+ * @param i_pPrivateKey
+ * @param i_sPassphrase
+ * @return pointer to the Memory BIO
+ */
+ void* SaveCertToPKCS12MemoryBIO(
+ CPrivateKey* i_pPrivateKey,
+ char *i_sPassphrase);
+#endif
+
+};
+
+
+/**
+ * This class provides a method for storing an X.509 certificate and
+ * private key to a file. The private key is appended to the
+ * certificate and optionally encrypted with the specified passphrase
+ * for encoding and storage in PEM format.
+ */
+class CPKI
+{
+ public:
+ CPKI();
+ ~CPKI();
+
+ public:
+
+ /**
+ * exports a certificate and associated private key to the
+ * specified file.
+ * @param i_pCertificate a pointer to an instance of a certificate
+ * @param i_pPrivateKey a pointer to an instance of a private key
+ * @param i_pcFileName the name of the file to store the cert and private key
+ * @param i_sPassphrase optional but when provided supplies a
+ * pass phrase to use for encrypting the private key. The cipher
+ * used for encryption is determined by the underlying implementation
+ * which for the reference implementation uses triple DES by default.
+ * @param i_eFileFormat the encoding format to use for the certificate and private key
+ */
+ bool ExportCertAndKeyToFile(
+ CCertificate* const i_pCertificate,
+ CPrivateKey* const i_pPrivateKey,
+ const char* const i_pcFileName,
+ const char* const i_sPassphrase,
+ EnumPKIFileFormat i_eFileFormat );
+
+ private:
+
+ int m_iKeyLength;
+
+ CCertificate *m_pCACertificate;
+ CPrivateKey *m_pCAPrivateKey;
+ };
+
+#endif //K_KMSAgentPKICommon_h
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKIKey.cpp b/usr/src/lib/libkmsagent/common/KMSAgentPKIKey.cpp
new file mode 100644
index 0000000000..a50446739a
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKIKey.cpp
@@ -0,0 +1,153 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentPKIKey.cpp
+ */
+#include <stdio.h>
+
+#include "SYSCommon.h"
+#include "KMSAgentPKICommon.h"
+#include "KMSAgentPKIimpl.h"
+
+///////////////////////////////////////////////////////////////////////////////////////
+// public key methods
+///////////////////////////////////////////////////////////////////////////////////////
+CPublicKey::CPublicKey()
+{
+ m_pPublicKeyImpl = InitializePKeyImpl();
+
+ FATAL_ASSERT( m_pPublicKeyImpl != NULL );
+
+}
+
+/**
+ * This method saves public key into a buffer,
+ * it also returns the actual used buffer length.
+ * @param i_pcBuffer Buffer to receive public key
+ * @param i_iBufferLength length of the buffer provided
+ * @param o_pActualLength actual length of the public key stored into the buffer
+ * @param i_iFormat key format, @see EnumPKIFileFormat
+ */
+bool CPublicKey::Save( unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ int i_iFormat )
+{
+ return SavePublicKeyToBuffer( m_pPublicKeyImpl,
+ i_pcBuffer,
+ i_iBufferLength,
+ o_pActualLength,
+ i_iFormat );
+}
+
+bool CPublicKey::Load(unsigned char * const i_pcBuffer,
+ int i_iLength,
+ int i_iFormat)
+{
+ return LoadPublicKeyFromBuffer( m_pPublicKeyImpl,
+ i_pcBuffer,
+ i_iLength,
+ i_iFormat );
+}
+
+bool CPublicKey::Encrypt (int i_iLength,
+ const unsigned char * const i_pcPlainText,
+ unsigned char * const o_pcCypherText,
+ int * const o_pActualLength)
+{
+ return PublicKeyEncrypt(i_iLength,i_pcPlainText,o_pcCypherText,o_pActualLength, m_pPublicKeyImpl );
+}
+
+CPublicKey::~CPublicKey()
+{
+ if(m_pPublicKeyImpl != NULL)
+ {
+ FinalizePKeyImpl( m_pPublicKeyImpl );
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+// private key methods
+///////////////////////////////////////////////////////////////////////////////////////
+
+CPrivateKey::CPrivateKey()
+{
+ m_pPKeyImpl = InitializePKeyImpl();
+
+ FATAL_ASSERT( m_pPKeyImpl != NULL );
+
+}
+
+/**
+ * This method saves private key into a buffer,
+ * it also returns the actual used buffer length.
+ */
+bool CPrivateKey::Save( unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ const char * const i_pPassphrase,
+ int i_iFormat )
+{
+ return SavePrivateKeyToBuffer(m_pPKeyImpl,
+ i_pcBuffer,
+ i_iBufferLength,
+ o_pActualLength,
+ i_pPassphrase,
+ i_iFormat );
+}
+
+bool CPrivateKey::Load(unsigned char * const i_pcBuffer,
+ int i_iLength,
+ const char * const i_pPassphrase,
+ int i_iFormat)
+{
+ return LoadPrivateKeyFromBuffer( m_pPKeyImpl,
+ i_pcBuffer,
+ i_iLength,
+ i_pPassphrase,
+ i_iFormat );
+}
+
+CPrivateKey::~CPrivateKey()
+{
+ if(m_pPKeyImpl != NULL)
+ {
+ FinalizePKeyImpl( m_pPKeyImpl );
+ }
+}
+#ifdef KMSUSERPKCS12
+void
+*CPrivateKey::GetNative()
+{
+ return GetPKey(m_pPKeyImpl);
+}
+void
+CPrivateKey::SetNative(void *pKey)
+{
+ SetPKey(m_pPKeyImpl, pKey);
+ return;
+}
+#endif
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKIKeyOpenSSL.cpp b/usr/src/lib/libkmsagent/common/KMSAgentPKIKeyOpenSSL.cpp
new file mode 100644
index 0000000000..d66f185296
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKIKeyOpenSSL.cpp
@@ -0,0 +1,412 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentPKIKeyOpenSSL.cpp
+ */
+
+#include <stdio.h>
+#include <openssl/bio.h>
+#include <openssl/pem.h>
+#include <openssl/rsa.h>
+
+#include "SYSCommon.h"
+#include "KMSAgentPKIimpl.h"
+
+typedef struct PKeyControl
+{
+ EVP_PKEY* pPKey;
+} PKeyControl;
+
+void * InitializePKeyImpl()
+{
+ PKeyControl *pPKeyControl =
+ (PKeyControl *) malloc(sizeof(PKeyControl));
+
+ if ( pPKeyControl != NULL )
+ {
+ pPKeyControl->pPKey = NULL;
+ }
+
+ return pPKeyControl;
+}
+
+void FinalizePKeyImpl( void * i_pPKeyImpl )
+{
+ if ( i_pPKeyImpl != NULL )
+ {
+ free(i_pPKeyImpl);
+ }
+}
+
+#ifdef KMSUSERPKCS12
+void *GetPKey(void *i_pPKeyImpl) {
+ PKeyControl* pPKeyControl = (PKeyControl*) i_pPKeyImpl;
+ return ((void *)pPKeyControl->pPKey);
+}
+
+void SetPKey(void *i_pPKeyImpl, void *pKey) {
+ PKeyControl* pPKeyControl = (PKeyControl*) i_pPKeyImpl;
+ pPKeyControl->pPKey = (EVP_PKEY *)pKey;
+ return;
+}
+#endif
+
+/**
+ * export the private key to a memory BIO, if error, return NULL
+ */
+BIO* SavePrivateKeyToMemoryBIO(PKeyControl* const i_pPKeyControl,
+ const char * const i_pPassphrase)
+{
+ BIO *pMemBio = NULL;
+ const EVP_CIPHER *pCipher = NULL;
+ int iReturn;
+
+ // set cipher, if passphrase is not empty
+ if(i_pPassphrase != NULL)
+ {
+ pCipher= EVP_des_ede3_cbc(); //NULL means no password protection
+ }
+
+ // create memory BIO
+ pMemBio = BIO_new(BIO_s_mem());
+
+ if(pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return NULL;
+ }
+
+ iReturn = PEM_write_bio_PrivateKey
+ (pMemBio,
+ i_pPKeyControl->pPKey,
+ pCipher,
+ NULL,0,NULL, (char*) i_pPassphrase);
+
+ if(!iReturn) // return 0: means error occurs
+ {
+ //fixme: log -- could not export private key
+ BIO_free(pMemBio);
+ return NULL;
+ }
+
+ return pMemBio;
+}
+
+bool SavePrivateKeyToBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ const char * const i_pPassphrase,
+ int i_iFormat)
+{
+ PKeyControl* pPKeyControl = (PKeyControl*) i_pPKeyImpl;
+
+ FATAL_ASSERT( pPKeyControl &&
+ i_pcBuffer &&
+ i_iBufferLength > 0 &&
+ o_pActualLength );
+
+ BIO *pMemBio = NULL;
+ char *pData = NULL;
+ int iLength;
+
+ // create memory BIO
+ pMemBio = SavePrivateKeyToMemoryBIO( pPKeyControl, i_pPassphrase );
+
+ if(pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+
+ iLength = BIO_get_mem_data(pMemBio, &pData);
+
+ // If the output buffer is a string, it needs to be NULL terminated
+ // So always append a NULL to the output
+ if(iLength + 1 > i_iBufferLength)
+ {
+ //fixme: log -- buffer too small
+ BIO_free(pMemBio);
+ return false;
+ }
+ // copy the data to given buffer
+ memcpy(i_pcBuffer, pData, iLength);
+ // NULL terminate the string
+ i_pcBuffer[iLength] = '\0';
+ *o_pActualLength = iLength;
+
+ // free memory
+ BIO_free(pMemBio);
+
+ return true;
+}
+
+/**
+ * import the private key from a BIO, if error, return NULL
+ */
+bool LoadPrivateKeyFromBIO(PKeyControl* const io_pPKeyControl,
+ BIO *i_pBio,
+ char *i_pPassphrase )
+{
+ if (io_pPKeyControl == NULL)
+ {
+ return false;
+ }
+
+ EVP_PKEY *pKey = NULL;
+
+ if(i_pBio == NULL)
+ {
+ return false;
+ }
+
+ if ( io_pPKeyControl != NULL && io_pPKeyControl->pPKey != NULL )
+ {
+ return false; // do not allow overwrite
+ }
+
+ pKey=PEM_read_bio_PrivateKey(i_pBio,NULL,NULL,i_pPassphrase);
+ if (pKey == NULL)
+ {
+ // fixme: log: invalid private key format or passphrase
+ return false;
+ }
+
+ io_pPKeyControl->pPKey = pKey;
+
+ return true;
+}
+
+bool LoadPrivateKeyFromBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * i_pcBuffer,
+ int i_iLength,
+ const char * const i_pPassphrase,
+ int i_iFormat)
+{
+ PKeyControl* const pPKeyControl = (PKeyControl*) i_pPKeyImpl;
+
+ FATAL_ASSERT( i_pPKeyImpl && i_pcBuffer );
+
+ bool bReturn;
+ BIO *pMemBio;
+ // create a mem bio from the given buffer
+ // Note that BIO_new_mem_buf() creates a BIO which never
+ // destroy the memory attached to it.
+ pMemBio = BIO_new_mem_buf(i_pcBuffer, i_iLength);
+ if (pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+ bReturn = LoadPrivateKeyFromBIO( pPKeyControl,
+ pMemBio, (char *)i_pPassphrase );
+
+ BIO_free(pMemBio);
+
+ return bReturn;
+}
+
+/**
+ * export the public key to a memory BIO, if error, return NULL
+ */
+BIO* SavePublicKeyToMemoryBIO(PKeyControl* const i_pPublicKeyControl )
+{
+ BIO *pMemBio = NULL;
+
+ int iReturn;
+
+ // create memory BIO
+ pMemBio = BIO_new(BIO_s_mem());
+
+ if(pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return NULL;
+ }
+
+ iReturn = PEM_write_bio_PUBKEY(pMemBio,
+ i_pPublicKeyControl->pPKey );
+
+ if(!iReturn) // return 0: means error occurs
+ {
+ //fixme: log -- could not export private key
+ BIO_free(pMemBio);
+ return NULL;
+ }
+
+ return pMemBio;
+}
+
+bool SavePublicKeyToBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ int i_iFormat)
+{
+ PKeyControl* pPublicKeyControl = (PKeyControl*) i_pPKeyImpl;
+
+ FATAL_ASSERT( pPublicKeyControl &&
+ i_pcBuffer &&
+ i_iBufferLength > 0 &&
+ o_pActualLength );
+
+ BIO *pMemBio = NULL;
+ char *pData = NULL;
+ int iLength;
+
+ // create memory BIO
+ pMemBio = SavePublicKeyToMemoryBIO( pPublicKeyControl );
+
+ if(pMemBio == NULL)
+ {
+ return false;
+ }
+
+ iLength = BIO_get_mem_data(pMemBio, &pData);
+
+ // If the output buffer is a string, it needs to be NULL terminated
+ // So always append a NULL to the output
+ if(iLength + 1 > i_iBufferLength)
+ {
+ BIO_free(pMemBio);
+ return false;
+ }
+ // copy the data to given buffer
+ memcpy(i_pcBuffer, pData, iLength);
+ // NULL terminate the string
+ i_pcBuffer[iLength] = '\0';
+ *o_pActualLength = iLength;
+
+ // free memory
+ BIO_free(pMemBio);
+
+ return true;
+}
+
+/**
+ * import the public key from a BIO, if error, return NULL
+ */
+bool LoadPublicKeyFromBIO(PKeyControl* const io_pPublicKeyControl,
+ BIO *i_pBio )
+{
+ EVP_PKEY *pKey = NULL;
+
+ if(io_pPublicKeyControl == NULL)
+ {
+ return false;
+ }
+
+ if(i_pBio == NULL)
+ {
+ return false;
+ }
+
+ if ( io_pPublicKeyControl != NULL && io_pPublicKeyControl->pPKey != NULL )
+ {
+ return false; // do not allow overwrite
+ }
+
+ pKey = PEM_read_bio_PUBKEY(i_pBio, NULL, NULL, NULL);
+ if (pKey == NULL)
+ {
+ // fixme: log: invalid public key format or passphrase
+ return false;
+ }
+
+ io_pPublicKeyControl->pPKey = pKey;
+
+ return true;
+}
+
+bool LoadPublicKeyFromBuffer(
+ void * const i_pPublicKeyImpl,
+ unsigned char * i_pcBuffer,
+ int i_iLength,
+ int i_iFormat)
+{
+ PKeyControl* const pPublicKeyControl = (PKeyControl*) i_pPublicKeyImpl;
+
+ FATAL_ASSERT( i_pPublicKeyImpl && i_pcBuffer );
+
+ bool bReturn;
+ BIO *pMemBio;
+ // create a mem bio from the given buffer
+ // Note that BIO_new_mem_buf() creates a BIO which never
+ // destroy the memory attached to it.
+ pMemBio = BIO_new_mem_buf(i_pcBuffer, i_iLength);
+ if (pMemBio == NULL)
+ {
+ //fixme: log -- no memory
+ return false;
+ }
+ bReturn = LoadPublicKeyFromBIO( pPublicKeyControl,
+ pMemBio );
+
+ BIO_free(pMemBio);
+
+ return bReturn;
+}
+
+bool PublicKeyEncrypt (int i_iLength,
+ const unsigned char * const i_pcPlainText,
+ unsigned char * const o_pcCypherText,
+ int * const o_pActualLength,
+ void * pPKeyControl )
+{
+ FATAL_ASSERT( i_pcPlainText );
+ FATAL_ASSERT( o_pcCypherText );
+ FATAL_ASSERT( o_pActualLength );
+ FATAL_ASSERT( pPKeyControl );
+
+ PKeyControl *pKeyControl = (PKeyControl *)pPKeyControl;
+ EVP_PKEY * pEVP_PKEY = pKeyControl->pPKey;
+ RSA * pRSAPublicKey = pEVP_PKEY->pkey.rsa;
+
+//#if defined(DEBUG)
+// RSA_print_fp(stdout, pRSAPublicKey, 0);
+// printf("PublicKeyEncrypt(): RSA_size()=%d, cyphertextLen=%d\n",
+// RSA_size(pRSAPublicKey),
+// i_iLength);
+//#endif
+
+ *o_pActualLength = RSA_public_encrypt(i_iLength,
+ i_pcPlainText,
+ o_pcCypherText,
+ pRSAPublicKey,
+ RSA_PKCS1_PADDING);
+
+ if ( *o_pActualLength < 0 )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentPKIimpl.h b/usr/src/lib/libkmsagent/common/KMSAgentPKIimpl.h
new file mode 100644
index 0000000000..4e506edbe0
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentPKIimpl.h
@@ -0,0 +1,165 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentPKIimpl.h
+ */
+
+#ifndef K_KMSAgentPKIimpl_h
+#define K_KMSAgentPKIimpl_h
+
+/**
+ * initializes the implementation environment for an X509
+ * certificate implementation and returns an opague handle to any
+ * resources that should be freed when use of the X.509
+ * implementation is complete. This handle is used on all
+ * subsequent calls that may need to access this resource.
+ */
+void * InitializeCertImpl();
+
+/**
+ * Save the X.509 Certificate in PEM format to the specified filename
+ */
+bool SaveX509CertTofile(
+ void* const i_pImplResource,
+ const char * const i_pcFileName );
+
+/**
+ * Save the X.509Certificate in PEM format to the specified buffer
+ * and set the length of the certificate in the location referenced
+ * by o_pActualLength
+ */
+bool SaveX509CertToBuffer(
+ void* const i_pImplResource,
+ unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength );
+
+/**
+ * loads the X.509 certificate from i_pcFileName and keeps a reference to it
+ * via i_pImplResource
+ */
+bool LoadX509CertFromFile(
+ void* const i_pImplResource,
+ const char * const i_pcFileName );
+
+/**
+ * load the X.509 certificate from i_pX509Buffer and keeps a reference to it
+ * via i_pImplResource
+ */
+bool LoadX509CertFromBuffer(
+ void* const i_pImplResource,
+ void* const i_pX509Cert,
+ int i_iLength);
+
+/**
+ * frees any resources allocated by <code>InitializeCertImpl</code>
+ */
+void FinalizeCertImpl(
+ void* i_pImplResource);
+
+/**
+ * print the X.509 certificate to stdout
+ */
+bool PrintX509Cert( void* const i_pImplResource );
+
+/**
+ * initializes the implementation environment for a public or private key
+ * and returns an opague handle to any resources that should be freed
+ * when use of the key is complete. This handle is used
+ * on all subsequent calls that may need to access this resource.
+ */
+void * InitializePKeyImpl();
+
+/**
+ * frees any resources allocated by <code>InitializePKeyImpl</code>
+ */
+void FinalizePKeyImpl( void * i_pPKeyImpl );
+
+#ifdef KMSUSERPKCS12
+void *GetPKey( void *i_pImplResource);
+void SetPKey( void *i_pImplResource, void *i_pPKey);
+void *GetCert( void *i_pImplResource);
+void SetCert( void *i_pImplResource, void *cert);
+#endif
+
+/**
+ * Stores the private key in a memory buffer referenced by
+ * i_pcBuffer with the length of the key being stored in the area
+ * referenced by o_pActualLength.
+ *
+ */
+bool SavePrivateKeyToBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ const char * const i_pPassphrase,
+ int i_iFormat);
+
+/**
+ * load the private key into this object from the specified buffer
+ */
+bool LoadPrivateKeyFromBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * i_pcBuffer,
+ int i_iLength,
+ const char * const i_pPassphrase,
+ int i_iFormat);
+
+/**
+ * Stores the pubic key in a memory buffer referenced by
+ * i_pcBuffer with the length of the key being stored in the area
+ * referenced by o_pActualLength.
+ *
+ */
+bool SavePublicKeyToBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * const i_pcBuffer,
+ int i_iBufferLength,
+ int * const o_pActualLength,
+ int i_iFormat);
+
+/**
+ * load a public key into this object from the specified buffer
+ */
+bool LoadPublicKeyFromBuffer(
+ void * const i_pPKeyImpl,
+ unsigned char * i_pcBuffer,
+ int i_iLength,
+ int i_iFormat);
+
+/**
+ * encrypt the plaintext using RSA encryption with the RSA public
+ * key provided and return resulting cyphertext
+ */
+bool PublicKeyEncrypt (int i_iLength,
+ const unsigned char * const i_pcPlainText,
+ unsigned char * const o_pcCypherText,
+ int * const o_pActualLength,
+ void * i_pRSAPublicKey);
+
+#endif // K_KMSAgentPKIimpl_h
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.cpp b/usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.cpp
new file mode 100644
index 0000000000..a8ca63902a
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.cpp
@@ -0,0 +1,148 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include "KMSAgentSoapUtilities.h"
+#include "KMSAgentStringUtilities.h"
+#include "ApplianceParameters.h"
+
+#include "stdsoap2.h"
+
+/**
+ * Get the peer's network address
+ */
+void GetPeerNetworkAddress (char* const o_psPeerNetworkAddress,
+ struct soap* i_pSoap)
+{
+ FATAL_ASSERT(o_psPeerNetworkAddress);
+
+ if (strlen(i_pSoap->host) > 0)
+ {
+ // IPv4 addresses can appear as ::ffff:a.b.c.d, strip off the prefix
+ if (strncmp(i_pSoap->host, "::ffff:", 7) == 0)
+ {
+ strncpy(o_psPeerNetworkAddress, &i_pSoap->host[7], g_iMAX_PEER_NETWORK_ADDRESS_LENGTH);
+ o_psPeerNetworkAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH-1] = '\0';
+ return;
+ }
+ strncpy(o_psPeerNetworkAddress, i_pSoap->host, g_iMAX_PEER_NETWORK_ADDRESS_LENGTH);
+ o_psPeerNetworkAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH-1] = '\0';
+ return;
+ }
+
+ // i_pSoap->ip == 0 could not represent a valid
+ // Peer Network Address (IPv4), check i_pSoap->session_host
+ // for an IPv6 address
+ if (i_pSoap->ip == 0)
+ {
+#ifndef METAWARE
+ if (strlen(i_pSoap->session_host) > 0)
+ {
+ // IPv4 addresses can appear as ::ffff:a.b.c.d, strip off the
+ // prefix
+
+ if (strncmp(i_pSoap->session_host, "::ffff:", 7) == 0)
+ {
+ strncpy(o_psPeerNetworkAddress, &i_pSoap->session_host[7], g_iMAX_PEER_NETWORK_ADDRESS_LENGTH);
+ o_psPeerNetworkAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH-1] = '\0';
+ return;
+ }
+
+ strncpy(o_psPeerNetworkAddress, i_pSoap->session_host, g_iMAX_PEER_NETWORK_ADDRESS_LENGTH);
+ o_psPeerNetworkAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH-1] = '\0';
+ return;
+ }
+#endif
+ strcpy(o_psPeerNetworkAddress, "");
+ return;
+ }
+
+ K_snprintf(o_psPeerNetworkAddress,
+ g_iMAX_PEER_NETWORK_ADDRESS_LENGTH,
+ "%d.%d.%d.%d",
+ (int) (i_pSoap->ip >> 24)&0xFF,
+ (int) (i_pSoap->ip >> 16)&0xFF,
+ (int) (i_pSoap->ip >> 8)&0xFF,
+ (int) (i_pSoap->ip)&0xFF);
+
+ return;
+}
+
+/**
+ * Get the soap fault code and print it
+ */
+void GetSoapFault(char* o_psFaultMessage,
+ struct soap *i_pstSoap)
+{
+ FATAL_ASSERT( i_pstSoap );
+
+ strncpy (o_psFaultMessage, " SoapFaultCode=",g_iMAX_SOAP_FAULT_MESSAGE_LENGTH);
+ o_psFaultMessage[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH-1] = '\0';
+ strncat (o_psFaultMessage, GET_SOAP_FAULTCODE(i_pstSoap),
+ g_iMAX_SOAP_FAULT_MESSAGE_LENGTH-strlen(o_psFaultMessage));
+ strncat (o_psFaultMessage, " SoapFaultString=",
+ g_iMAX_SOAP_FAULT_MESSAGE_LENGTH-strlen(o_psFaultMessage));
+ strncat (o_psFaultMessage, GET_SOAP_FAULTSTRING(i_pstSoap),
+ g_iMAX_SOAP_FAULT_MESSAGE_LENGTH-strlen(o_psFaultMessage));
+ strncat (o_psFaultMessage, " SoapFaultDetail=",
+ g_iMAX_SOAP_FAULT_MESSAGE_LENGTH-strlen(o_psFaultMessage));
+ strncat (o_psFaultMessage, GET_SOAP_FAULTDETAIL(i_pstSoap),
+ g_iMAX_SOAP_FAULT_MESSAGE_LENGTH-strlen(o_psFaultMessage));
+
+ return;
+}
+
+bool PutBinaryIntoSoapBinary(
+ struct soap* i_pSoap,
+ const unsigned char* i_pBinary,
+ int i_iBinarySize,
+ unsigned char*& o_pSoapBinary,
+ int& o_iSoapBinarySize )
+{
+ FATAL_ASSERT( i_pSoap );
+
+ o_pSoapBinary = 0;
+ o_iSoapBinarySize = 0;
+
+ if ( i_iBinarySize > 0 )
+ {
+ o_pSoapBinary =
+ (unsigned char*)soap_malloc(
+ i_pSoap,
+ sizeof(unsigned char) * i_iBinarySize);
+
+ if ( !o_pSoapBinary )
+ {
+ // No log for out of memory condition
+
+ return false;
+ }
+
+ o_iSoapBinarySize = i_iBinarySize;
+
+ memcpy(o_pSoapBinary, i_pBinary, i_iBinarySize);
+ }
+
+ return true;
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.h b/usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.h
new file mode 100644
index 0000000000..510839eb41
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentSoapUtilities.h
@@ -0,0 +1,75 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentSoapUtilities.h
+ */
+
+#ifndef KMSAgentSoapUtilities_h
+#define KMSAgentSoapUtilities_h
+
+/**
+ * maximum length of a network IP address
+ */
+static const int g_iMAX_PEER_NETWORK_ADDRESS_LENGTH = 50;
+
+/**
+ * maximum length of a soap fault message string
+ */
+static const int g_iMAX_SOAP_FAULT_MESSAGE_LENGTH = 256;
+
+//BEN CHANGE - removed predeclaration of struct soap
+// need the real declaration
+//struct soap;
+
+/**
+ * copies at most g_iMAX_PEER_NETWORK_ADDRESS_LENGTH characters
+ * from the peer's network address from the soap runtime context.
+ * <code>o_psPeerNetworkAddress</code> should be at least
+ * <code>g_iMAX_PEER_NETWORK_ADDRESS_LENGTH</code> in length.
+ */
+void GetPeerNetworkAddress( char* const o_psPeerNetworkAddress,
+ struct soap* i_pSoap );
+
+/**
+ * creates a soap fault message and stores it in o_psFaultMessage. The fault message
+ * has the form: " SoapFaultCode=%s SoapFaultString=%s SoapFaultDetail=%s" with the
+ * appropriate values substitued for %s from the soap runtime.
+ * @param o_psFaultMessage a buffer for the fault message that is at least
+ * <code>g_iMAX_SOAP_FAULT_MESSAGE_LENGTH</code> in size.
+ * @param i_pstSoap the soap runtime context to process for fault information
+ */
+// BEN - removed const
+void GetSoapFault(char* o_psFaultMessage,
+ struct soap *i_pstSoap);
+
+bool PutBinaryIntoSoapBinary(
+ struct soap* i_pSoap,
+ const unsigned char* i_pBinary,
+ int i_iBinarySize,
+ unsigned char*& o_pSoapBinary,
+ int& o_iSoapBinarySize );
+
+#endif //KMSAgentSoapUtilities_h
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentStorage.cpp b/usr/src/lib/libkmsagent/common/KMSAgentStorage.cpp
new file mode 100644
index 0000000000..586144c7a0
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentStorage.cpp
@@ -0,0 +1,1575 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentStorage.cpp
+ * This file provides an implementation of the KMSAgentStorage.h
+ * interface utilizing a filesystem for storage of KMS Client
+ * Profile elements.
+ *
+ * For storage of Certificates and Private key material the PKICommon
+ * interface is used.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#ifndef METAWARE
+#include <errno.h>
+#endif
+
+#ifdef K_SOLARIS_PLATFORM
+#ifndef SOLARIS10
+#include <cryptoutil.h>
+#endif
+#include <pthread.h>
+#include <fcntl.h>
+#endif
+
+#include "stdsoap2.h"
+
+#include "KMSClientProfile.h" // must be before agentstorage
+#include "KMSAgentPKICommon.h" // must be before agentstorage
+#include "KMSAgentStorage.h"
+
+#include "SYSCommon.h"
+#include "AutoMutex.h"
+#include "KMSAuditLogger.h"
+#include "KMSClientProfileImpl.h"
+
+#include "KMSAgent_direct.h"
+#ifdef K_SOLARIS_PLATFORM
+#include "KMSAgent.h"
+#endif
+#include "k_setupssl.h" // K_ssl_client_context
+
+#ifdef METAWARE
+extern "C" int K_ssl_client_context(struct soap *soap,
+ int flags,
+ const char *keyfile, // NULL - SERVER
+ const char *password, // NULL - SERVER
+ const char *cafile,
+ const char *capath, // ALWAYS NULL
+ const char *randfile); // ALWAYS NULL
+#include "debug.h"
+#endif
+
+
+#define CA_CERTIFICATE_FILE "ca.crt"
+#define CLIENT_KEY_FILE "clientkey.pem"
+
+#define PROFILE_CONFIG_FILE "profile.cfg"
+#define PROFILE_CLUSTER_CONFIG_FILE "cluster.cfg"
+
+static char g_sWorkingDirectory[KMS_MAX_PATH_LENGTH+1];
+static char g_sStringbuf[10000]; // too large to be on the 9840D stack
+
+static void BuildFullProfilePathWithName(utf8cstr o_pProfilePath,
+ const char* const i_pWorkingDirectory,
+ const char* const i_pProfileName)
+{
+ int len;
+ FATAL_ASSERT( o_pProfilePath );
+ FATAL_ASSERT( i_pWorkingDirectory );
+ FATAL_ASSERT( i_pProfileName );
+ FATAL_ASSERT( (strlen(i_pWorkingDirectory) > 0) );
+ FATAL_ASSERT( (strlen(i_pProfileName) > 0) );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, BuildFullProfilePathWithName );
+#endif
+
+ strncpy(o_pProfilePath, i_pWorkingDirectory,
+ KMS_MAX_FILE_NAME );
+
+ if ( o_pProfilePath[ strlen(o_pProfilePath) -1 ] != PATH_SEPARATOR )
+ {
+ len = strlen(o_pProfilePath);
+ o_pProfilePath[ len ] = PATH_SEPARATOR ;
+ o_pProfilePath[ len + 1 ] = '\0';
+ }
+
+ strncat( o_pProfilePath, i_pProfileName, KMS_MAX_FILE_NAME );
+ len = strlen(o_pProfilePath);
+ o_pProfilePath[ len ] = PATH_SEPARATOR ;
+ o_pProfilePath[ len +1 ] = '\0';
+
+ return;
+}
+
+static void BuildFullProfilePath(utf8cstr o_sProfilePath,
+ const char* const i_pWorkingDirectory,
+ const char* const i_pProfileName)
+{
+ FATAL_ASSERT( o_sProfilePath );
+ FATAL_ASSERT( i_pWorkingDirectory );
+ FATAL_ASSERT( i_pProfileName );
+ FATAL_ASSERT( (strlen(i_pProfileName) > 0) );
+
+ BuildFullProfilePathWithName( o_sProfilePath,
+ i_pWorkingDirectory,
+ i_pProfileName );
+
+ return;
+}
+
+#ifdef K_SOLARIS_PLATFORM
+static struct flock cfgfl = {
+ 0, 0, 0, 0, 0, 0,
+ {0, 0, 0, 0}
+};
+static struct flock clusterfl = {
+ 0, 0, 0, 0, 0, 0,
+ {0, 0, 0, 0}
+};
+
+pthread_mutex_t cfg_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t cluster_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t keyfile_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static int
+flock_fd(int fd, int cmd, struct flock *fl, pthread_mutex_t *mutex)
+{
+ int ret = 0;
+
+ (void) pthread_mutex_lock(mutex);
+
+ fl->l_type = cmd;
+
+ while ((ret = fcntl(fd, F_SETLKW, fl)) == -1) {
+ if (errno != EINTR)
+ break;
+ }
+ (void) pthread_mutex_unlock(mutex);
+ return (ret);
+}
+
+#endif
+
+static bool Profile_WriteConfigFile(KMSClientProfile *i_pProfile,
+ const char *i_pFileName)
+{
+ FATAL_ASSERT( i_pProfile );
+ FATAL_ASSERT( i_pFileName );
+
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, Profile_WriteConfigFile );
+#endif
+
+ char *sp = g_sStringbuf;
+ size_t bytesWritten = 0;
+
+ // save config parameters
+
+ myFILE *fp = fopen(i_pFileName, "w");
+ if(fp == NULL)
+ {
+ LogError(i_pProfile,
+ AUDIT_PROFILE_WRITE_CONFIG_FILE_OPEN_CONFIGURATION_FILE_FAILED,
+ NULL,
+ NULL,
+ i_pFileName);
+
+ return false;
+ }
+
+#ifdef K_SOLARIS_PLATFORM
+ int fd = fileno(fp);
+ (void) flock_fd(fd, F_WRLCK, &cfgfl, &cfg_mutex);
+#endif
+
+const char* const sProfileName = i_pProfile->m_wsProfileName;
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "ProfileName=%s\n", sProfileName);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "AgentID=%s\n", i_pProfile->m_wsEntityID);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "ClusterDiscoveryFrequency=%d\n",
+ i_pProfile->m_iClusterDiscoveryFrequency);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "CAServicePortNumber=%d\n",
+ i_pProfile->m_iPortForCAService);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "CertificateServicePortNumber=%d\n",
+ i_pProfile->m_iPortForCertificateService);
+
+ if(i_pProfile->m_iPortForAgentService != 0)
+ {
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "AgentServicePortNumber=%d\n",
+ i_pProfile->m_iPortForAgentService);
+ }
+
+ if(i_pProfile->m_iPortForDiscoveryService != 0)
+ {
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "DiscoveryServicePortNumber=%d\n",
+ i_pProfile->m_iPortForDiscoveryService);
+ }
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "ApplianceAddress=%s\n", i_pProfile->m_wsApplianceAddress);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "Timeout=%d\n", i_pProfile->m_iTransactionTimeout);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "FailoverLimt=%d\n", i_pProfile->m_iFailoverLimit);
+
+ sp += K_snprintf(sp, sizeof(i_pProfile->m_wsProfileName), "HexHashedPassphrase=%s\n", i_pProfile->m_sHexHashedPassphrase);
+
+ bytesWritten = fputs(g_sStringbuf, fp);
+
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &cfgfl, &cfg_mutex);
+#endif
+
+#ifndef WIN32
+ if ( strlen(g_sStringbuf) != bytesWritten )
+#else
+ if ( bytesWritten < 0 )
+#endif
+ {
+ fclose(fp);
+ return false;
+ }
+ fclose(fp);
+
+ return true;
+}
+
+static bool Profile_ReadConfigFile
+( KMSClientProfile *i_pProfile,
+ const char *i_pFileName)
+{
+ FATAL_ASSERT( i_pProfile );
+ FATAL_ASSERT( i_pFileName );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, Profile_ReadConfigFile ) ;
+#endif
+
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+
+ const int iMaxLineSize = 1024;
+
+ myFILE *fp;
+ char acBuffer[iMaxLineSize+1];
+
+ fp = fopen(i_pFileName, "r");
+ if(fp == NULL)
+ {
+ LogError(i_pProfile,
+ AUDIT_PROFILE_READ_CONFIG_FILE_OPEN_CONFIGURATION_FILE_FAILED,
+ NULL,
+ NULL,
+ i_pFileName);
+ return false;
+ }
+
+#ifdef K_SOLARIS_PLATFORM
+ int fd = fileno(fp);
+ (void) flock_fd(fd, F_RDLCK, &cfgfl, &cfg_mutex);
+#endif
+ // read file one line by one line
+ while(1)
+ {
+ int i;
+ char *pName, *pValue;
+
+ memset(acBuffer, 0, iMaxLineSize+1);
+
+ //---------------------------
+ // get info from the file
+ //---------------------------
+ if(fgets(acBuffer, iMaxLineSize+1, fp) == NULL)
+ break;
+
+ if(strlen(acBuffer) < 3)
+ continue;
+
+ if(acBuffer[0] == '#' ||
+ acBuffer[0] == ';' ||
+ acBuffer[0] == '[') // jump comments
+ continue;
+
+ pName = acBuffer;
+ pValue = NULL;
+
+ for(i = 0; acBuffer[i] != '\0'; i++)
+ {
+ if(acBuffer[i] == '=')
+ pValue = acBuffer + i + 1;
+
+ if(acBuffer[i] == '=' ||
+ acBuffer[i] == '\r' ||
+ acBuffer[i] == '\n')
+ acBuffer[i] = '\0';
+ }
+
+ if(pValue == NULL)
+ {
+ LogError(i_pProfile,
+ AUDIT_PROFILE_READ_CONFIG_FILE_INVALID_CONFIGURATION_FILE_FORMAT,
+ NULL,
+ NULL,
+ i_pFileName);
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &cfgfl, &cfg_mutex);
+#endif
+ fclose(fp);
+ return false;
+ }
+
+ if(strcmp(pName, "ProfileName") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(i_pProfile->m_wsProfileName, wsValue, KMS_MAX_ENTITY_ID);
+ i_pProfile->m_wsProfileName[KMS_MAX_ENTITY_ID] = 0;
+ }
+
+ if(strcmp(pName, "AgentID") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(i_pProfile->m_wsEntityID, wsValue, KMS_MAX_ENTITY_ID);
+ i_pProfile->m_wsEntityID[KMS_MAX_ENTITY_ID] = 0;
+ }
+
+ if(strcmp(pName, "ClusterDiscoveryFrequency") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iClusterDiscoveryFrequency));
+ }
+
+ if(strcmp(pName, "CAServicePortNumber") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iPortForCAService));
+ }
+
+ if(strcmp(pName, "CertificateServicePortNumber") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iPortForCertificateService));
+ }
+
+ if(strcmp(pName, "AgentServicePortNumber") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iPortForAgentService));
+ }
+
+ if(strcmp(pName, "DiscoveryServicePortNumber") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iPortForDiscoveryService));
+ }
+
+ if(strcmp(pName, "ApplianceAddress") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(i_pProfile->m_wsApplianceAddress,
+ wsValue, KMS_MAX_NETWORK_ADDRESS);
+ i_pProfile->m_wsApplianceAddress[KMS_MAX_NETWORK_ADDRESS] = 0;
+ }
+
+ if(strcmp(pName, "Timeout") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iTransactionTimeout));
+ }
+
+ if(strcmp(pName, "FailoverLimt") == 0)
+ {
+ sscanf(pValue, "%d", &(i_pProfile->m_iFailoverLimit));
+ }
+
+ if(strcmp(pName, "HexHashedPassphrase") == 0)
+ {
+ sscanf(pValue, "%s", i_pProfile->m_sHexHashedPassphrase);
+ }
+ }
+
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &cfgfl, &cfg_mutex);
+#endif
+ fclose(fp);
+
+ return true;
+}
+
+
+
+
+
+/*! ProfileExists
+ *
+ */
+extern "C" bool ProfileExists(
+ const char* const i_pWorkingDirectory,
+ const char* const i_pProfileName)
+{
+ FATAL_ASSERT( i_pWorkingDirectory );
+ FATAL_ASSERT( i_pProfileName );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, ProfileExists );
+#endif
+
+
+ // the profile is stored in the working folder
+ strncpy( g_sWorkingDirectory,
+ i_pWorkingDirectory,
+ KMS_MAX_PATH_LENGTH );
+
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+ BuildFullProfilePath( sFullProfileDir,
+ i_pWorkingDirectory,
+ i_pProfileName );
+
+ char sConfigFile[KMS_MAX_FILE_NAME+1] = "";
+ strncpy( sConfigFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sConfigFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sConfigFile, PROFILE_CONFIG_FILE, KMS_MAX_FILE_NAME );
+
+ // just try to open the file to test if it exists
+
+ bool bProfileExists = false;
+
+ myFILE* pfFile = fopen( sConfigFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ bProfileExists = true;
+
+ fclose(pfFile);
+ }
+
+ return bProfileExists;
+}
+
+
+/*! CreateProfile
+ *
+ */
+bool CreateProfile(
+ KMSClientProfile* const io_pProfile,
+ const char* const i_pWorkingDirectory,
+ const char* const i_pProfileName)
+{
+ FATAL_ASSERT( io_pProfile );
+ FATAL_ASSERT( i_pWorkingDirectory );
+ FATAL_ASSERT( i_pProfileName );
+ FATAL_ASSERT( (strlen(i_pProfileName) > 0) );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, CreateProfile );
+
+#endif
+
+ bool bSuccess = false;
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)io_pProfile->m_pLock );
+
+ char sFullProfileDir[KMS_MAX_FILE_NAME];
+ BuildFullProfilePath( sFullProfileDir,
+ i_pWorkingDirectory,
+ i_pProfileName );
+
+ bSuccess = ( K_CreateDirectory( sFullProfileDir ) == 0 );
+
+ if ( !bSuccess )
+ {
+ Log(AUDIT_CLIENT_LOAD_PROFILE_CREATE_DIRECTORY_FAILED,
+ NULL,
+ NULL,
+ NULL );
+ }
+ strncpy( g_sWorkingDirectory, i_pWorkingDirectory, KMS_MAX_PATH_LENGTH );
+
+ bSuccess = StoreConfig( io_pProfile );
+ if ( !bSuccess )
+ {
+ Log(AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_FAILED,
+ NULL,
+ NULL,
+ NULL );
+ }
+ else
+ {
+ Log(AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_SUCCEEDED,
+ NULL,
+ NULL,
+ NULL );
+ }
+
+ return bSuccess;
+}
+
+
+/*! StoreConfig
+ * Store the configuration to persistent storage
+ */
+bool StoreConfig(
+ KMSClientProfile* const i_pProfile )
+{
+ FATAL_ASSERT( i_pProfile );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, StoreConfig ) ;
+#endif
+
+ char sConfigFile[KMS_MAX_FILE_NAME];
+ BuildFullProfilePath( sConfigFile,
+ g_sWorkingDirectory, i_pProfile->m_wsProfileName );
+
+ strncat( sConfigFile, PROFILE_CONFIG_FILE, KMS_MAX_FILE_NAME );
+
+ return Profile_WriteConfigFile(i_pProfile, sConfigFile );
+}
+
+/*! StoreCluster
+ * Store the cluster to persistent storage
+ */
+bool StoreCluster(
+ KMSClientProfile* const i_pProfile )
+{
+ FATAL_ASSERT( i_pProfile );
+
+ myFILE *fp;
+ int sCount;
+ char *sp = g_sStringbuf;
+
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+ BuildFullProfilePath( sFullProfileDir,
+ g_sWorkingDirectory, i_pProfile->m_wsProfileName );
+
+ char sClusterFile[KMS_MAX_FILE_NAME+1] = "";
+ strncpy( sClusterFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sClusterFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sClusterFile, PROFILE_CLUSTER_CONFIG_FILE, KMS_MAX_FILE_NAME );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, StoreCluster );
+#endif
+
+
+ fp = fopen(sClusterFile, "w");
+ if (fp == NULL)
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_SAVE_CLUSTER_INFORMATION_OPEN_CLUSTER_FILE_FAILED,
+ NULL,
+ NULL,
+ sClusterFile );
+ return false;
+ }
+
+#ifdef K_SOLARIS_PLATFORM
+ int fd = fileno(fp);
+ (void) flock_fd(fd, F_WRLCK, &clusterfl, &cluster_mutex);
+#endif
+
+ sp += K_snprintf(sp, sizeof(g_sStringbuf), "EntitySiteID=%s\n\n", i_pProfile->m_wsEntitySiteID);
+
+ for (int i = 0; i < i_pProfile->m_iClusterNum; i++)
+ {
+ if ( i > 0 )
+ {
+ sp += K_snprintf(sp, sizeof(g_sStringbuf), "\n");
+ }
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf),"<StartAppliance>\n")) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+#ifdef WIN32
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "ApplianceID=%I64d\n",
+ i_pProfile->m_aCluster[i].m_lApplianceID)) < 0 )
+ { fclose(fp); return false; }
+ sp += sCount;
+
+#else
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "ApplianceID=%lld\n",
+ i_pProfile->m_aCluster[i].m_lApplianceID)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+#endif
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "Enabled=%d\n",
+ i_pProfile->m_aCluster[i].m_iEnabled)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "Responding=%d\n",
+ i_pProfile->m_aCluster[i].m_iResponding)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "Load=%lld\n",
+ i_pProfile->m_aCluster[i].m_lLoad)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "ApplianceAlias=%s\n",
+ i_pProfile->m_aCluster[i].m_wsApplianceAlias)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "ApplianceNetworkAddress=%s\n",
+ i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "ApplianceSiteID=%s\n",
+ i_pProfile->m_aCluster[i].m_wsApplianceSiteID)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "KMAVersion=%s\n",
+ i_pProfile->m_aCluster[i].m_sKMAVersion)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "KMALocked=%d\n",
+ i_pProfile->m_aCluster[i].m_iKMALocked)) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+
+ if (( sCount = K_snprintf(sp, sizeof(g_sStringbuf), "<EndAppliance>\n")) < 0 )
+ {
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ return false; }
+ sp += sCount;
+ }
+
+ fputs(g_sStringbuf, fp);
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+ Log(AUDIT_CLIENT_SAVE_CLUSTER_INFORMATION_SUCCEEDED,
+ NULL,
+ NULL,
+ NULL );
+
+ return true;
+}
+
+/*! GetConfig
+ * get the configuration file from persistent storage
+ */
+bool GetConfig(
+ KMSClientProfile* const io_pProfile )
+{
+ FATAL_ASSERT( io_pProfile );
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+
+ BuildFullProfilePath( sFullProfileDir,
+ g_sWorkingDirectory,
+ io_pProfile->m_wsProfileName );
+
+ char sConfigFile[KMS_MAX_FILE_NAME+1];
+
+ strncpy( sConfigFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sConfigFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sConfigFile, PROFILE_CONFIG_FILE, KMS_MAX_FILE_NAME );
+
+ return Profile_ReadConfigFile( io_pProfile, sConfigFile );
+}
+
+/** GetCluster
+ * get the cluster information from persistent storage
+ */
+bool GetCluster(
+ KMSClientProfile* const io_pProfile,
+ int& o_bClusterInformationFound )
+
+{
+ FATAL_ASSERT( io_pProfile );
+
+ const int iMaxLineSize = 1024;
+
+ myFILE *fp;
+ char acBuffer[iMaxLineSize+1];
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+
+ BuildFullProfilePath( sFullProfileDir,
+ g_sWorkingDirectory,
+ io_pProfile->m_wsProfileName );
+
+ char sClusterFile[KMS_MAX_FILE_NAME+1];
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, GetCluster );
+#endif
+
+ strncpy( sClusterFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sClusterFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sClusterFile, PROFILE_CLUSTER_CONFIG_FILE, KMS_MAX_FILE_NAME );
+
+ fp = fopen( sClusterFile, "r" );
+
+ if ( fp == NULL )
+ {
+#ifdef METAWARE
+ // Assume file doesn't exist. This isn't an error (no support for
+ // errno in metaware).
+ o_bClusterInformationFound = 0;
+ return true;
+#else
+ if ( errno == ENOENT )
+ {
+ // File doesn't exist. This isn't an error.
+ o_bClusterInformationFound = 0;
+ return true;
+ }
+
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_CLUSTER_INFORMATION_OPEN_CLUSTER_FILE_FAILED,
+ NULL,
+ NULL,
+ sClusterFile );
+ return false;
+#endif
+ }
+
+#ifdef K_SOLARIS_PLATFORM
+ int fd = fileno(fp);
+ (void) flock_fd(fd, F_WRLCK, &clusterfl, &cluster_mutex);
+#endif
+
+ o_bClusterInformationFound = 1;
+ int i;
+ // KMAVersion is new to Cluster config with 2.1 KMS and will not exist
+ // in persisted cluster configs from earlier agents
+ for ( i = 0; i < KMS_MAX_CLUSTER_NUM; i++ )
+ {
+ io_pProfile->m_aCluster[i].m_sKMAVersion[0] = '\0';
+ }
+
+ int iClusterNum = 0;
+ // read file one line by one line
+ while(1)
+ {
+ int i;
+ char *pName, *pValue;
+
+ memset(acBuffer, 0, iMaxLineSize+1);
+
+ // get info from the file
+ if(fgets(acBuffer, iMaxLineSize+1, fp) == NULL)
+ break;
+
+ if(strlen(acBuffer) < 3)
+ continue;
+
+ if(acBuffer[0] == '#' ||
+ acBuffer[0] == ';' ||
+ acBuffer[0] == '[') // jump comments
+ continue;
+
+ pName = acBuffer; pValue = NULL;
+ for(i = 0; acBuffer[i] != '\0'; i++)
+ {
+ if(acBuffer[i] == '=')
+ pValue = acBuffer + i + 1;
+
+ if(acBuffer[i] == '=' ||
+ acBuffer[i] == '\r' ||
+ acBuffer[i] == '\n')
+ acBuffer[i] = '\0';
+ }
+
+ if(strcmp(pName, "<StartAppliance>") == 0)
+ {
+ continue;
+ }
+ if(strcmp(pName, "<EndAppliance>") == 0)
+ {
+ iClusterNum++;
+ }
+
+ if(pValue == NULL)
+ {
+ if(strcmp(pName,"<StartAppliance>") == 0)
+ continue;
+
+ if(strcmp(pName,"<EndAppliance>") == 0)
+ continue;
+
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_CLUSTER_INFORMATION_INVALID_CLUSTER_FILE_FORMAT,
+ NULL,
+ NULL,
+ sClusterFile );
+ return false;
+ }
+
+ if(strcmp(pName, "EntitySiteID") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(io_pProfile->m_wsEntitySiteID, wsValue, KMS_MAX_ENTITY_SITE_ID);
+ io_pProfile->m_wsEntitySiteID[KMS_MAX_ENTITY_SITE_ID] = 0;
+ }
+
+
+ if(strcmp(pName, "ApplianceID") == 0)
+ {
+#ifdef WIN32
+ sscanf(pValue, "%lld",
+ &(io_pProfile->m_aCluster[iClusterNum].m_lApplianceID));
+#else
+ sscanf(pValue, "%lld",
+ &(io_pProfile->m_aCluster[iClusterNum].m_lApplianceID));
+#endif
+ }
+ if(strcmp(pName, "Enabled") == 0)
+ {
+ sscanf(pValue, "%d",
+ &(io_pProfile->m_aCluster[iClusterNum].m_iEnabled));
+ }
+
+ // assume it is responding by default
+ io_pProfile->m_aCluster[iClusterNum].
+ m_iResponding = TRUE;
+
+ if(strcmp(pName, "Load") == 0)
+ {
+ sscanf(pValue, "%lld",
+ &(io_pProfile->m_aCluster[iClusterNum].m_lLoad));
+ }
+ if(strcmp(pName, "ApplianceAlias") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(io_pProfile->m_aCluster[iClusterNum].m_wsApplianceAlias,
+ wsValue,
+ KMS_MAX_ENTITY_ID);
+ io_pProfile->m_aCluster[iClusterNum].
+ m_wsApplianceAlias[KMS_MAX_ENTITY_ID] = 0;
+
+ }
+ if(strcmp(pName, "ApplianceNetworkAddress") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(io_pProfile->m_aCluster[iClusterNum].
+ m_wsApplianceNetworkAddress,
+ wsValue,
+ KMS_MAX_NETWORK_ADDRESS);
+ io_pProfile->m_aCluster[iClusterNum].
+ m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS] = 0;
+ }
+ if(strcmp(pName, "ApplianceSiteID") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(io_pProfile->m_aCluster[iClusterNum].m_wsApplianceSiteID,
+ wsValue,
+ KMS_MAX_ENTITY_SITE_ID);
+ io_pProfile->m_aCluster[iClusterNum].
+ m_wsApplianceSiteID[KMS_MAX_ENTITY_SITE_ID] = 0;
+ }
+ if(strcmp(pName, "KMAVersion") == 0)
+ {
+ utf8cstr wsValue = pValue;
+ strncpy(io_pProfile->m_aCluster[iClusterNum].m_sKMAVersion,
+ wsValue,
+ KMS_MAX_VERSION_LENGTH);
+ io_pProfile->m_aCluster[iClusterNum].
+ m_sKMAVersion[KMS_MAX_VERSION_LENGTH] = '\0';
+ }
+ if(strcmp(pName, "KMALocked") == 0)
+ {
+ sscanf(pValue, "%d",
+ &(io_pProfile->m_aCluster[iClusterNum].m_iKMALocked));
+ }
+ }
+ io_pProfile->m_iClusterNum = iClusterNum;
+
+#ifdef K_SOLARIS_PLATFORM
+ (void) flock_fd(fd, F_UNLCK, &clusterfl, &cluster_mutex);
+#endif
+ fclose(fp);
+
+ return true;
+}
+
+/*! DeleteCluster
+ *
+ */
+bool DeleteCluster( KMSClientProfile* const io_pProfile )
+{
+ FATAL_ASSERT( io_pProfile );
+ FATAL_ASSERT( io_pProfile->m_wsProfileName );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, DeleteCluster );
+#endif
+
+ bool bSuccess = true;
+ char sFullProfileDir[KMS_MAX_FILE_NAME];
+ char sClusterInformationFile[KMS_MAX_FILE_NAME];
+
+ BuildFullProfilePathWithName( sFullProfileDir, g_sWorkingDirectory,
+ io_pProfile->m_wsProfileName );
+
+ strcpy( sClusterInformationFile, sFullProfileDir );
+ strncat( sClusterInformationFile, PROFILE_CLUSTER_CONFIG_FILE,
+ KMS_MAX_FILE_NAME );
+
+ myFILE* pfFile = fopen( sClusterInformationFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ if ( my_unlink(sClusterInformationFile) )
+ bSuccess = false;
+ }
+
+ return true;
+}
+
+/*! StoreCACertificate
+ * Store CA Certificate to a persistent storage file
+ * @param i_pProfile
+ * @param i_pCACertificate
+ *
+ * @returns boolean success or failure
+ */
+bool StoreCACertificate(
+ KMSClientProfile* const i_pProfile,
+ CCertificate* const i_pCACertificate )
+{
+ FATAL_ASSERT( i_pProfile );
+ FATAL_ASSERT( i_pCACertificate );
+
+ char sCACertificateFile[KMS_MAX_FILE_NAME];
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, StoreCACertificate );
+#endif
+
+ BuildFullProfilePath( sCACertificateFile,
+ g_sWorkingDirectory,
+ i_pProfile->m_wsProfileName );
+
+ strncat( sCACertificateFile, CA_CERTIFICATE_FILE, KMS_MAX_FILE_NAME );
+
+ // OVERLOADED Save method - 2 parameters means save to a file
+ if ( !( i_pCACertificate->Save(sCACertificateFile, PKI_FORMAT)) )
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_SAVE_CA_CERTIFICATE_FAILED,
+ NULL,
+ NULL,
+ sCACertificateFile );
+ return false;
+ }
+ return true;
+
+}
+
+/*! StoreAgentPKI
+ * Store Private Keys a persistent storage file
+ *
+ */
+#ifndef K_SOLARIS_PLATFORM
+static
+#endif
+bool StoreAgentPKI(
+ KMSClientProfile* const i_pProfile,
+ CCertificate* const i_pAgentCertificate,
+ CPrivateKey* const i_pAgentPrivateKey,
+ const char* const i_sHexHashedPassphrase )
+{
+ FATAL_ASSERT( i_pProfile );
+ FATAL_ASSERT( i_pAgentCertificate );
+
+ bool bSuccess;
+ char sClientKeyFile[KMS_MAX_FILE_NAME];
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, StoreAgentPKI ) ;
+#endif
+
+ BuildFullProfilePath( sClientKeyFile,
+ g_sWorkingDirectory,
+ i_pProfile->m_wsProfileName );
+
+ strncat( sClientKeyFile,
+#ifdef KMSUSERPKCS12
+ CLIENT_PK12_FILE,
+#else
+ CLIENT_KEY_FILE,
+#endif
+ KMS_MAX_FILE_NAME );
+
+ CPKI oPKI;
+
+ // save Certificate and Private Key to file named sClientKeyFile(CLIENT_KEY_FILE)
+ bSuccess = oPKI.ExportCertAndKeyToFile(
+ i_pAgentCertificate,
+ i_pAgentPrivateKey,
+ sClientKeyFile,
+ i_sHexHashedPassphrase,
+#ifdef KMSUSERPKCS12
+ PKCS12_FORMAT
+#else
+ PKI_FORMAT
+#endif
+ );
+
+ if ( !bSuccess )
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_EXPORT_CERTIFICATE_AND_KEY_FAILED,
+ NULL,
+ NULL,
+ sClientKeyFile );
+ }
+ return bSuccess;
+}
+
+/*! StorePKIcerts
+ * Store PKI objects to persistent storage files
+ */
+bool StorePKIcerts(
+ KMSClientProfile* const io_pProfile,
+ CCertificate* const i_pCACertificate,
+ CCertificate* const i_pAgentCertificate,
+ CPrivateKey* const i_pAgentPrivateKey,
+ const char* const i_sHexHashedPassphrase )
+{
+ FATAL_ASSERT( io_pProfile );
+ FATAL_ASSERT( i_pAgentCertificate );
+
+ bool bSuccess = false;
+
+ bSuccess = StoreCACertificate( io_pProfile, i_pCACertificate );
+
+ if ( bSuccess )
+ {
+ bSuccess = StoreAgentPKI( io_pProfile,
+ i_pAgentCertificate,
+ i_pAgentPrivateKey,
+ i_sHexHashedPassphrase );
+ }
+
+ if ( bSuccess )
+ {
+ io_pProfile->m_iEnrolled = TRUE;
+ }
+
+ return bSuccess;
+}
+
+#ifdef KMSUSERPKCS12
+
+/*
+ * Test to see if the PKCS12 file exists.
+ */
+bool ClientKeyP12Exists(char *profileName)
+{
+ bool bSuccess = true;
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+ char sAgentPK12File[KMS_MAX_FILE_NAME+1];
+ struct stat statp;
+
+ BuildFullProfilePath(sFullProfileDir,
+ g_sWorkingDirectory, profileName);
+
+ strncpy( sAgentPK12File, sFullProfileDir, KMS_MAX_FILE_NAME );
+ strncat( sAgentPK12File, CLIENT_PK12_FILE, KMS_MAX_FILE_NAME );
+
+ bSuccess = false;
+ if (stat(sAgentPK12File, &statp) == -1)
+ bSuccess = false;
+ else if (statp.st_size > 0)
+ bSuccess = true;
+
+ return (bSuccess);
+}
+
+/*
+ * Load the cert and the private key from the PKCS12 file.
+ */
+bool GetPKCS12CertAndKey(
+ KMSClientProfile* const io_pProfile,
+ utf8char *i_pPassphrase,
+ CCertificate *i_pEntityCert,
+ CPrivateKey *i_pEntityPrivateKey)
+{
+ bool bSuccess = true;
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+ char sAgentPK12File[KMS_MAX_FILE_NAME+1];
+
+ BuildFullProfilePath(sFullProfileDir,
+ g_sWorkingDirectory, io_pProfile->m_wsProfileName );
+
+ strncpy( sAgentPK12File, sFullProfileDir, KMS_MAX_FILE_NAME );
+ strncat( sAgentPK12File, CLIENT_PK12_FILE, KMS_MAX_FILE_NAME );
+
+ bSuccess = i_pEntityCert->LoadPKCS12CertAndKey(
+ sAgentPK12File, FILE_FORMAT_PKCS12,
+ i_pEntityPrivateKey, i_pPassphrase);
+
+ if (!bSuccess)
+ io_pProfile->m_iLastErrorCode = KMS_AGENT_LOCAL_AUTH_FAILURE;
+
+ return (bSuccess);
+}
+
+bool StoreTempAgentPKI(
+ KMSClientProfile* const i_pProfile,
+ CCertificate* i_pAgentCertificate,
+ CPrivateKey* i_pAgentPrivateKey)
+{
+ FATAL_ASSERT( i_pProfile );
+ FATAL_ASSERT( i_pAgentCertificate );
+
+ bool bSuccess;
+ char sClientKeyFile[KMS_MAX_FILE_NAME];
+
+ BuildFullProfilePath( sClientKeyFile,
+ g_sWorkingDirectory,
+ i_pProfile->m_wsProfileName );
+
+ strncat(sClientKeyFile,
+ CLIENT_KEY_FILE,
+ KMS_MAX_FILE_NAME );
+
+ CPKI oPKI;
+
+ // save Certificate and Private Key to file named sClientKeyFile(CLIENT_KEY_FILE)
+ bSuccess = oPKI.ExportCertAndKeyToFile(
+ i_pAgentCertificate,
+ i_pAgentPrivateKey,
+ sClientKeyFile,
+ NULL,
+ PKI_FORMAT);
+
+ if ( !bSuccess )
+ {
+ LogError(i_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_EXPORT_CERTIFICATE_AND_KEY_FAILED,
+ NULL,
+ NULL,
+ sClientKeyFile );
+ }
+ return bSuccess;
+}
+
+void CleanupPrivateKeyFile(KMSClientProfile* const io_pProfile)
+{
+ char sClientKeyFile[KMS_MAX_FILE_NAME];
+
+ BuildFullProfilePath( sClientKeyFile,
+ g_sWorkingDirectory,
+ io_pProfile->m_wsProfileName );
+
+ strncat(sClientKeyFile,
+ CLIENT_KEY_FILE,
+ KMS_MAX_FILE_NAME );
+
+ (void) unlink(sClientKeyFile);
+ return;
+}
+#endif /* PKCS12 */
+
+/**
+ * GetPKIcerts verifies that CA and Agent certificates are available in
+ * persistent storage and updates profile with an indicator
+ */
+bool GetPKIcerts(
+ KMSClientProfile* const io_pProfile )
+{
+ FATAL_ASSERT( io_pProfile );
+
+ bool bSuccess = true;
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+ char sCAcertFile[KMS_MAX_FILE_NAME+1];
+ char sAgentCertFile[KMS_MAX_FILE_NAME+1];
+#ifndef K_SOLARIS_PLATFORM
+ myFILE* pfFile;
+#endif
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, GetPKIcerts );
+#endif
+
+ io_pProfile->m_iEnrolled = FALSE;
+
+ BuildFullProfilePath( sFullProfileDir,
+ g_sWorkingDirectory, io_pProfile->m_wsProfileName );
+
+ strncpy( sCAcertFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sCAcertFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sCAcertFile, CA_CERTIFICATE_FILE, KMS_MAX_FILE_NAME );
+
+#ifdef K_SOLARIS_PLATFORM
+ /*
+ * stat(2) is preferred over fopen(3C)
+ * fopen for checking if a file is present.
+ */
+ struct stat statp;
+ if (stat(sCAcertFile, &statp)) {
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_FAILED,
+ NULL,
+ NULL,
+ "Test for presence of CA Certificate failed" );
+ return false;
+ }
+
+#else
+ pfFile = fopen( sCAcertFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ }
+ else
+ {
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_FAILED,
+ NULL,
+ NULL,
+ "Test for presence of CA Certificate failed" );
+ return false;
+ }
+#endif
+
+ // open the file containing client certificate and private key
+ // checking if the file exists.
+ strncpy( sAgentCertFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sAgentCertFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sAgentCertFile, CLIENT_KEY_FILE, KMS_MAX_FILE_NAME );
+
+#ifdef K_SOLARIS_PLATFORM
+ /*
+ * stat(2) is safer than "fopen" for checking if a file is
+ * present or not.
+ */
+ if (stat(sAgentCertFile, &statp)) {
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_FAILED,
+ NULL,
+ NULL,
+ "Test for presence of Agent Certificate failed" );
+ return false;
+ }
+#else
+
+ pfFile = fopen( sAgentCertFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ }
+ else
+ {
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_FAILED,
+ NULL,
+ NULL,
+ "Test for presence of Agent Certificate failed" );
+ return false;
+ }
+#endif
+
+ io_pProfile->m_iEnrolled = TRUE;
+
+ return bSuccess;
+}
+
+/**
+ * DeleteStorageProfile
+ */
+bool DeleteStorageProfile(
+ const char* const i_pName)
+{
+ FATAL_ASSERT( i_pName );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, DeleteStorageProfile );
+#endif
+
+ bool bSuccess = true;
+ char sFullProfileDir[KMS_MAX_FILE_NAME+1];
+ char sConfigFile[KMS_MAX_FILE_NAME+1];
+ char sClusterInformationFile[KMS_MAX_FILE_NAME+1];
+ char sCACertificateFile[KMS_MAX_FILE_NAME+1];
+ char sClientKeyFile[KMS_MAX_FILE_NAME+1];
+#ifdef KMSUSERPKCS12
+ char sClientP12File[KMS_MAX_FILE_NAME+1];
+#endif
+
+ BuildFullProfilePathWithName( sFullProfileDir,
+ g_sWorkingDirectory, i_pName );
+ strncpy( sConfigFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sConfigFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sConfigFile, PROFILE_CONFIG_FILE, KMS_MAX_FILE_NAME );
+
+ strncpy( sClusterInformationFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sClusterInformationFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sClusterInformationFile,
+ PROFILE_CLUSTER_CONFIG_FILE,
+ KMS_MAX_FILE_NAME );
+
+ strncpy( sCACertificateFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sCACertificateFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sCACertificateFile, CA_CERTIFICATE_FILE, KMS_MAX_FILE_NAME );
+
+ strncpy( sClientKeyFile, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sClientKeyFile[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sClientKeyFile, CLIENT_KEY_FILE, KMS_MAX_FILE_NAME );
+
+ myFILE* pfFile = fopen( sConfigFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ if ( my_unlink(sConfigFile) )
+ bSuccess = false;
+ }
+
+ pfFile = fopen( sClusterInformationFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ if ( my_unlink(sClusterInformationFile) )
+ bSuccess = false;
+ }
+
+ pfFile = fopen( sCACertificateFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ if ( my_unlink(sCACertificateFile) )
+ bSuccess = false;
+ }
+
+ pfFile = fopen( sClientKeyFile, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ if ( my_unlink(sClientKeyFile) )
+ bSuccess = false;
+ }
+
+#ifdef KMSUSERPKCS12
+ strncpy( sClientP12File, sFullProfileDir, KMS_MAX_FILE_NAME );
+ sClientP12File[KMS_MAX_FILE_NAME] = '\0';
+ strncat( sClientP12File, CLIENT_KEY_FILE, KMS_MAX_FILE_NAME );
+
+ /* Just unlink, no need to open/close first. */
+ if ( my_unlink(sClientP12File) )
+ bSuccess = false;
+#endif
+
+ pfFile = fopen( sFullProfileDir, "rb" );
+
+ if ( pfFile != NULL )
+ {
+ fclose(pfFile);
+ if ( my_rmdir(sFullProfileDir) )
+ bSuccess = false;
+ }
+
+ return bSuccess;
+}
+
+
+
+
+/**
+ * K_soap_ssl_client_context
+ * Parse client context and send to soap, either using a soap call
+ * for openSSL or user implemented call for Treck SSL
+ *
+ * @param i_pProfile - pointer to KMSClientProfile
+ * @param io_pSoap - pointer to soap structure
+ * @param i_iFlags - input flags (CLIENT or SERVER auth)
+ *
+ * @returns 0=success, non-zero=fail
+ */
+int K_soap_ssl_client_context
+( KMSClientProfile* const i_pProfile, // input KMSClientProfile
+ struct soap * io_pSoap, // i/o soap profile
+ unsigned short i_iFlags ) // input flags
+{
+ FATAL_ASSERT( i_pProfile );
+ FATAL_ASSERT( io_pSoap );
+
+#if defined(DEBUG_TRACE) && defined(METAWARE)
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, K_soap_ssl_client_context ) ;
+#endif
+
+
+ char sCACertificateFile[KMS_MAX_FILE_NAME];
+ char sClientKeyFile[KMS_MAX_FILE_NAME];
+
+
+ BuildFullProfilePath( sCACertificateFile, // out
+ g_sWorkingDirectory, // out
+ i_pProfile->m_wsProfileName ); // in
+
+ strncat( sCACertificateFile, // path
+ CA_CERTIFICATE_FILE, // name
+ KMS_MAX_FILE_NAME );
+
+
+ switch ( i_iFlags )
+ {
+ case SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION:
+ {
+ BuildFullProfilePath( sClientKeyFile,
+ g_sWorkingDirectory,
+ i_pProfile->m_wsProfileName );
+
+ strncat( sClientKeyFile, // path
+ CLIENT_KEY_FILE, // name
+ KMS_MAX_FILE_NAME );
+
+ // this sends the following to the SSL Layer
+#ifdef METAWARE
+ return K_ssl_client_context(
+ io_pSoap, // i/o
+ i_iFlags, // flags
+ sClientKeyFile, // keyfile - client cert and private key
+ i_pProfile->m_sHexHashedPassphrase, // password
+ sCACertificateFile, // cafile - CA certificate
+ NULL, // capath
+ NULL ); // randfile
+#else
+ return soap_ssl_client_context(
+ io_pSoap, // i/o
+#ifndef SOAP_SSL_SKIP_HOST_CHECK
+ i_iFlags, // flags
+#else
+ i_iFlags | SOAP_SSL_SKIP_HOST_CHECK, // flags
+#endif
+ sClientKeyFile, // keyfile - client cert and private key
+ i_pProfile->m_sHexHashedPassphrase, // password
+ sCACertificateFile, // cafile - CA certificate
+ NULL, // capath
+ NULL ); // randfile
+#endif
+ }
+ case SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION:
+ {
+#ifdef METAWARE
+ return K_ssl_client_context(
+ io_pSoap, // i/o
+ i_iFlags, // flags
+ NULL, // keyfile
+ NULL, // password
+ sCACertificateFile, // cafile
+ NULL, // capath
+ NULL ); // randfile
+#else
+ return soap_ssl_client_context(
+ io_pSoap, // i/o
+#ifndef SOAP_SSL_SKIP_HOST_CHECK
+ i_iFlags, // flags
+#else
+ i_iFlags | SOAP_SSL_SKIP_HOST_CHECK, // flags
+#endif
+ NULL, // keyfile
+ NULL, // password
+ sCACertificateFile, // cafile
+ NULL, // capath
+ NULL ); // randfile
+#endif
+ }
+ default:
+ // unauthenticated sessions are not supported
+ return 1;
+ }
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentStorage.h b/usr/src/lib/libkmsagent/common/KMSAgentStorage.h
new file mode 100644
index 0000000000..f85fa68117
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentStorage.h
@@ -0,0 +1,175 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAgentStorage.h
+ *
+ * This header provides an interface for the agent library to persist profile information, including
+ * <ul>
+ * <li>Profile Configuration properties
+ * <li>Profile KMS Cluster information
+ * <li>PKI Certificates and Agent Private Key
+ * </ul>
+ * With the storage management of PKI elements is an interface for initialization of the gSoap SSL
+ * client context.
+ * <p>
+ * The reference implementation of this interface maps these storage elements into files.
+ * Other implmentations may need to persist these elements into other types of non-volatile
+ * storage.
+ */
+
+#ifndef KMSAGENT_STORAGE_H
+#define KMSAGENT_STORAGE_H
+
+/**
+ * checks if a profile exists in the working directory with the name specified in the io_pProfile struct
+ */
+extern "C" bool ProfileExists(
+ const char* const i_pWorkingDirectory,
+ const char* const i_pProfileName);
+
+/**
+ * creates a Storage object in the working directory with the specified name.
+ * The storage object's contents are empty.
+ */
+bool CreateProfile(
+ KMSClientProfile* const io_pProfile,
+ const char* const i_pWorkingDirectory,
+ const char* const i_pProfileName);
+
+/**
+ * saves the Config portion of the profile into persistent storage
+ */
+bool StoreConfig(
+ KMSClientProfile* const i_pProfile );
+
+/**
+ * saves the Cluster information from the profile into persistent storage
+ */
+bool StoreCluster(
+ KMSClientProfile* const i_pProfile );
+
+/**
+ * retrieve the Config information from persistent storage into the profile
+ */
+bool GetConfig(
+ KMSClientProfile* const io_pProfile );
+
+
+/**
+ * populate cluster array with names from storage. If the profile does
+ * does not contain cluster information then sets o_bClusterInformationFound
+ * to true.
+ */
+bool GetCluster(
+ KMSClientProfile* const io_pProfile,
+ int& o_bClusterInformationFound );
+
+/**
+ * delete the cluster information from persistent storage
+ */
+bool DeleteCluster( KMSClientProfile* const io_pProfile );
+
+/**
+ * saves the CA certificate into persistent storage
+ */
+bool StoreCACertificate(
+ KMSClientProfile* const i_pProfile,
+ CCertificate* const i_pCACertificate );
+
+
+/**
+ * save the CA certificate, agent certificate and agent
+ * private key material to persistent storage
+ * @param i_sHexHashedPassphrase this is an optional passphrase
+ * that is required when the caller wishes the private key to be
+ * encrypted. The private key will then be encrypted using this
+ * pass phrase.
+ */
+bool StorePKIcerts(
+ KMSClientProfile* const io_pProfile,
+ CCertificate* const i_pCACertificate,
+ CCertificate* const i_pAgentCertificate,
+ CPrivateKey* const i_pAgentPrivateKey,
+ const char* const i_sHexHashedPassphrase );
+
+/**
+ * retrieve the CA certificate, agent certificate and agent
+ * private key material from persistent storage and reference
+ * from the profile
+ */
+bool GetPKIcerts(
+ KMSClientProfile* const io_pProfile );
+
+#ifdef KMSUSERPKCS12
+bool StoreAgentPKI(
+ KMSClientProfile* const i_pProfile,
+ CCertificate* const i_pAgentCertificate,
+ CPrivateKey* const i_pAgentPrivateKey,
+ const char* const i_sHexHashedPassphrase);
+
+bool GetPKCS12CertAndKey(
+ KMSClientProfile* const io_pProfile,
+ utf8char *i_pPassphrase,
+ CCertificate *i_pEntityCert,
+ CPrivateKey *i_pEntityPrivateKey);
+
+bool StoreTempAgentPKI(
+ KMSClientProfile* const io_pProfile,
+ CCertificate *i_pEntityCert,
+ CPrivateKey *i_pEntityPrivateKey);
+
+bool ClientKeyP12Exists(char *profileName);
+
+void CleanupPrivateKeyFile(KMSClientProfile* const io_pProfile);
+#endif
+
+/**
+ * Provides a wrapper to gSoap's soap_ssl_client_context()
+ * that hides how Certificates and Private key material are presented to the underlying SSL
+ * layer.
+ * @param i_pProfile The profile must contain a reference to the CA certificate and for
+ * SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION the Agent's certificate and private key material.
+ * @param io_pSoap gSoap runtime
+ * @param i_iFlags These are the gSoap authentication flags, either
+ * SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION or SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION.
+ * The private key password argument is only applicable
+ * for SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION.
+ *
+ * @return value from gSoap's soap_ssl_client_context()
+ */
+int K_soap_ssl_client_context(
+ KMSClientProfile* const i_pProfile,
+ struct soap * io_pSoap,
+ unsigned short i_iFlags );
+
+/**
+ * deletes the persistent storage object specified by name and its contents
+ */
+bool DeleteStorageProfile(
+ const char* const i_pName);
+
+#endif // KMSAGENT_STORAGE_H
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.cpp b/usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.cpp
new file mode 100644
index 0000000000..c47e6848e8
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.cpp
@@ -0,0 +1,235 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef WIN32
+#include <ctype.h>
+
+ #ifndef METAWARE
+ #include <wctype.h>
+ #endif
+
+#endif
+
+#ifndef METAWARE
+ #include <sys/timeb.h>
+#endif
+
+#include "KMSAgentStringUtilities.h"
+
+#ifdef WIN32
+#include <stdlib.h>
+#include <time.h>
+#define gmtime_r(clock,result) ( *(result) = *gmtime(clock), result )
+#endif
+
+// Find header in KMSAgentStringUtilities.h
+int64 UTF8ToInt64( const char* i_sNumber )
+{
+ FATAL_ASSERT( i_sNumber );
+
+#ifdef WIN32
+ return _atoi64( i_sNumber );
+#else
+ return atoll( i_sNumber );
+#endif
+}
+
+void Int64ToUTF8(char* const o_psUTF8,
+ int64 i_iNumber,
+ int i_bPad,
+ int i_bHex )
+{
+ //string sFormat;
+ char sFormat[10];
+
+ if ( i_bPad && i_bHex )
+ {
+#ifdef WIN32
+ strcpy(sFormat,"%016I64X");
+#else
+ strcpy(sFormat,"%016llX");
+#endif
+ }
+ else if ( i_bPad && !i_bHex )
+ {
+#ifdef WIN32
+ strcpy(sFormat, "%019I64d");
+#else
+ strcpy(sFormat, "%019lld");
+#endif
+ }
+ else if ( !i_bPad && i_bHex )
+ {
+#ifdef WIN32
+ strcpy(sFormat, "%I64X");
+#else
+ strcpy(sFormat, "%llX");
+#endif
+ }
+ else //( !i_bPad && !i_bHex )
+ {
+#ifdef WIN32
+ strcpy(sFormat, "%I64d");
+#else
+ strcpy(sFormat, "%lld");
+#endif
+ }
+
+#ifndef METAWARE
+ int iReturn = sprintf( o_psUTF8, sFormat, i_iNumber);
+
+ //int iReturn = K_snprintf(o_psUTF8, iBufferSize, sFormat, i_iNumber);
+#else
+ int iReturn = sprintf( o_psUTF8, sFormat, i_iNumber);
+#endif
+ if ( iReturn < 0 )
+ {
+ // Our buffer wasn't big enough. Shouldn't happen.
+ FATAL_ASSERT(0);
+ }
+
+ return;
+
+}
+
+// Find header in KMSAgentStringUtilities.h
+int ConvertUTF8HexStringToBinary(
+ const char* i_sHexString,
+ unsigned char* o_pBinaryBuffer)
+{
+ int iHexLen = i_sHexString ? strlen(i_sHexString) : 0;
+ FATAL_ASSERT( (iHexLen % 2) == 0 ); // to be valid, the hex string must have an even number of characters
+
+ if ( !o_pBinaryBuffer )
+ {
+ return ( iHexLen / 2 );
+ }
+
+ if ( iHexLen <= 0 )
+ {
+ return 0;
+ }
+
+ int iDigitValue = 0;
+
+ for ( int i = 0; i < iHexLen; i++)
+ {
+ if (i_sHexString[i] >= '0' && i_sHexString[i] <= '9')
+ {
+ iDigitValue = i_sHexString[i] - '0';
+ }
+ else if (i_sHexString[i] >= 'A' && i_sHexString[i] <= 'F')
+ {
+ iDigitValue = i_sHexString[i] - 'A' + 10;
+ }
+ else if (i_sHexString[i] >= 'a' && i_sHexString[i] <= 'f')
+ {
+ iDigitValue = i_sHexString[i] - 'a' + 10;
+ }
+ else
+ {
+ iDigitValue = 0;
+ }
+
+ if (i % 2 == 0)
+ {
+ o_pBinaryBuffer[i/2] = (char)(iDigitValue << 4);
+ }
+ else
+ {
+ o_pBinaryBuffer[i/2] |= (char)iDigitValue;
+ }
+ }
+
+ return ( iHexLen / 2 );
+}
+
+// Find header in KMSAgentStringUtilities.h
+void ConvertBinaryToUTF8HexString(
+ char* const o_sHexString,
+ const unsigned char* const i_pBinaryBuffer,
+ int i_iBinaryBufferSize )
+{
+ const char HEXCHARS[] = "0123456789ABCDEF";
+
+ FATAL_ASSERT( o_sHexString );
+
+ if ( (i_pBinaryBuffer == 0) || (i_iBinaryBufferSize == 0) )
+ {
+ strcpy(o_sHexString, "");
+ return;
+ }
+
+ FATAL_ASSERT( i_pBinaryBuffer );
+
+ for ( int i = 0; i < (2 * i_iBinaryBufferSize); i++ )
+ {
+ unsigned char ucFourBits = i_pBinaryBuffer[i / 2];
+ if ( (i % 2) == 0 ) // high four bits of the current byte
+ ucFourBits = (ucFourBits >> 4) & 0xF; // shift down and blank out upper bits
+ else // low four bits of the current byte
+ ucFourBits = ucFourBits & 0xF; // blank out upper bits
+
+ o_sHexString[i] = HEXCHARS[ucFourBits];
+ }
+
+ o_sHexString[i_iBinaryBufferSize * 2] = '\0';
+
+ return;
+}
+
+
+// Find header in StringUtilities.h
+void GetCurrentDateTimeISO8601UTC(char* const o_psDateTimeISO8601UTC,
+ int i_iLength)
+{
+
+#ifndef METAWARE
+ timeb stTime;
+ ftime(&stTime);
+
+ FATAL_ASSERT( o_psDateTimeISO8601UTC );
+
+ struct tm* pstTime = gmtime( &(stTime.time) );
+
+ K_snprintf(
+ o_psDateTimeISO8601UTC,
+ i_iLength,
+ "%04d-%02d-%02d %02d:%02d:%02d.%03dZ",
+ pstTime->tm_year+1900,
+ pstTime->tm_mon+1,
+ pstTime->tm_mday,
+ pstTime->tm_hour,
+ pstTime->tm_min,
+ pstTime->tm_sec,
+ stTime.millitm);
+
+#else
+ // no time functions for the metaware environment
+ strcpy( o_psDateTimeISO8601UTC, "" );
+#endif
+ return;
+}
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.h b/usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.h
new file mode 100644
index 0000000000..1705a266ff
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgentStringUtilities.h
@@ -0,0 +1,135 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * @file KMSAgentStringUtilities.h
+ */
+
+#ifndef KMSAgentStringUtilities_h
+#define KMSAgentStringUtilities_h
+
+#ifdef WIN32
+#pragma warning(disable: 4786)
+#endif
+
+#include <stdio.h>
+
+#include "SYSCommon.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+// Functions for conversions between integers and strings.
+//
+
+/*---------------------------------------------------------------------------*/
+/**
+ * Converts a UTF8 string to an int64.
+ *
+ * @param i_sNumber: A string representation of the number to convert.
+ * @return The integer the input string represented.
+ */
+/*---------------------------------------------------------------------------*/
+ int64 UTF8ToInt64( const char* i_sNumber );
+
+/**
+ * Formats an int64 into a UTF8 string.
+ *
+ * A note on padding: If i_bPad is true, the string will be padded to the
+ * maximum size necessary to hold a an int64 representation. For decimal this
+ * is 19, for hex it is 16.
+ *
+ * @param i_iNumber The number to format.
+ * @param i_bPad If true, the string will be padded with zeroes. (See note above.)
+ * @param i_bHex Indicates whether the string format should be a hexadecimal
+ * representation of the integer (true) or a decimal representation (false).
+ * @param o_psUTF8 the string representation of the integer
+ *
+ * @return void
+ */
+void Int64ToUTF8(char* const o_psUTF8,
+ int64 i_iNumber,
+ int i_bPad,
+ int i_bHex );
+
+//
+// Functions for converting between binary buffer and hex string
+//
+
+/*--------------------------------------------------------------------------*/
+/**
+ * Converts a UTF8 hex string to its binary representation.
+ *
+ * If o_pBinaryBuffer is null, the function will return the required size.
+ * (The required size is always strlen(i_sHexString)/2.)
+ *
+ * @param i_sHexString: The hex string to convert.
+ * @param o_pBinaryBuffer: The buffer in which to put the binary
+ * representation of the hex string. If this is null, the function
+ * returns the required size.
+ * If this is not null, it must be large enough to hold binary conversion.
+ *
+ * @return The number of bytes put into o_pBinaryBuffer (or the number of bytes
+ * required, if o_pBinaryBuffer was null).
+ */
+/*---------------------------------------------------------------------------*/
+int ConvertUTF8HexStringToBinary(
+ const char* i_sHexString,
+ unsigned char* o_pBinaryBuffer);
+
+/**
+ * Converts a binary buffer to its UTF8 hex string representation.
+ *
+ * @param i_pBinaryBuffer: The binary buffer to convert.
+ * @param i_iBinaryBufferSize: The size of i_pBinaryBuffer;
+ * @param o_sHexString The hex string representation of the
+ * binary buffer which should be at least
+ * (i_iBinaryBufferSize * 2) + 1 characters long
+ */
+void ConvertBinaryToUTF8HexString(
+ char* const o_sHexString,
+ const unsigned char* const i_pBinaryBuffer,
+ int i_iBinaryBufferSize );
+
+//
+// Functions for date strings
+//
+
+/**
+ * populates o_psDateTimeISO8601UTC with a null terminated ISO 8601
+ * formatted timestamp string from the current UTC time of the
+ * system. The timestamp length will be restricted to i_iLength-1
+ * characters.
+ */
+void GetCurrentDateTimeISO8601UTC(char* const o_psDateTimeISO8601UTC,
+ int i_iLength);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //KMSAgentStringUtilities_h
diff --git a/usr/src/lib/libkmsagent/common/KMSAgent_direct.h b/usr/src/lib/libkmsagent/common/KMSAgent_direct.h
new file mode 100644
index 0000000000..e33322a5dd
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAgent_direct.h
@@ -0,0 +1,942 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file direct.h
+ *
+ * This file is included in KMSAgentStorage.cpp to provide file handling
+ * hooks. It also contains our EEPROM file handling functions.
+ *
+ * HISTORY:
+ * 8/6/07 BJB Added code for 9840D encryption sectors
+ * 4/7/08 BJB Changed to remove 'file is junk' message - EVT
+ * didn't like it.
+ * 4/24/08 BJB Added function call back to T10000/9840D code
+ * to lookup eeprom address -
+ * so it isn't a hardcoded value.
+ * 05/09/08 BJB Added being more conservative about EEPROM so as to change
+ * frequency of 32CA problems
+ *
+ */
+
+
+#ifndef KMSAGENT_DIRECT_H
+#define KMSAGENT_DIRECT_H
+
+#include <stdio.h>
+#include <string.h>
+
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#define my_unlink(a) unlink(a)
+#define my_rmdir(a) rmdir(a)
+
+#ifndef METAWARE
+
+#define myFILE FILE
+
+#else // METAWARE
+
+#include "SYSCommon.h"
+#include "debug.h"
+#include <snprintf.h>
+
+extern "C" void ecpt_trace_msg(ECPT_TRACE_ENTRY*,const char*,...);
+
+extern char st[256];
+
+
+#ifndef I_KNOW_REAL_NAMES
+#undef fopen
+#undef fclose
+#undef fputs
+#undef fgets
+#undef fwrite
+#undef fread
+#undef unlink
+#undef rmdir
+
+#define fopen my_eeprom_fopen
+#define fclose my_eeprom_fclose
+#define fputs my_eeprom_fputs
+#define fwrite my_eeprom_fwrite
+#define fread my_eeprom_fread
+#define fgets my_eeprom_fgets
+#define unlink my_eeprom_unlink
+#define rmdir my_eeprom_rmdir
+
+#define my_eeprom_rmdir(a) (1)
+
+#endif
+
+
+#include "KMSClientProfile.h"
+extern char KMSAgent_Version[KMS_MAX_VERSION_LENGTH];
+
+unsigned char volatile* eeprom_addr_lookup_FILESYSTEM_START_ADDR(void);
+unsigned int EEPROM_Sector_size(void);
+
+#define FILESYSTEM_SECTOR (eeprom_addr_lookup_FILESYSTEM_START_ADDR())
+// was ((unsigned char volatile*)0xf20000) on 9840
+// was ((unsigned char volatile*)0x41dc0000) on T10000
+
+#define FILESYSTEM_SECTOR_SIZE (EEPROM_Sector_size())
+// was hardcoded 0x20000
+
+#define EEPROM_ERASED_BYTE 0xFF
+
+/* size of a file allowed (not counting the name) */
+#define EEPROM_FILE_SECT_SIZE 0x1800
+
+/* size of a file name allowed (+ the null) */
+#define EEPROM_FNAME_SIZE 0x80
+
+// 1000h = 4096d
+#define EEPROM_BLOCK_SIZE (EEPROM_FILE_SECT_SIZE - EEPROM_FNAME_SIZE - 4)
+
+/* number of 'files' available */
+#define FTABLE_SIZE 0x5
+
+
+#define UCHAR8 unsigned char
+#define UINT32 unsigned long
+
+
+extern "C" unsigned long
+EEPROM_Sector_Erase( unsigned char volatile *sector_address );
+
+extern "C" unsigned long
+Flash_Write( UCHAR8 *destinationP,
+ UCHAR8 *sourceP,
+ UINT32 byteCount);
+
+extern "C" unsigned long
+Flash_Read( UCHAR8 *dstP,
+ UCHAR8 *srcP,
+ UINT32 byteCount);
+
+/* a eeprom file */
+struct eepromBlockStruct
+{
+ unsigned long fsize;
+ char fname[EEPROM_FNAME_SIZE];
+ unsigned char fdata[EEPROM_BLOCK_SIZE];
+};
+
+
+struct fileSystem
+{
+ struct eepromBlockStruct ftable[FTABLE_SIZE];
+ /* what level of toolkit wrote this - for
+ future compatibility */
+ char writingversion[KMS_MAX_VERSION_LENGTH+1];
+};
+
+
+#define MODE_WRITE 0x01
+#define MODE_READ 0x02
+
+#define MYFILE_CLOSED 0x0
+#define MYFILE_OPEN_READ 0x1
+#define MYFILE_OPEN_WRITE 0x2
+
+
+/* an open file */
+typedef struct fileStruct
+{
+ unsigned char *readptr;
+ unsigned long readsize;
+ unsigned char *writeptr;
+ struct eepromBlockStruct *memptr;
+ unsigned long mode;
+ unsigned long file_number;
+} myFILE;
+
+
+extern "C" myFILE *my_eeprom_fopen (const char *filename, const char *mode);
+extern "C" int my_eeprom_fclose (myFILE *stream);
+extern "C" int my_eeprom_fputs (const char *s, myFILE *stream);
+extern "C" int my_eeprom_fwrite (const char *s, int size, int nobj, myFILE *f);
+extern "C" int my_eeprom_fread (char *s, int size, int nobj, myFILE *f);
+extern "C" char *my_eeprom_fgets (char *s, int n, myFILE *stream);
+extern "C" int my_eeprom_unlink (const char *filename);
+extern "C" int my_eeprom_fsys_erase(void);
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifdef DEFINE_STORAGE
+/* ram copy of the file system */
+struct fileSystem ramFileSystem;
+int file_read = FALSE;
+
+/* file state - open/closed/etc */
+unsigned long fstate[FTABLE_SIZE] = {MYFILE_CLOSED,
+ MYFILE_CLOSED,
+ MYFILE_CLOSED,
+ MYFILE_CLOSED,
+ MYFILE_CLOSED};
+#else
+/* ram copy of the file system */
+extern struct fileSystem ramFileSystem;
+extern int file_read;
+
+/* file state - open/closed/etc */
+extern unsigned long fstate[FTABLE_SIZE];
+
+#endif
+
+
+
+#ifdef DEFINE_STORAGE
+
+
+extern "C" unsigned long
+
+
+/* UNIT TEST */
+int TESTV = 0;
+
+/* UNIT TEST */
+#define MY_FLASH_READ(a,b,c) \
+ Flash_Read(a,b,c); \
+ if (TESTV++ < 5) { \
+ ramFileSystem.ftable[0].fname[0] = EEPROM_ERASED_BYTE; \
+ ramFileSystem.ftable[1].fsize = EEPROM_BLOCK_SIZE+1; \
+ }
+
+
+
+/**
+ * my_eeprom_fopen()
+ * my filesystem fileopen
+ */
+extern "C" myFILE *my_eeprom_fopen(const char *filename, const char *mode)
+{
+ int i;
+ myFILE *file;
+ int open_for_write = TRUE;
+ static int Firsttime = TRUE;
+ int retries = 100;
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fopen ) ;
+ ecpt_trace_msg( trace, "file %s", (char*)filename);
+
+ FATAL_ASSERT(filename);
+ FATAL_ASSERT(mode);
+
+ if ( (strcmp(mode,"wb") == 0) ||
+ (strcmp(mode,"w") == 0))
+ {
+ // write
+ open_for_write = TRUE;
+ }
+ else if ( (strcmp(mode,"r") == 0) ||
+ (strcmp(mode,"rb") == 0) )
+ {
+ // read binary
+ open_for_write = FALSE;
+ }
+ else
+ {
+ FATAL_APPLICATION_STATE("my_eeprom_fopen : Illegal mode");
+ }
+
+ /* read the file table from eeprom? */
+ if (!file_read)
+ {
+ RETRY:
+
+ MY_FLASH_READ((unsigned char *)&ramFileSystem,
+ (unsigned char *)FILESYSTEM_SECTOR,
+ sizeof(ramFileSystem));
+
+ /* Audit the filesystem - if it looks junked, reclaim bad files */
+
+ for (i=0; i < FTABLE_SIZE; i++)
+ {
+ if ( (ramFileSystem.ftable[i].fname[0] == EEPROM_ERASED_BYTE) ||
+ (ramFileSystem.ftable[i].fsize > EEPROM_BLOCK_SIZE) )
+ {
+ /* if this looks bad, don't accept this outcome until
+ 100 retries */
+ if (retries-- > 0)
+ {
+ ecpt_trace_msg( trace, "file was junk - retrying %s", (char*)filename);
+ log_error_printf(
+ "KMSAgent_direct::fopen file %d is junk - (name %x, "
+ "size %x, data %x) RETRYING \n",
+ i,
+ ramFileSystem.ftable[i].fname[0],
+ ramFileSystem.ftable[i].fsize ,
+ ramFileSystem.ftable[i].fdata[0]);
+
+ goto RETRY;
+ }
+ else
+ {
+ ecpt_trace_msg( trace, "file was junk - formatting %s", (char*)filename);
+ log_error_printf(
+ "KMSAgent_direct::fopen file %d is junk - (name %x, "
+ "size %x, data %x) formatting it\n",
+ i,
+ ramFileSystem.ftable[i].fname[0],
+ ramFileSystem.ftable[i].fsize ,
+ ramFileSystem.ftable[i].fdata[0]);
+
+ /* set data to reasonable starting values */
+ ramFileSystem.ftable[i].fname[0] = 0;
+ ramFileSystem.ftable[i].fsize = 0;
+ ramFileSystem.ftable[i].fdata[0] = 0;
+ }
+
+ }
+
+ } /* for */
+
+ file_read = TRUE;
+
+ } /* !file read */
+
+ /* read the file table */
+ for (i=0; i < FTABLE_SIZE; i++)
+ {
+ /* compare filename to ram copy filename */
+ if (strcmp(filename, (const char *)ramFileSystem.ftable[i].fname) == 0)
+ {
+
+ if (fstate[i] != MYFILE_CLOSED)
+ {
+ log_printf("KMSAgent_direct::fopen FN=%s file matches, "
+ "FILE %d WAS ALREADY OPEN for %s with mode %s"
+ "file size is %d \n",
+ filename,
+ i,
+ (fstate[i] == MYFILE_OPEN_WRITE ? "WRITE": "READ"),
+ mode,
+ ramFileSystem.ftable[i].fsize);
+ }
+
+ /* create a new ramfile handle */
+ file = malloc(sizeof(myFILE));
+
+ /* since file is being rewritten, it is now size 0 */
+ if (open_for_write)
+ ramFileSystem.ftable[i].fsize = 0;
+
+ /* remember the file is open */
+ fstate[i]= open_for_write ? MYFILE_OPEN_WRITE : MYFILE_OPEN_READ;
+
+
+ /* if filename matches, set file pointers to it */
+ file->writeptr = file->readptr = ramFileSystem.ftable[i].fdata;
+ file->memptr = &ramFileSystem.ftable[i];
+ file->readsize = 0;
+ file->mode = open_for_write ? MODE_WRITE : MODE_READ;
+ file->file_number = i;
+
+
+ log_printf("KMSAgent_direct::fopen FN=%s file matches, "
+ "opening existing file number %d with mode %s"
+ "file size is %d \n",
+ filename,
+ i,
+ mode,
+ ramFileSystem.ftable[i].fsize);
+
+ break;
+ }
+
+ }
+
+ /* if no existing entry was found, assign a new entry to this filename */
+ if (i == FTABLE_SIZE)
+ {
+ /* couldn't find an old file and opened for read so return NULL */
+ if (open_for_write == FALSE)
+ {
+
+
+ log_printf("KMSAgent_direct::fopen FN=%s no file match, "
+ "file opened for read so return NULL %d\n",
+ filename,
+ i);
+
+
+ return NULL;
+ }
+
+ /* find a free file pointer */
+ for (i=0; i < FTABLE_SIZE ; i++)
+ {
+ /* empty data will be 0xffffffff since it was copied
+ straight from EEPROM */
+ if (ramFileSystem.ftable[i].fname[0] == '\0')
+ {
+ log_printf("KMSAgent_direct::fopen FN=%s no file match, "
+ "opening new file %d\n",
+ filename,
+ i);
+
+ /* give it a filename - marks this as in use */
+ strcpy ((char *)ramFileSystem.ftable[i].fname, filename);
+
+ /* set filesize to zero */
+ ramFileSystem.ftable[i].fsize = 0;
+
+ /* remember the file is open */
+ fstate[i]= open_for_write ? MYFILE_OPEN_WRITE : MYFILE_OPEN_READ;
+
+
+ /* create a new ramfile handle */
+ file = malloc(sizeof(myFILE));
+
+ /* if filename matches, set file pointers to it */
+ file->writeptr = file->readptr = ramFileSystem.ftable[i].fdata;
+ file->memptr = &ramFileSystem.ftable[i];
+ file->readsize = 0;
+ file->mode = open_for_write ? MODE_WRITE : MODE_READ;
+ file->file_number = i;
+
+ break;
+ }
+
+ }
+
+ if (i == FTABLE_SIZE)
+ {
+ log_error_printf("KMSAgent_direct::fopen FN=%s no free files \n",
+ filename);
+ /* no free entries - bail */
+ return NULL;
+ }
+
+ }
+
+ /* return pointer to the myFILE struct created */
+ return file;
+
+}
+
+/**
+ * my_eeprom_fclose()
+ * my filesystem fileclose
+ */
+extern "C" int my_eeprom_fclose(myFILE *f)
+{
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fclose ) ;
+ ecpt_trace_msg( trace, "entered");
+
+ FATAL_ASSERT(f);
+
+#ifdef DEBUG
+ log_printf("KMSAgent_direct::fclose FN=%s, "
+ "FILE %d "
+ "file size is %d \n",
+ ramFileSystem.ftable[f->file_number].fname,
+ f->file_number,
+ ramFileSystem.ftable[f->file_number].fsize);
+#endif
+
+ if (fstate[f->file_number] == MYFILE_CLOSED)
+ {
+ log_error_printf("KMSAgent_direct::fclose FN=%s, "
+ "FILE %d WAS ALREADY CLOSED "
+ "file size is %d \n",
+ ramFileSystem.ftable[f->file_number].fname,
+ f->file_number,
+ ramFileSystem.ftable[f->file_number].fsize);
+ }
+
+ /* remember the file is closed */
+ fstate[f->file_number]= MYFILE_CLOSED;
+
+ /* don't rewrite eeprom unless file was opened for writing */
+ if (f->mode == MODE_WRITE)
+ {
+ /* Erase the sector we are rewriting */
+ EEPROM_Sector_Erase( (unsigned char*)FILESYSTEM_SECTOR ) ;
+
+ /* remember the version of toolkit that wrote this filesystem
+ (for any future compatibility problems). */
+ strncpy(ramFileSystem.writingversion,
+ KMSAgent_Version,
+ sizeof(KMSAgent_Version));
+
+ /* flush the memory indicated by myFILE * out to EEPROM */
+ /* see boot_eeprom.c for details on Flash_Write */
+ Flash_Write ((unsigned char*)FILESYSTEM_SECTOR,
+ (unsigned char*)&ramFileSystem,
+ FILESYSTEM_SECTOR_SIZE);
+ }
+
+ /* delete the placeholder file */
+ free(f);
+
+ return 0;
+}
+
+/**
+ * my_eeprom_fputs()
+ * my filesystem put string
+ */
+extern "C" int my_eeprom_fputs(const char *s, myFILE *f)
+{
+ /* put the string to the memory indicated by myFILE */
+ int i;
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fputs ) ;
+
+ ecpt_trace_msg (trace, "\nmy_eeprom_fputs : Entered");
+
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::my_eeprom_fputs "
+ "f->writeptr =%x "
+ "f->readptr=%x "
+ "f->readsize=%x "
+ "f->memptr=%x"
+ "f->memptr->fsize=%x\n",
+ f->writeptr,
+ f->readptr,
+ f->readsize,
+ f->memptr,
+ f->memptr->fsize);
+
+#endif
+
+ FATAL_ASSERT(s);
+ FATAL_ASSERT(f);
+
+ for (i=0;;i++)
+ {
+ /* end of input string? quit */
+ if (*s == '\0')
+ break;
+
+ /* end of max file memory, quit */
+ if ((unsigned char*)s >=
+ (unsigned char*)(f->memptr + sizeof(struct eepromBlockStruct)))
+ break;
+
+ /* copy */
+ *(f->writeptr) = *s++;
+ f->writeptr++;
+
+ /* increment the filesize */
+ f->memptr->fsize += 1;
+
+ }
+
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::fputs wrote %d chars, "
+ "filesize is %d\n",
+ i,
+ f->memptr->fsize );
+#endif
+
+ /* return how many chars were written */
+ return i;
+}
+
+
+/**
+ * my_eeprom_fwrite()
+ * my filesystem put string
+ */
+extern "C" int my_eeprom_fwrite(const char *s,
+ int size,
+ int nobj,
+ myFILE *f)
+{
+ /* put the string to the memory indicated by myFILE */
+ int i,j;
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fwrite ) ;
+ ecpt_trace_msg ( trace, "Entered");
+
+ log_printf(
+ "\nKMSAgent_direct::my_eeprom_fputs "
+ "f->writeptr =%x "
+ "f->readptr=%x "
+ "f->readsize=%x "
+ "f->memptr=%x"
+ "f->memptr->fsize=%x\n",
+ f->writeptr,
+ f->readptr,
+ f->readsize,
+ f->memptr,
+ f->memptr->fsize);
+
+ FATAL_ASSERT(s);
+ FATAL_ASSERT(f);
+ FATAL_ASSERT((size*nobj) > 0);
+
+ for (i=0; i<nobj; i++)
+ {
+ for (j=0; j<size; j++)
+ {
+ /* end of max file memory, quit */
+ if ((unsigned char*)s >=
+ (unsigned char*)(f->memptr + sizeof(struct eepromBlockStruct)))
+ goto DONE;
+
+ /* copy */
+ *(f->writeptr) = *s++;
+ f->writeptr++;
+
+ /* increment the filesize */
+ f->memptr->fsize += 1;
+ }
+
+ }
+
+ DONE:
+
+
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::fwrite wrote %d chars, "
+ "filesize is %d\n",
+ i,
+ f->memptr->fsize );
+#endif
+
+ /* return how many objects were written */
+ return i;
+}
+
+
+
+/**
+ * my_eeprom_fgets()
+ * my filesystem getstring
+ */
+extern "C" char *my_eeprom_fgets(char *s, int n, myFILE *f)
+{
+ /* put the string to the memory indicated by myFILE */
+ int i;
+ char *tmp = s;
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fgets ) ;
+ ecpt_trace_msg (trace, "entered");
+
+ FATAL_ASSERT(s);
+ FATAL_ASSERT(n > 0);
+ FATAL_ASSERT(f);
+
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::my_eeprom_fgets from file %s "
+ "fileptr %x "
+ "readptr = %x "
+ "readsize = %d "
+ "filesize = %d \n",
+ f->memptr->fname,
+ f,
+ f->readptr,
+ f->readsize,
+ f->memptr->fsize);
+#endif
+
+ /* get up to n-1 (and a \0) chars */
+ for (i=0; i < n; i++)
+ {
+ /* end of read line? quit */
+ if (*f->readptr == '\n')
+ {
+ /* increment the number of bytes read */
+ f->readptr++;
+ f->readsize++;
+ break;
+ }
+
+ /* trying to read beyond what was written? quit */
+ if (f->readsize >
+ f->memptr->fsize)
+ {
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::fgets eof after %d chars, "
+ "readsize is %d "
+ "filesize is %d\n",
+ i,
+ f->readsize,
+ f->memptr->fsize);
+#endif
+ return NULL;
+ }
+
+ /* trying to read beyond max file memory, quit */
+ if ((unsigned char*)f->readptr >=
+ (unsigned char*)(f->memptr + sizeof(struct eepromBlockStruct)))
+ {
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::fgets end of max file after %d chars "
+ "readsize is %d "
+ "filesize is %d\n",
+ i,
+ f->readsize,
+ f->memptr->fsize);
+#endif
+ /* EOF or error is signalled by NULL return */
+ return NULL;
+ }
+
+ /* copy a char */
+ *tmp++ = *f->readptr;
+
+ /* increment the number of bytes read */
+ f->readptr++;
+ f->readsize++;
+
+ } /* for */
+
+ /* terminate the returned string with a 0, but not a \n */
+ *tmp='\0';
+
+#ifdef DEBUG
+ /* terminate returned string after a non-absurd number of chars
+ */
+ log_printf(
+ "\nKMSAgent_direct::fgets string [%s] "
+ "end of line after %d chars "
+ "readsize is %d "
+ "filesize is %d\n",
+ s,
+ i,
+ f->readsize,
+ f->memptr->fsize);
+#endif
+
+ /* on success, return the original pointer */
+ return s;
+}
+
+
+
+
+/**
+ * my_eeprom_fread()
+ * my filesystem read a file
+ */
+extern "C" int my_eeprom_fread(char *s, int size, int nobj, myFILE *f)
+{
+ /* put the string to the memory indicated by myFILE */
+ int i,j;
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fread ) ;
+ ecpt_trace_msg (trace, "entered");
+
+ FATAL_ASSERT(s);
+ FATAL_ASSERT(f);
+ FATAL_ASSERT((size*nobj) > 0);
+
+ for (i=0; i<nobj; i++)
+ {
+ for (j=0; j<size; j++)
+ {
+ /* end of written file memory, quit */
+ if ( (unsigned char*) s >=
+ (unsigned char*) (f->memptr + f->memptr->fsize) )
+ goto DONE;
+
+ /* copy */
+ *s++ = *(f->readptr);
+ f->readptr++;
+ }
+
+ }
+
+ DONE:
+
+#ifdef DEBUG
+ log_printf(
+ "\nKMSAgent_direct::fread read %d chars, "
+ "filesize is %d\n",
+ i,
+ f->memptr->fsize );
+#endif
+
+ /* return how many objects were written */
+ return i;
+
+}
+
+
+
+
+
+
+/**
+ * my_eeprom_unlink() - delete the file named
+ */
+extern "C" int my_eeprom_unlink(const char *filename)
+{
+ int i;
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fgets ) ;
+ ecpt_trace_msg (trace, "Entered fn=%s", (char*)filename);
+
+ /* assume the file is closed */
+ FATAL_ASSERT(filename);
+
+ /* read the file table */
+ for (i=0; i < FTABLE_SIZE; i++)
+ {
+
+ if (fstate[i] != MYFILE_CLOSED)
+ {
+ log_error_printf("KMSAgent_direct::unlink FN=%s file matches, "
+ "FILE %d WAS STILL OPEN for %s"
+ "file size is %d \n",
+ filename,
+ i,
+ (fstate[i] == MYFILE_OPEN_WRITE ? "WRITE": "READ"),
+ ramFileSystem.ftable[i].fsize);
+ }
+
+ /* compare input filename to ram copy filename */
+ if (strcmp(filename, (const char*)ramFileSystem.ftable[i].fname) == 0)
+ {
+ /* if filename matches, zero it out to delete the file */
+ ramFileSystem.ftable[i].fname[0] = '\0';
+ ramFileSystem.ftable[i].fsize = 0;
+ ramFileSystem.ftable[i].fdata[0] = 1;
+
+ /* remember the file is closed */
+ fstate[i]= MYFILE_CLOSED;
+
+ EEPROM_Sector_Erase( FILESYSTEM_SECTOR ) ;
+
+ /* remember the version of toolkit that wrote this filesystem
+ (for any future compatibility problems). */
+ strncpy(ramFileSystem.writingversion,
+ KMSAgent_Version,
+ sizeof(KMSAgent_Version));
+
+ /* flush the memory indicated by myFILE * out to EEPROM */
+ Flash_Write ((unsigned char*)FILESYSTEM_SECTOR,
+ (unsigned char*)&ramFileSystem,
+ FILESYSTEM_SECTOR_SIZE);
+
+ break;
+ }
+
+ }
+
+#ifdef DEBUG
+ log_printf ("my_eeprom_unlink : returning");
+#endif
+
+ if (i == FTABLE_SIZE)
+ return -1;
+
+ /* success */
+ return 0;
+}
+
+
+/**
+ * my_eeprom_fsys_erase() - delete all files
+ */
+extern "C" int my_eeprom_fsys_erase(void)
+{
+ int i;
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE( trace, my_eeprom_fread ) ;
+ ecpt_trace_msg (trace, "my_eeprom_fsys_erase : entering ");
+
+ /* read the file table */
+ for (i=0; i < FTABLE_SIZE; i++)
+ {
+ if (fstate[i] != MYFILE_CLOSED)
+ {
+ log_error_printf("KMSAgent_direct::fsys_erase FN=%s file "
+ "FILE %d WAS STILL OPEN for %s "
+ "file size is %d \n",
+ ramFileSystem.ftable[i].fname,
+ i,
+ (fstate[i] == MYFILE_OPEN_WRITE ? "WRITE": "READ"),
+ ramFileSystem.ftable[i].fsize);
+ }
+
+ /* zero filename out to delete the file */
+ ramFileSystem.ftable[i].fname[0] = '\0';
+ ramFileSystem.ftable[i].fsize = 0;
+ ramFileSystem.ftable[i].fdata[0] = 2;
+
+ /* remember the file is closed */
+ fstate[i]= MYFILE_CLOSED;
+
+ EEPROM_Sector_Erase( FILESYSTEM_SECTOR ) ;
+
+ /* remember the version of toolkit that wrote this filesystem
+ (for any future compatibility problems). */
+ strncpy(ramFileSystem.writingversion,
+ KMSAgent_Version,
+ sizeof(KMSAgent_Version));
+
+ /* flush the memory indicated by myFILE * out to EEPROM */
+ Flash_Write ((unsigned char*)FILESYSTEM_SECTOR,
+ (unsigned char*)&ramFileSystem,
+ FILESYSTEM_SECTOR_SIZE);
+
+
+ }
+
+#ifdef DEBUG
+ log_printf ("\nmy_eeprom_fsys_erase : returning");
+#endif
+
+ if (i == FTABLE_SIZE)
+ return -1;
+
+ /* success */
+ return 0;
+}
+
+
+
+
+#endif // DEFINE_STORAGE
+#endif // METAWARE
+#endif
+
diff --git a/usr/src/lib/libkmsagent/common/KMSAuditLogger.cpp b/usr/src/lib/libkmsagent/common/KMSAuditLogger.cpp
new file mode 100644
index 0000000000..3ef29efe80
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAuditLogger.cpp
@@ -0,0 +1,191 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAuditLogger.cpp
+ */
+
+#ifndef WIN32
+//#include <syslog.h>
+#include <stdarg.h>
+#endif
+
+#include <stdio.h>
+
+#ifndef METAWARE
+#include <sys/timeb.h>
+#endif
+
+#include <time.h>
+
+#include "KMSAuditLogger.h"
+#include "ApplianceParameters.h"
+
+#define AGENT_LOG_FILE "KMSAgentLog.log"
+
+// globals for file logging
+static FILE* g_fpLogFileHandle = NULL;
+static K_MUTEX_HANDLE g_stLogFileMutex;
+static char g_sLogFileName[MAX_LOG_FILE_NAME_LENGTH];
+
+// Find header in AuditLogger.h
+int InitializeFileLogging( const char* const i_sWorkingDirectory )
+{
+ FATAL_ASSERT( i_sWorkingDirectory );
+ if ( g_fpLogFileHandle != NULL )
+ {
+ return false;
+ }
+
+ char sLogFileName[MAX_LOG_FILE_NAME_LENGTH];
+ strncpy( sLogFileName, i_sWorkingDirectory, MAX_LOG_FILE_NAME_LENGTH );
+
+ if ( sLogFileName[ strlen( sLogFileName )-1 ] != PATH_SEPARATOR )
+ {
+ sLogFileName[ strlen(sLogFileName) ] = PATH_SEPARATOR ;
+ sLogFileName[ strlen(sLogFileName) + 1 ] = '\0';
+ }
+
+ strncat( sLogFileName, AGENT_LOG_FILE, MAX_LOG_FILE_NAME_LENGTH );
+
+ strcpy(g_sLogFileName, sLogFileName);
+
+ if ( K_CreateMutex( &g_stLogFileMutex ) != K_SYS_OK )
+ {
+ return false;
+ }
+
+ if ( NULL == ( g_fpLogFileHandle = fopen( g_sLogFileName, "a+t" ) ) )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+// Find header in AuditLogger.h
+int FinalizeFileLogging()
+{
+ FATAL_ASSERT( g_fpLogFileHandle != NULL );
+
+ K_DestroyMutex( g_stLogFileMutex );
+
+ bool bSuccess = ( 0 == fclose( g_fpLogFileHandle ) );
+
+ g_fpLogFileHandle = NULL;
+
+ return bSuccess;
+}
+
+// Find header in AuditLogger.h
+extern "C" int LogToFile( int i_iErrno,
+ const char* const i_sLogLine )
+{
+ if ( g_fpLogFileHandle == NULL )
+ {
+ return false;
+ }
+
+ CAutoMutex oAutoMutex( g_stLogFileMutex );
+
+ if (0 > fputs( i_sLogLine, g_fpLogFileHandle ) )
+ {
+ return false;
+ }
+
+ if ( 0 > fputs( "\n", g_fpLogFileHandle ) )
+ {
+ return false;
+ }
+
+ if ( fflush( g_fpLogFileHandle ) != 0 )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+static const int g_iMaxLogFileLineLength = MAX_LOG_FILE_LINE_LENGTH;
+
+
+int Log_function(
+ int i_iErrno,
+ const char* const i_sOperation,
+ const char* const i_sEntityID,
+ const char* const i_sNetworkAddress,
+ const char* const i_sMessage )
+{
+ char sFileLogEntry[500];
+ const int iTempSize = 100;
+
+ timeb stTime;
+ ftime(&stTime);
+
+ struct tm* pstTime = gmtime( &(stTime.time) );
+
+ K_snprintf(
+ sFileLogEntry,
+ iTempSize,
+ "%04d-%02d-%02d %02d:%02d:%02d.%03dZ",
+ pstTime->tm_year+1900,
+ pstTime->tm_mon+1,
+ pstTime->tm_mday,
+ pstTime->tm_hour,
+ pstTime->tm_min,
+ pstTime->tm_sec,
+ stTime.millitm);
+
+ if ( i_sEntityID )
+ {
+ strcat(sFileLogEntry," AgentID=");
+ strcat(sFileLogEntry,i_sEntityID);
+ }
+
+ if ( i_sNetworkAddress )
+ {
+ strcat(sFileLogEntry," KMA Address=");
+ strcat(sFileLogEntry, i_sNetworkAddress);
+ }
+ if ( i_sOperation )
+ {
+ strcat(sFileLogEntry, " Operation=");
+ strcat(sFileLogEntry,i_sOperation);
+ }
+
+ if ( i_sMessage )
+ {
+ strcat(sFileLogEntry, " Msg=");
+ strcat(sFileLogEntry, i_sMessage);
+ }
+
+ return LogToFile( i_iErrno, sFileLogEntry );
+}
+
+int Log2(char* msg1,
+ char* msg2)
+{
+ return 0;
+}
diff --git a/usr/src/lib/libkmsagent/common/KMSAuditLogger.h b/usr/src/lib/libkmsagent/common/KMSAuditLogger.h
new file mode 100644
index 0000000000..a78010c6f8
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAuditLogger.h
@@ -0,0 +1,144 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAuditLogger.h
+ */
+
+#ifndef KMSAuditLogger_h
+#define KMSAuditLogger_h
+
+#ifndef METAWARE
+#ifdef WIN32
+#pragma warning(disable: 4786)
+#endif
+
+// SYSCommon.h needs the following include
+#include <stdio.h>
+
+#include "SYSCommon.h"
+#include "AutoMutex.h"
+#endif // METAWARE
+
+#include "ApplianceParameters.h"
+
+
+#define MAX_LOG_FILE_LINE_LENGTH MAXIMUM_UTF8_STRING_VALUE_LENGTH + 128
+#define MAX_LOG_FILE_NAME_LENGTH 256
+
+/**
+ * Opens a logging file for appending, or creation,
+ * with the name "KMSAgentLog.log" beneath the specified directory.
+ * @return true on success
+ */
+int InitializeFileLogging( const char* const i_sWorkingDirectory );
+
+/**
+ * closes the log file
+ * @return true if successful close
+ */
+int FinalizeFileLogging();
+
+/**
+ * write a log entry to the log file
+ * @return true if successful
+ */
+extern "C" int LogToFile( int i_iErrno,
+ const char* const i_sLogLine );
+
+/**
+ * Formats a message and to the log file using <code>LogToFile</code>,
+ * generating a ISO8601UTC timestamp and
+ * appending the various function arguments together.
+ * @param i_sOperation optional, an operation and error condition string
+ * @param i_sEntityID optional, the name of the entity performing the operation
+ * @param i_sNetworkAddress optional, the address of the KMS involved in the operation
+ * @param i_sMessage optional, the error message details
+ * @return 0 if successful
+ */
+int Log_function(
+ int i_iErrno,
+ const char* const i_sOperation,
+ const char* const i_sEntityID,
+ const char* const i_sNetworkAddress,
+ const char* const i_sMessage );
+
+// helper macro to convert value to a string
+#define Log(a,b,c,d) Log_function(a, #a, b, c, d)
+
+#define AUDIT_CLIENT_LOG_BASE 0x200
+
+#define AUDIT_CLIENT_LOAD_PROFILE_CREATE_DIRECTORY_FAILED (AUDIT_CLIENT_LOG_BASE + 0x0)
+#define AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_FAILED (AUDIT_CLIENT_LOG_BASE + 0x1)
+#define AUDIT_CLIENT_LOAD_PROFILE_CREATE_PROFILE_CONFIG_SUCCEEDED (AUDIT_CLIENT_LOG_BASE + 0x2)
+#define AUDIT_CLIENT_SAVE_CLUSTER_INFORMATION_SUCCEEDED (AUDIT_CLIENT_LOG_BASE + 0x3)
+
+#define AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SUCCESS (AUDIT_CLIENT_LOG_BASE + 0x4)
+#define AUDIT_CLIENT_GET_CERTIFICATE_SUCCESS (AUDIT_CLIENT_LOG_BASE + 0x5)
+#define AUDIT_CLIENT_LOAD_PROFILE (AUDIT_CLIENT_LOG_BASE + 0x6)
+#define AUDIT_CLIENT_GetClusterInformation (AUDIT_CLIENT_LOG_BASE + 0x7)
+
+#define AGENT_LOADBALANCER_FAILOVER (AUDIT_CLIENT_LOG_BASE + 0x8)
+
+#define AUDIT_CLIENT_AGENT_GET_CLUSTER_INFORMATION_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x9)
+#define AUDIT_CLIENT_AGENT_SELECT_APPLIANCE_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xa)
+#define AUDIT_CLIENT_AGENT_LOAD_PROFILE_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xc)
+#define AUDIT_CLIENT_AGENT_UNLOAD_PROFILE_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xd)
+#define AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xe)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0xf)
+#define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x10)
+#define AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x11)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x12)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x13)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x14)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x15)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x16)
+#define AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x17)
+#define AUDIT_CLIENT_AGENT_CREATED_AUDIT_LOG_INVALID_PARAMETERS (AUDIT_CLIENT_LOG_BASE + 0x18)
+#define AUDIT_CLIENT_AGENT_LOAD_PROFILE_PROFILE_ALREADY_LOADED (AUDIT_CLIENT_LOG_BASE + 0x19)
+#define AGENT_LOADBALANCER_AESKEYUNWRAP_GETKWK_RETURNED_NULL (AUDIT_CLIENT_LOG_BASE + 0x1a)
+#define AGENT_LOADBALANCER_AESKEYUNWRAP_KEY_UNWRAP_FAILED (AUDIT_CLIENT_LOG_BASE + 0x1b)
+#define AUDIT_CLIENT_FILTER_CLUSTER_FAILED (AUDIT_CLIENT_LOG_BASE + 0x1c)
+#define AUDIT_CLIENT_FILTER_CLUSTER (AUDIT_CLIENT_LOG_BASE + 0x1d)
+
+
+
+
+
+
+int Log_function(int i_iErrno,
+ const char* const i_sOperation,
+ const char* const i_sEntityID,
+ const char* const i_sNetworkAddress,
+ const char* const i_sMessage );
+
+/**
+ * Log generically 2 parameters (presumably to the screen,
+ * but could be to a file
+ */
+extern "C" int Log2(char* msg1,
+ char* msg2);
+
+#endif //KMSAuditLogger_h
diff --git a/usr/src/lib/libkmsagent/common/KMSAuditLogger_meta.cpp b/usr/src/lib/libkmsagent/common/KMSAuditLogger_meta.cpp
new file mode 100644
index 0000000000..a9de204d4d
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSAuditLogger_meta.cpp
@@ -0,0 +1,128 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSAuditLogger_meta.cpp
+ * HISTORY:
+ * 9/14/07 BJB changed to log to file even if DEBUG is off
+ */
+
+#include "KMSAuditLogger.h"
+#include <stdio.h>
+#include <string.h>
+#include <snprintf.h>
+#include "strnlen.h"
+#include "debug.h"
+
+
+extern "C" void ecpt_trace_msg(ECPT_TRACE_ENTRY*, char*, ...);
+
+/**
+ * InitializeFileLogging
+ * @returns success/failure (0=fail, 1=success)
+ */
+int InitializeFileLogging( const char* const i_sLogFilename )
+{
+ // do nothing
+ return 1;
+}
+
+int FinalizeFileLogging()
+{
+ // do nothing
+ return 1;
+}
+
+int TruncateLogFile()
+{
+ // do nothing
+ return 1;
+}
+
+
+/**
+ * LogToFile
+ * @returns success/failure (0=fail, 1=success)
+ */
+
+extern "C" void
+tnMsg( const char *format, ... );
+
+
+int LogToFile(int i_iErrno,
+ const char* const i_sLogLine )
+{
+ ECPT_TRACE_ENTRY *trace = NULL;
+ ECPT_TRACE ( trace, LogToFile );
+
+ ecpt_trace_msg( trace, "%i:%s", i_iErrno, i_sLogLine );
+
+ return 1;
+}
+
+/**
+ * Log
+ * @returns success/failure (0=fail, 1=success)
+ */
+int Log_function(int i_iErrno,
+ const char* const i_sOperation,
+ const char* const i_sEntityID,
+ const char* const i_sNetworkAddress,
+ const char* const i_sMessage )
+{
+
+ ECPT_TRACE_ENTRY *trace = NULL;
+
+ ECPT_TRACE ( trace, Log_function );
+
+ ecpt_trace_msg( trace, "%i:%s:%s:",
+ i_iErrno,
+ i_sOperation );
+
+ trace = NULL;
+ ECPT_TRACE ( trace, Log_function );
+ ecpt_trace_msg( trace, "%s:%s:%s",
+ i_sMessage,
+ i_sEntityID,
+ i_sNetworkAddress);
+
+ return 1;
+}
+
+
+
+/**
+ * Log2
+ * @returns success/failure (0=fail, 1=success)
+ */
+extern "C" int Log2(char* msg1,
+ char* msg2)
+{
+ // does nothing anymore
+ return 1;
+}
+
+
+
diff --git a/usr/src/lib/libkmsagent/common/KMSClientProfile.cpp b/usr/src/lib/libkmsagent/common/KMSClientProfile.cpp
new file mode 100644
index 0000000000..cefd75a1b9
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSClientProfile.cpp
@@ -0,0 +1,2878 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+
+#if !defined(UNIX) && !defined(METAWARE)
+#include "KMSAgent_direct.h"
+#endif
+
+#include <string.h>
+
+#include "KMSClientProfile.h"
+
+#include "KMSAgent.h"
+#include "KMS_CAStub.h"
+#include "KMS_CertificateStub.h"
+#include "KMS_DiscoveryStub.h"
+#include "KMSClientProfileImpl.h"
+#include "KMSAuditLogger.h"
+#include "KMSAgentSoapUtilities.h"
+#include "KMSAgentStringUtilities.h"
+
+
+#include "KMSAgentPKICommon.h" // must be before agentstorage
+
+#include "stdsoap2.h"
+#include "KMSAgentStorage.h" // uses KMSClientProfile
+
+
+#include "KMSAgentWebServiceNamespaces.h"
+#include "k_setupssl.h"
+#include "KMSAgentChallenge.h"
+#include "KMSAgentCryptoUtilities.h"
+#include "ApplianceParameters.h"
+#include "AutoMutex.h"
+
+#include "KMSAgentLoadBalancer.h"
+#include "KMSAgentDataUnitCache.h"
+
+#include "ClientSoapFaultCodes.h"
+#ifdef METAWARE
+#include "debug.h"
+#include "sizet.h"
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#include "literals.h"
+#endif
+#include "KMSAgentAESKeyWrap.h"
+
+#if defined(METAWARE) && defined(DEBUG)
+#include "debug.h"
+#endif
+#include "KMSAuditLogger.h"
+#include "KMSClientProfileImpl.h"
+
+#ifdef METAWARE
+extern "C" void
+tnMsg( const char *format,
+ ... );
+#endif
+
+bool g_bUseFileLog = false;
+char g_wsWorkingDirectory[KMS_MAX_PATH_LENGTH+1] = "./";
+
+
+static bool InitializeLogging(
+ const utf8cstr i_wsWorkingDirectory,
+ int i_bUseFileLog )
+{
+ FATAL_ASSERT( !i_bUseFileLog || i_wsWorkingDirectory );
+
+ bool bFileLogSuccess = true;
+
+ g_bUseFileLog = ( i_bUseFileLog != 0 );
+
+ // InitializeFileLogging must always be called,
+ // because the file is always used by FATALs.
+
+ bFileLogSuccess = InitializeFileLogging( i_wsWorkingDirectory ) ? true:false;
+
+ return bFileLogSuccess;
+}
+
+static void FinalizeLogging()
+{
+ // FinalizeFileLogging must always be called,
+ // because the file is always used by FATALs.
+ FinalizeFileLogging();
+
+ return;
+}
+
+
+
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_InitializeLibrary
+ *
+ *--------------------------------------------------------------------------*/
+
+bool KMSClient_InitializeLibrary(
+ const utf8cstr i_wsWorkingDirectory,
+ int i_bUseFileLog)
+{
+ bool bSuccess;
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_InitializeLibrary : ENTERING");
+#endif
+
+ // setup SSL
+ bSuccess = K_SetupSSL() == 1;
+ if(!bSuccess)
+ {
+ return false;
+ }
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_InitializeLibrary : set current directory");
+#endif
+
+ // if i_wsWorkingDirectory is null, caller means current directory
+ if ( i_wsWorkingDirectory != NULL )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_InitializeLibrary : check working directory");
+#endif
+
+ // string is there but is empty or junk
+ if (strlen(i_wsWorkingDirectory) <= 0)
+ {
+ strcpy(i_wsWorkingDirectory, ".");
+ }
+
+ if ( strlen(i_wsWorkingDirectory) >= KMS_MAX_PATH_LENGTH )
+ {
+ return false;
+ }
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_InitializeLibrary : set global working directory");
+#endif
+
+ // set global working directory to input
+ strncpy(g_wsWorkingDirectory,
+ i_wsWorkingDirectory,
+ KMS_MAX_PATH_LENGTH);
+ g_wsWorkingDirectory[KMS_MAX_PATH_LENGTH] = 0;
+ }
+ else
+ {
+ strcpy(g_wsWorkingDirectory, ".");
+ }
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_InitializeLibrary : Initialize logging");
+#endif
+
+ // initialize file logging
+ bSuccess = InitializeLogging( g_wsWorkingDirectory,
+ i_bUseFileLog);
+
+ return bSuccess;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_FinalizeLibrary
+ *--------------------------------------------------------------------------*/
+bool KMSClient_FinalizeLibrary()
+{
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_FinalizeLibrary : ENTERING");
+#endif
+
+ K_CleanupSSL();
+
+ FinalizeLogging();
+
+ return true; /* always */
+}
+
+
+int LogError_lastErrno;
+
+
+/**
+ * Construct a message for the KMSAuditLogger and store the message
+ * in the profile as the last error message.
+ */
+void LogError_function(KMSClientProfile *i_pProfile,
+ int i_iErrno,
+ const char* i_sOperation,
+ const char* i_sEntityID,
+ const char* i_sNetworkAddress,
+ const char* i_sMessage )
+{
+ FATAL_ASSERT( i_pProfile && i_sOperation );
+
+ // save for caller's use - this shouldn't be a global, but I don't
+ // want this as an item in the profile as I don't want it persisted
+ LogError_lastErrno = i_iErrno;
+
+ // log the message to a data file (and internal logs)
+#ifndef METAWARE
+ if ( g_bUseFileLog )
+#endif
+ {
+ Log_function(i_iErrno,
+ i_sOperation,
+ i_sEntityID,
+ i_sNetworkAddress,
+ i_sMessage);
+ }
+
+#ifdef METAWARE
+ /* print this to the T10000/9840 VOP */
+ /* NOTE the \n is important to VOP - leave it in */
+ tnMsg("`msg`KMS2.0:msg#=%i,op=%s\r\n",
+ i_iErrno,
+ i_sOperation);
+
+ tnMsg("`msg`msg=%s,eid=%s,addr=%s\r\n",
+ i_sMessage,
+ i_sEntityID,
+ i_sNetworkAddress);
+
+#endif
+
+ // copy the error message into the profile (for later reference)
+ strncpy(i_pProfile->m_wsErrorString,
+ i_sOperation,
+ KMS_MAX_ERROR_STRING);
+
+ // make sure to NUL out the end
+ i_pProfile->m_wsErrorString[KMS_MAX_ERROR_STRING] = 0;
+
+ if ( i_sEntityID )
+ {
+ strncat(i_pProfile->m_wsErrorString,
+ i_sEntityID,
+ KMS_MAX_ERROR_STRING);
+ }
+
+ if ( i_sNetworkAddress )
+ {
+ strncat(i_pProfile->m_wsErrorString,
+ ",Address=",
+ KMS_MAX_ERROR_STRING);
+ strncat(i_pProfile->m_wsErrorString,
+ i_sNetworkAddress,
+ KMS_MAX_ERROR_STRING);
+ }
+
+ if ( i_sMessage )
+ {
+ strncat(i_pProfile->m_wsErrorString,
+ ",Msg=",
+ KMS_MAX_ERROR_STRING);
+ strncat(i_pProfile->m_wsErrorString,
+ i_sMessage,
+ KMS_MAX_ERROR_STRING);
+ }
+
+ // make sure to NUL out the end
+ i_pProfile->m_wsErrorString[KMS_MAX_ERROR_STRING] = 0;
+
+}
+
+// see KMSClientProfileImpl.h
+bool SSL_InvalidCertificate (const char * const i_sErrorString)
+{
+ if (
+ // OpenSSL generates this msg
+ strstr(i_sErrorString, "sslv3 alert certificate unknown"))
+ {
+ return true;
+ }
+ return false;
+
+}
+
+// see KMSClientProfileImpl.h
+bool ServerError (const char * i_sErrorString, int i_iErrno )
+{
+ // The Client Soap Fault Code returned by the KMA
+ // may be at the start of i_sErrorString or immediately
+ // follwing "SoapFaultString=" depending on the caller's
+ // string
+
+ int iErrorCode;
+
+ const char* sFaultstringStart = strstr(i_sErrorString, "SoapFaultString=" );
+ if ( sFaultstringStart )
+ {
+ iErrorCode = GET_FAULT_CODE( sFaultstringStart + strlen("SoapFaultString=") );
+ }
+ else
+ {
+ // This may be zero if there is no error code at the start of the string.
+ iErrorCode = GET_FAULT_CODE( i_sErrorString );
+ }
+
+ // the following is commented out so the former check can be observed. This check is no longer
+ // made since invalid certificate failures may be due to a KMA that is behind on
+ // replication updates hence failover would succeed.
+// if (
+// // OpenSSL generates this msg
+// SSL_InvalidCertificate(i_sErrorString))
+// {
+// return false;
+// }
+
+ if (
+ // when the KMA is locked
+ iErrorCode == CLIENT_ERROR_AGENT_APPLIANCE_LOCKED
+
+ // KMS 2.2 change when the KMA is locked
+ || iErrorCode == CLIENT_ERROR_MANAGER_APPLIANCE_LOCKED
+
+ // KMS 2.2 change for core security internal error
+ || iErrorCode == CLIENT_ERROR_MANAGER_INTERNAL
+
+ // if the KMA's pre-gen'd key pool is depleted
+ || iErrorCode == CLIENT_ERROR_AGENT_NO_READY_KEYS
+
+ // if the KMA's HSM is broke and the KMA is in FIPS mode
+ || iErrorCode == CLIENT_ERROR_SERVER_HSM_REQUIRED_BUT_MISSING
+
+ // when the server is too slow
+ || NULL != strstr( i_sErrorString, "Timeout" )
+ || NULL != strstr( i_sErrorString, "Operation interrupted or timed out" )
+
+ // The Appliance is powered down, or is not reachable
+ || NULL != strstr( i_sErrorString, "Connection refused" )
+
+ || NULL != strstr( i_sErrorString, "Unknown error" )
+
+ // SOAP EOF
+ || NULL != strstr( i_sErrorString, "End of file or no input:" )
+
+ // Appliance server software is not running (while Appliance machine is OK)
+ || NULL != strstr( i_sErrorString, "connect failed in tcp_connect()" )
+
+ // If the server has an internal error but still responds
+ || NULL != strstr( i_sErrorString, "Server Error" )
+
+ // OpenSSL protocol errors (Note: the SSL_ERROR_SSL may be due
+ // to invalid client-side values, but for now it's used as a
+ // catch-all; a side-effect is that any actual invalid client-side
+ // value will cause one audit log entry to be created on each
+ // Appliance in the cluster).
+ || NULL != strstr( i_sErrorString,
+ "Error observed by underlying BIO: No error" )
+ || NULL != strstr( i_sErrorString,
+ "EOF was observed that violates the protocol" )
+ || NULL != strstr( i_sErrorString,
+ "SSL_ERROR_SSL" ) )
+ {
+ return true;
+ }
+
+#ifndef WIN32
+ // check for errno values that imply connection problems to the server
+ switch (i_iErrno)
+ {
+ case ECONNABORTED : return true; // Connection aborted.
+ case ECONNREFUSED : return true; // Connection refused.
+ case ECONNRESET : return true; // Connection reset.
+ case EHOSTUNREACH : return true; // Host is unreachable.
+ case ENETDOWN : return true; // Network is down.
+ case ENETRESET : return true; // Connection aborted by network.
+ case ENETUNREACH : return true; // Network unreachable.
+ case ENOPROTOOPT : return true; // Protocol not available.
+#ifndef METAWARE
+ case ETIME : return true; // Stream ioctl() timeout.
+#endif
+ case ETIMEDOUT : return true; // Connection timed out.
+ }
+#endif
+ // at this point we conclude its a client side issue
+ return false;
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_GetLastErrorMessage
+ *
+ *--------------------------------------------------------------------------*/
+
+// extern "C"
+utf8char * KMSClient_GetLastErrorMessage(KMSClientProfile *i_pProfile)
+{
+ FATAL_ASSERT(i_pProfile);
+
+ CAutoMutex oAutoMutex( 0 );
+ if ( i_pProfile->m_pLock )
+ {
+ oAutoMutex.Lock( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+ }
+
+ return i_pProfile->m_wsErrorString;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_RetrieveEntityCertificate
+ * Get the Root CA Certificate and store it into the profile
+ *--------------------------------------------------------------------------*/
+static bool KMSClient_RetrieveEntityCertificate(
+ KMSClientProfile* i_pProfile,
+ utf8cstr i_wsEntityID,
+ utf8cstr i_wsPassphrase,
+ char* const o_sHexHashedPassphrase )
+{
+ FATAL_ASSERT( i_pProfile && i_wsEntityID && i_wsPassphrase );
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_RetrieveEntityCertificate : entered");
+#endif
+
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+
+ strcpy(o_sHexHashedPassphrase, "");
+
+ bool bSuccess = true;
+ bool bTryFailOver = false;
+
+ struct soap *pstCASoap;
+ pstCASoap = (struct soap *) malloc( sizeof(struct soap) );
+ if(pstCASoap == NULL)
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("Malloc %x pstCASoap returned null\n", sizeof(struct soap));
+#endif
+ LogError(i_pProfile,
+ LoadProfile_AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SOAP_ERROR,
+ NULL,
+ NULL,
+ "malloc failure for pstCASoap" );
+ return false;
+ }
+
+ // initialize the SOAP connection that will get the RootCA
+ soap_init2( pstCASoap, (SOAP_XML_STRICT | SOAP_C_UTFSTRING), (SOAP_XML_STRICT | SOAP_C_UTFSTRING) );
+
+#ifdef METAWARE
+ K_SetupCallbacks ( pstCASoap );
+#endif
+
+ CCertificate* pRootCACertificate = 0;
+ CCertificate* pEntityCertificate = 0;
+ CPrivateKey* pEntityPrivateKey = 0;
+
+ soap_set_namespaces( pstCASoap, KMS_CA_namespaces );
+
+ pstCASoap->connect_timeout = i_pProfile->m_iTransactionTimeout;
+ pstCASoap->send_timeout = i_pProfile->m_iTransactionTimeout;
+ pstCASoap->recv_timeout = i_pProfile->m_iTransactionTimeout;
+
+ struct soap *pstCertificateSoap;
+
+ pstCertificateSoap = (struct soap *) malloc( sizeof(struct soap) );
+
+ if(pstCertificateSoap == NULL)
+ {
+#if defined(METAWARE)
+ log_printf("Malloc %x pstCertificateSoap returned null\n",
+ sizeof(struct soap));
+#endif
+ soap_free( pstCASoap );
+ free(pstCASoap);
+ return false;
+ }
+
+ // initialize the SOAP connection that will get the Certificate
+ soap_init2( pstCertificateSoap, (SOAP_XML_STRICT | SOAP_C_UTFSTRING), (SOAP_XML_STRICT | SOAP_C_UTFSTRING) );
+
+#ifdef METAWARE
+ K_SetupCallbacks ( pstCertificateSoap );
+#endif
+
+ soap_set_namespaces( pstCertificateSoap, KMS_Certificate_namespaces );
+
+ pstCertificateSoap->connect_timeout = i_pProfile->m_iTransactionTimeout;
+ pstCertificateSoap->send_timeout = i_pProfile->m_iTransactionTimeout;
+ pstCertificateSoap->recv_timeout = i_pProfile->m_iTransactionTimeout;
+
+ CAgentLoadBalancer oLoadBalancer(i_pProfile);
+ int iIndex = oLoadBalancer.Balance();
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_RetrieveEntityCertificate : call KMS_CA__RetrieveRootCACertificate");
+#endif
+
+ // get the server's URL that will provide SOAP services
+ do
+ {
+ bSuccess = true;
+ bTryFailOver = false;
+ bool bFailedOnRetrieveRootCA = false;
+ const char* sURL = 0;
+
+ if ( bSuccess )
+ {
+ sURL = oLoadBalancer.GetHTTPURL(iIndex,
+ i_pProfile->m_iPortForCAService);
+
+ if ( !sURL )
+ {
+ bSuccess = false;
+ }
+ }
+
+ if ( bSuccess )
+ {
+ strncpy(i_pProfile->m_sURL, sURL, KMS_MAX_URL);
+ i_pProfile->m_sURL[KMS_MAX_URL] = 0;
+ }
+
+
+ // SOAP CALL - retrieve Root CA Certificate from the Server
+ struct KMS_CA::
+ KMS_CA__RetrieveRootCACertificateResponse stRootCACertificateResponse;
+
+ if ( bSuccess )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_RetrieveCertificate : call KMS_CA__RetrieveRootCACertificate again");
+#endif
+ bSuccess =
+ KMS_CA::soap_call_KMS_CA__RetrieveRootCACertificate(
+ pstCASoap,
+ i_pProfile->m_sURL,
+ NULL,
+ i_wsEntityID,
+ stRootCACertificateResponse ) == SOAP_OK;
+
+ if ( !bSuccess )
+ {
+ GetSoapFault(sSoapFaultMsg, (struct soap*)pstCASoap);
+ GetPeerNetworkAddress(sKmaAddress, pstCASoap);
+ LogError(i_pProfile,
+ LoadProfile_AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg );
+
+ bTryFailOver = ServerError(GET_SOAP_FAULTSTRING(pstCASoap), pstCASoap->errnum);
+ bFailedOnRetrieveRootCA = true;
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 1\n");
+ }
+#endif
+
+
+ // Validate the SOAP response
+ if ( bSuccess )
+ {
+ if ( stRootCACertificateResponse.RootCACertificate.__size < 1 ||
+ stRootCACertificateResponse.RootCACertificate.__ptr == NULL ||
+ stRootCACertificateResponse.AuthenticationHashIterationCount <
+ MIN_AUTHENTICATION_ITERATION_COUNT ||
+ stRootCACertificateResponse.AuthenticationHashIterationCount >
+ MAX_AUTHENTICATION_ITERATION_COUNT ||
+ stRootCACertificateResponse.ClientAuthenticationChallenge.__size !=
+ AUTHENTICATION_CHALLENGE_LENGTH ||
+ stRootCACertificateResponse.ClientAuthenticationChallenge.__ptr == NULL )
+ {
+ bSuccess = false;
+
+ GetPeerNetworkAddress(sKmaAddress, pstCASoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_INVALID_RESPONSE_FORMAT,
+ NULL,
+ sKmaAddress,
+ NULL);
+ }
+ else
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstCASoap);
+ Log(AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SUCCESS,
+ NULL,
+ sKmaAddress,
+ NULL);
+ }
+
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 2\n");
+ }
+#endif
+
+ // build our RootCACertificate object
+ if ( bSuccess )
+ {
+ pRootCACertificate = new CCertificate;
+
+ // make sure the new was successful
+ bSuccess = ( pRootCACertificate != 0 );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 3\n");
+ }
+#endif
+
+ if ( bSuccess )
+ {
+ // OVERLOADED Load method - 3 parameters means
+ // recall from BUFFER
+ bSuccess =
+ pRootCACertificate->Load(
+ stRootCACertificateResponse.RootCACertificate.__ptr, // to here
+ stRootCACertificateResponse.RootCACertificate.__size, // size
+ PKI_FORMAT ); // ignored
+
+ if( !bSuccess )
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstCASoap);
+ LogError(i_pProfile,
+ AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_INVALID_CA_CERTIFICATE_FORMAT,
+ NULL,
+ sKmaAddress,
+ NULL);
+ }
+
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 4\n");
+ }
+#endif
+
+
+ if ( bSuccess )
+ {
+ // save the built CACertificate object to a FILE (i_pProfile gets the
+ // persistent handle to that file)
+ bSuccess = StoreCACertificate( i_pProfile, pRootCACertificate );
+
+ if ( !bSuccess )
+ {
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_SAVE_CA_CERTIFICATE_FAILED,
+ NULL,
+ NULL,
+ NULL);
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 5\n");
+ }
+#endif
+
+ //-------------------------------
+ // Initialize SSL - use SERVER AUTH
+ //-------------------------------
+ if ( bSuccess )
+ {
+ // SERVER_AUTHENTICATION needs just the pstCertificateSoap
+ bSuccess =
+ K_soap_ssl_client_context(
+ i_pProfile, // in ->m_wsProfileName,->m_sHexHashedPassphrase
+ pstCertificateSoap, // in - soap structure
+ SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION // in - flags
+ ) == SOAP_OK;
+
+ if ( !bSuccess )
+ {
+ GetSoapFault(sSoapFaultMsg, (struct soap*)pstCertificateSoap);
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg );
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 6\n");
+ }
+#endif
+
+ // hash the passphrase passed in
+ char sHexAuthenticationSecret[2*HASH_LENGTH+1];
+
+ if ( bSuccess )
+ {
+ bSuccess = ComputeFixedEntityHashedPassphraseAndAuthenticationSecret(
+ i_wsPassphrase,
+ o_sHexHashedPassphrase,
+ stRootCACertificateResponse.AuthenticationHashIterationCount,
+ sHexAuthenticationSecret );
+
+ if ( !bSuccess )
+ {
+ LogError(i_pProfile,AUDIT_CLIENT_COMPUTE_FIXED_FAILED,
+ NULL,
+ NULL,
+ NULL);
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 7\n");
+ }
+#endif
+
+ // copy received Root CA into buffer for input
+ // into challenge-response computation
+ unsigned char aRootCACertificate[MAX_CERT_SIZE];
+ int iRootCACertificateLength;
+
+ if ( bSuccess )
+ {
+ // OVERLOADED save method - save iRootCACertificateLength to aRootCACertificate
+ // buffer
+ bSuccess = pRootCACertificate->Save(
+ aRootCACertificate,
+ MAX_CERT_SIZE,
+ &iRootCACertificateLength,
+ PKI_FORMAT );
+
+ if ( !bSuccess )
+ {
+ LogError(i_pProfile,AUDIT_CLIENT_SAVE_ROOTCA_FAILED,
+ NULL,
+ NULL,
+ NULL);
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 8\n");
+ }
+#endif
+
+ // respond to server's challenge
+ unsigned char aAuthenticationSecret[AUTHENTICATION_SECRET_LENGTH];
+ unsigned char
+ aClientAuthenticationChallengeResponse[AUTHENTICATION_RESPONSE_LENGTH];
+
+ if ( bSuccess )
+ {
+ FATAL_ASSERT( AUTHENTICATION_SECRET_LENGTH ==
+ ConvertUTF8HexStringToBinary(
+ sHexAuthenticationSecret, NULL ) );
+
+ ConvertUTF8HexStringToBinary(
+ sHexAuthenticationSecret, aAuthenticationSecret );
+
+ // client authentication response
+ bSuccess = ComputeChallengeResponse(
+ aAuthenticationSecret,
+ AUTHENTICATION_SECRET_LENGTH,
+ aRootCACertificate,
+ iRootCACertificateLength,
+ stRootCACertificateResponse.ClientAuthenticationChallenge.__ptr,
+ AUTHENTICATION_CHALLENGE_LENGTH,
+ aClientAuthenticationChallengeResponse,
+ AUTHENTICATION_RESPONSE_LENGTH );
+
+ if ( !bSuccess )
+ {
+ LogError(i_pProfile,AUDIT_CLIENT_COMPUTE_CHALLENGE_RESPONSE_FAILED,
+ NULL,
+ NULL,
+ NULL);
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 9\n");
+ }
+#endif
+
+ struct KMS_Certificate::xsd__hexBinary stClientAuthenticationResponse;
+
+ if ( bSuccess )
+ {
+ stClientAuthenticationResponse.__size =
+ AUTHENTICATION_RESPONSE_LENGTH;
+ stClientAuthenticationResponse.__ptr =
+ (unsigned char*)soap_malloc(
+ pstCertificateSoap, AUTHENTICATION_RESPONSE_LENGTH );
+
+ if ( stClientAuthenticationResponse.__ptr != NULL )
+ {
+ memcpy( stClientAuthenticationResponse.__ptr,
+ aClientAuthenticationChallengeResponse,
+ AUTHENTICATION_RESPONSE_LENGTH );
+ }
+ else
+ {
+ bSuccess = false;
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 10\n");
+ }
+#endif
+
+ // generate challenge nonce
+ struct KMS_Certificate::xsd__hexBinary stServerAuthenticationChallenge;
+
+ if ( bSuccess )
+ {
+ stServerAuthenticationChallenge.__size =
+ AUTHENTICATION_CHALLENGE_LENGTH;
+ stServerAuthenticationChallenge.__ptr =
+ (unsigned char*)soap_malloc( pstCertificateSoap,
+ AUTHENTICATION_CHALLENGE_LENGTH );
+
+ bSuccess = ( stServerAuthenticationChallenge.__ptr != NULL );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 11\n");
+ }
+#endif
+
+ if ( bSuccess )
+ {
+ bSuccess = GetPseudorandomBytes(
+ AUTHENTICATION_CHALLENGE_LENGTH,
+ stServerAuthenticationChallenge.__ptr );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 12\n");
+ }
+#endif
+
+ if ( bSuccess )
+ {
+ sURL = oLoadBalancer.GetHTTPSURL(iIndex,
+ i_pProfile->
+ m_iPortForCertificateService);
+
+ if ( !sURL )
+ {
+ bSuccess = false;
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 13\n");
+ }
+#endif
+
+ // Verify that the same URL is used for Root CA Certificate
+ // retrieval as for Entity Certificate retrieval
+
+ if ( bSuccess )
+ {
+ char sTempCAURL[KMS_MAX_URL + 1];
+ strncpy( sTempCAURL, i_pProfile->m_sURL, KMS_MAX_URL );
+ sTempCAURL[KMS_MAX_URL] = 0;
+
+ char * sRetrieveRootCACertificateURL = strtok( sTempCAURL, ":" );
+
+ sRetrieveRootCACertificateURL = strtok(NULL, ":");
+
+ char sTempAgentURL[KMS_MAX_URL + 1];
+ strncpy( sTempAgentURL, sURL, KMS_MAX_URL );
+ sTempAgentURL[KMS_MAX_URL] = 0;
+ char * sRetrieveAgentCertificateURL = strtok( sTempAgentURL, ":" );
+ sRetrieveAgentCertificateURL = strtok(NULL, ":");
+
+ FATAL_ASSERT( strcmp( sRetrieveRootCACertificateURL,
+ sRetrieveAgentCertificateURL ) == 0 );
+
+ strncpy(i_pProfile->m_sURL, sURL, KMS_MAX_URL);
+ i_pProfile->m_sURL[KMS_MAX_URL] = 0;
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 14\n");
+ }
+#endif
+
+ KMS_Certificate::KMS_Certificate__RetrieveEntityCertificateResponse
+ stRetrieveEntityCertificateResponse;
+
+ // SOAP - retrieve ENTITY Certificate, passing the challenge response,
+ // a challenge to the server and get back the server's response
+ if ( bSuccess )
+ {
+ bSuccess =
+ KMS_Certificate::soap_call_KMS_Certificate__RetrieveEntityCertificate(
+ pstCertificateSoap,
+ sURL,
+ NULL,
+ (utf8cstr )i_wsEntityID,
+ stClientAuthenticationResponse,
+ stServerAuthenticationChallenge,
+ stRetrieveEntityCertificateResponse ) == SOAP_OK;
+
+ if( !bSuccess )
+ {
+ GetSoapFault(sSoapFaultMsg, (struct soap*)pstCertificateSoap);
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg );
+
+ bTryFailOver = ServerError(GET_SOAP_FAULTSTRING(pstCertificateSoap),
+ pstCertificateSoap->errnum);
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 15\n");
+ }
+#endif
+
+ // Validate the response structure
+ if ( bSuccess )
+ {
+ if ( stRetrieveEntityCertificateResponse.
+ ServerAuthenticationResponse.__ptr == NULL
+
+ || stRetrieveEntityCertificateResponse.
+ ServerAuthenticationResponse.__size !=
+ AUTHENTICATION_RESPONSE_LENGTH
+
+ || stRetrieveEntityCertificateResponse.Certificate.__size < 1
+
+ || stRetrieveEntityCertificateResponse.Certificate.__ptr == 0
+
+ || stRetrieveEntityCertificateResponse.
+ WrappedPrivateKeyMaterial.__size < 1
+
+ || stRetrieveEntityCertificateResponse.
+ WrappedPrivateKeyMaterial.__ptr == 0 )
+ {
+ bSuccess = false;
+
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_INVALID_RESPONSE_FORMAT,
+ NULL,
+ sKmaAddress,
+ NULL );
+ }
+ else
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ Log(AUDIT_CLIENT_GET_CERTIFICATE_SUCCESS,
+ NULL,
+ sKmaAddress,
+ NULL );
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 16\n");
+ }
+#endif
+
+ // if valid, calculate the correct challenge-response
+ unsigned char
+ aServerAuthenticationChallengeResponse[AUTHENTICATION_RESPONSE_LENGTH];
+
+ if ( bSuccess )
+ {
+ bSuccess = ComputeChallengeResponse(
+ aAuthenticationSecret,
+ AUTHENTICATION_SECRET_LENGTH,
+ aRootCACertificate,
+ iRootCACertificateLength,
+ stServerAuthenticationChallenge.__ptr,
+ AUTHENTICATION_CHALLENGE_LENGTH,
+ aServerAuthenticationChallengeResponse,
+ AUTHENTICATION_RESPONSE_LENGTH );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 17\n");
+ }
+#endif
+
+ // if successful, check if the server provided the correct challenge-response
+ if ( bSuccess )
+ {
+ if ( 0 != memcmp(
+ aServerAuthenticationChallengeResponse,
+ stRetrieveEntityCertificateResponse.ServerAuthenticationResponse.__ptr,
+ AUTHENTICATION_RESPONSE_LENGTH ) )
+ {
+ bSuccess = false;
+
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_INVALID_CHALLENGE_RESPONSE,
+ NULL,
+ sKmaAddress,
+ NULL );
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 18\n");
+ }
+#endif
+
+
+ if ( bSuccess )
+ {
+ pEntityCertificate = new CCertificate;
+ // if certificate was obtained
+ bSuccess = ( pEntityCertificate != 0 );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 19\n");
+ }
+#endif
+
+ if ( bSuccess )
+ {
+ // Load(recall) the signed certificate using OVERLOADED load method
+ // 3 parameters means load from a buffer
+ bSuccess = pEntityCertificate->Load(
+ stRetrieveEntityCertificateResponse.Certificate.__ptr, // load into
+ stRetrieveEntityCertificateResponse.Certificate.__size,
+ PKI_FORMAT );
+
+ if ( !bSuccess )
+ {
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_INVALID_CERTIFICATE_FORMAT,
+ NULL,
+ sKmaAddress,
+ NULL );
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 20\n");
+ }
+#endif
+
+ if ( bSuccess )
+ {
+ pEntityPrivateKey = new CPrivateKey;
+ bSuccess = ( pEntityPrivateKey != 0 );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ {
+ log_printf("!bSuccess 21\n");
+ }
+#endif
+
+
+ if ( bSuccess )
+ {
+ // Load the Private Key using OVERLOADED Load method - 3 parameters
+ // means load from a buffer
+
+ // TODO: change this when certificate service supports requesting unwrapped private keys
+ bSuccess = pEntityPrivateKey->Load(
+ stRetrieveEntityCertificateResponse.WrappedPrivateKeyMaterial.__ptr, // load into
+ stRetrieveEntityCertificateResponse.WrappedPrivateKeyMaterial.__size,
+ NULL,
+ PKI_FORMAT );
+
+ if (!bSuccess )
+ {
+
+ GetPeerNetworkAddress(sKmaAddress, pstCertificateSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CERTIFICATE_INVALID_KEY_FORMAT,
+ NULL,
+ sKmaAddress,
+ NULL );
+ }
+ }
+
+ if ( bSuccess )
+ {
+ strncpy(i_pProfile->m_wsEntityID,
+ i_wsEntityID,
+ KMS_MAX_ENTITY_ID );
+ i_pProfile->m_wsEntityID[KMS_MAX_ENTITY_ID] = 0;
+
+ // store PKI certificates and unwrapped private key
+ bSuccess = StorePKIcerts( i_pProfile,
+ pRootCACertificate,
+ pEntityCertificate,
+ pEntityPrivateKey,
+#ifdef KMSUSERPKCS12
+ i_wsPassphrase
+#else
+ NULL
+#endif
+ );
+#ifdef KMSUSERPKCS12
+ if (bSuccess) {
+ /*
+ * Write out the cert and key individually so GetPKIcerts
+ * can use them.
+ */
+ bSuccess = StoreTempAgentPKI(i_pProfile,
+ pEntityCertificate, pEntityPrivateKey);
+ }
+
+#endif
+ }
+
+ if ( !bSuccess )
+ {
+ if (pRootCACertificate)
+ {
+ delete pRootCACertificate;
+ }
+ if (pEntityCertificate)
+ {
+ delete pEntityCertificate;
+ }
+ if (pEntityPrivateKey)
+ {
+ delete pEntityPrivateKey;
+ }
+
+ i_pProfile->m_iEnrolled = FALSE;
+
+ if ( bTryFailOver )
+ {
+ iIndex = oLoadBalancer.FailOver(iIndex, bFailedOnRetrieveRootCA ? pstCASoap : pstCertificateSoap);
+ }
+ }
+ }
+ while ( bTryFailOver && (iIndex >= 0) && !bSuccess );
+
+ // certs are now persisted so free up space
+ if ( bSuccess )
+ {
+ delete pRootCACertificate;
+ delete pEntityCertificate;
+ delete pEntityPrivateKey;
+ }
+
+ // Clean up SOAP resources for pstCASoap
+ soap_destroy( pstCASoap );
+ soap_end( pstCASoap );
+ soap_done( pstCASoap );
+
+ // Clean up SOAP resources for pstCertificateSoap
+ soap_destroy( pstCertificateSoap );
+ soap_end( pstCertificateSoap );
+ soap_done( pstCertificateSoap );
+
+ free(pstCASoap);
+ free(pstCertificateSoap);
+
+ return bSuccess;
+}
+
+/*--------------------------------------------------------------------------
+ * LoadClusterInformation
+ * calls GetCluster - that's it.
+ * If there is no cluster file, this function will return true,
+ * but o_bClusterInformationFound will be false.
+ *-------------------------------------------------------------------------*/
+static bool LoadClusterInformation( KMSClientProfile* i_pProfile,
+ int& o_bClusterInformationFound )
+{
+ FATAL_ASSERT( i_pProfile );
+
+ o_bClusterInformationFound = false;
+
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+
+ return GetCluster( i_pProfile, o_bClusterInformationFound ) ;
+
+}
+
+
+/*--------------------------------------------------------------------------
+ * EnrollAgent
+ * calls functions to perform enrollment and save PKI info to persistent storage
+ * stores configuration in persistent storage
+ *-------------------------------------------------------------------------*/
+
+static bool EnrollAgent( KMSClientProfile * io_pProfile,
+ utf8cstr i_wsEntityID,
+ utf8cstr i_wsPassphrase )
+{
+ FATAL_ASSERT( io_pProfile && i_wsEntityID && i_wsPassphrase );
+
+ bool bSuccess = true;
+
+ // see KMSAgentCryptoUtilities for HASH_LENGTH, aka KMS_MAX_HASH_SIZE
+ char sHexHashedPassphrase[2*KMS_MAX_HASH_SIZE+1];
+
+ if ( bSuccess )
+ {
+ // performs enrollment and saves PKI info to persistent storage
+ bSuccess = KMSClient_RetrieveEntityCertificate(
+ io_pProfile,
+ i_wsEntityID,
+ i_wsPassphrase,
+ sHexHashedPassphrase );
+
+ // KMSClient_RetrieveCertificate logs errors
+ }
+
+ if (bSuccess)
+ {
+ strncpy(io_pProfile->m_sHexHashedPassphrase,
+ sHexHashedPassphrase,
+ 2*KMS_MAX_HASH_SIZE );
+ io_pProfile->m_sHexHashedPassphrase[2*KMS_MAX_HASH_SIZE] = 0;
+
+ // persist the profile now updated with the hashed passphrase
+ bSuccess = StoreConfig( io_pProfile );
+
+ if (!bSuccess)
+ {
+ Log(AUDIT_CLIENT_LOAD_PROFILE,
+ i_wsEntityID,
+ NULL,
+ "store config failed following enrollment" );
+ }
+ }
+
+ return bSuccess;
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_LoadProfile
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_LoadProfile(
+ KMSClientProfile *io_pProfile,
+ utf8char *i_wsProfileName,
+ utf8char *i_wsEntityID,
+ utf8char *i_wsPassphrase,
+ utf8char *i_wsApplianceAddress,
+ int i_iTransactionTimeout,
+ int i_iFailOverLimit,
+ int i_iClusterDiscoveryFrequency,
+ int i_eKMSmode)
+{
+ FATAL_ASSERT(io_pProfile);
+ FATAL_ASSERT(i_wsProfileName);
+
+ bool bSuccess = true;
+
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_LoadProfile : entered");
+#endif
+
+ memset( io_pProfile, 0, sizeof(KMSClientProfile) );
+
+ // create lock
+
+ if (bSuccess)
+ {
+ bSuccess =
+ ( K_CreateMutex((K_MUTEX_HANDLE *)&io_pProfile->m_pLock) ==
+ K_SYS_OK );
+ }
+
+ // initialize profile with parameters
+
+ strncpy(io_pProfile->m_wsProfileName,
+ i_wsProfileName,
+ KMS_MAX_ENTITY_ID);
+ io_pProfile->m_wsProfileName[KMS_MAX_ENTITY_ID] = 0;
+
+ io_pProfile->m_iPortForCAService =
+ DEFAULT_CA_SERVICE_PORT_NUMBER;
+ io_pProfile->m_iPortForCertificateService =
+ DEFAULT_CERTIFICATE_SERVICE_PORT_NUMBER;
+ io_pProfile->m_iPortForDiscoveryService =
+ DEFAULT_DISCOVERY_SERVICE_PORT_NUMBER;
+ io_pProfile->m_iPortForAgentService =
+ DEFAULT_AGENT_SERVICE_PORT_NUMBER;
+ strncpy(io_pProfile->m_wsApplianceAddress,
+ i_wsApplianceAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ io_pProfile->m_wsApplianceAddress[KMS_MAX_NETWORK_ADDRESS] = 0;
+ io_pProfile->m_iClusterDiscoveryFrequency = i_iClusterDiscoveryFrequency;
+ io_pProfile->m_iTransactionTimeout = i_iTransactionTimeout;
+ io_pProfile->m_iFailoverLimit = i_iFailOverLimit;
+ io_pProfile->m_eKMSmode = i_eKMSmode;
+
+ // if the file isn't found, create a new one
+ bool bProfileExists = ProfileExists( g_wsWorkingDirectory, /* pass in default */
+ io_pProfile->m_wsProfileName );
+
+#ifdef KMSUSERPKCS12
+ /*
+ * Fix logic for determining if this request is for enrollment.
+ * Look to see if the server cert and clientkey.p12 file exist.
+ * We always expect a password for Solaris which is used to
+ * validate that the user has access to the clientkey data by
+ * attempting to use it to open the PKCS12 file.
+ */
+ bool bEnrolling = !ClientKeyP12Exists(io_pProfile->m_wsProfileName);
+#else
+ bool bEnrolling = i_wsEntityID && i_wsPassphrase;
+#endif
+
+ if ( bSuccess && !bEnrolling && !bProfileExists )
+ {
+ // when not enrolling a profile must exist
+ bSuccess = false;
+ Log(AUDIT_CLIENT_LOAD_PROFILE,
+ i_wsProfileName,
+ NULL,
+ "Enrollment attempted but profile could not be found" );
+ }
+
+ // if the file isn't found, create a new one
+ if ( bSuccess && !bProfileExists )
+ {
+ strncpy(io_pProfile->m_wsEntityID,
+ i_wsEntityID,
+ KMS_MAX_ENTITY_ID );
+ io_pProfile->m_wsEntityID[KMS_MAX_ENTITY_ID] = 0;
+ bSuccess = CreateProfile( io_pProfile,
+ g_wsWorkingDirectory,
+ io_pProfile->m_wsProfileName );
+ }
+
+ // load profile.cfg file
+ if ( bSuccess )
+ {
+ bSuccess = GetConfig( io_pProfile );
+
+ }
+
+ // if profile settings changed then update the profile storage
+ if ( bSuccess &&
+ ( strncmp(io_pProfile->m_wsApplianceAddress,
+ i_wsApplianceAddress, KMS_MAX_NETWORK_ADDRESS ) != 0 ||
+ io_pProfile->m_iClusterDiscoveryFrequency != i_iClusterDiscoveryFrequency ||
+ io_pProfile->m_iTransactionTimeout != i_iTransactionTimeout ||
+ io_pProfile->m_iFailoverLimit != i_iFailOverLimit
+ ))
+ {
+ strncpy(io_pProfile->m_wsApplianceAddress,
+ i_wsApplianceAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ io_pProfile->m_wsApplianceAddress[KMS_MAX_NETWORK_ADDRESS] = 0;
+ io_pProfile->m_iClusterDiscoveryFrequency = i_iClusterDiscoveryFrequency;
+ io_pProfile->m_iTransactionTimeout = i_iTransactionTimeout;
+ io_pProfile->m_iFailoverLimit = i_iFailOverLimit;
+
+ bSuccess = StoreConfig( io_pProfile );
+ }
+
+ // get PKI info from prior enrollment
+ if ( bSuccess && !bEnrolling )
+ {
+#ifdef KMSUSERPKCS12
+ /*
+ * Decrypt the PKCS12 file with the client cert and key using
+ * the given password. If it fails, then return an auth failure
+ * status. If success, write the client cert and key to the client file
+ * so it can be used later by the SOAP SSL functions.
+ */
+ CCertificate* pEntityCertificate = new CCertificate;;
+ CPrivateKey* pEntityPrivateKey = new CPrivateKey;
+ bSuccess = GetPKCS12CertAndKey(io_pProfile,
+ i_wsPassphrase,
+ pEntityCertificate,
+ pEntityPrivateKey);
+ if (!bSuccess) {
+ Log(AUDIT_CLIENT_LOAD_PROFILE,
+ i_wsProfileName,
+ NULL,
+ "Enrollment Certificate and Private Key "\
+ "were not loaded from PKCS12" );
+ } else {
+ /*
+ * Write out the cert and key individually so GetPKIcerts
+ * can use them.
+ */
+ bSuccess = StoreTempAgentPKI(io_pProfile,
+ pEntityCertificate, pEntityPrivateKey);
+ if (!bSuccess) {
+ Log(AUDIT_CLIENT_LOAD_PROFILE,
+ i_wsProfileName,
+ NULL,
+ "Enrollment Certificate and Private Key "\
+ "were not stored to file." );
+ }
+ }
+ delete pEntityCertificate;
+ delete pEntityPrivateKey;
+
+#endif
+ if (bSuccess)
+ bSuccess = GetPKIcerts( io_pProfile );
+ }
+
+ // if not enrolling then previously enrolled PKI info should now be initialized
+ if ( bSuccess && !bEnrolling &&
+ (!io_pProfile->m_sHexHashedPassphrase ||
+ !io_pProfile->m_iEnrolled ))
+ {
+ bSuccess = false;
+ Log(AUDIT_CLIENT_LOAD_PROFILE,
+ i_wsProfileName,
+ NULL,
+ "Enrollment Certificates and Private Key were not loaded from profile" );
+ }
+
+ io_pProfile->m_bIsClusterDiscoveryCalled = false;
+
+ // allocate main soap struct
+ struct soap* pstSoap = 0;
+
+ if ( bSuccess )
+ {
+ pstSoap = (struct soap*)malloc( sizeof(struct soap) );
+
+ io_pProfile->m_pvSoap = pstSoap;
+
+ bSuccess = ( pstSoap != NULL );
+
+ if ( bSuccess )
+ {
+ soap_init2( pstSoap,
+ (SOAP_XML_STRICT | SOAP_C_UTFSTRING ),
+ (SOAP_XML_STRICT | SOAP_C_UTFSTRING) );
+
+#ifdef METAWARE
+ K_SetupCallbacks ( pstSoap );
+#endif
+
+ soap_set_namespaces( pstSoap, KMS_Agent_namespaces );
+
+ pstSoap->connect_timeout = io_pProfile->m_iTransactionTimeout;
+ pstSoap->send_timeout = io_pProfile->m_iTransactionTimeout;
+ pstSoap->recv_timeout = io_pProfile->m_iTransactionTimeout;
+ }
+ else
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("Malloc %x pstSoap returned null\n",
+ sizeof(struct soap));
+#endif
+
+ }
+ }
+
+ // delete the existing cluster config if the input IP address
+ // does not match one already known to the cluster config
+
+ // Note that KMSClientProfile may be too large to fit on the stack, so we're
+ // going to put it on the heap.
+
+ KMSClientProfile* pstTempProfile = 0;
+ bool bFound = false;
+ int i;
+
+ if ( bSuccess )
+ {
+ pstTempProfile = (KMSClientProfile*)malloc( sizeof(KMSClientProfile) );
+ bSuccess = (pstTempProfile != 0);
+#if defined(METAWARE)
+ if (!bSuccess)
+ log_printf("Malloc %x pstTempProfile returned null\n",
+ sizeof(KMSClientProfile));
+#endif
+
+ }
+
+ int bClusterInformationFound = false;
+
+ if ( bSuccess )
+ {
+ memcpy( pstTempProfile, io_pProfile, sizeof(KMSClientProfile) );
+
+ bSuccess = LoadClusterInformation( pstTempProfile, bClusterInformationFound );
+ }
+
+ // got cluster info from persistent storage
+ if ( bSuccess && bClusterInformationFound )
+ {
+ // see if address is a member of the remembered cluster or is a
+ // new kma, meaning this KMA joins the cluster as the
+ // discovery KMA.
+ for ( i = 0; i < pstTempProfile->m_iClusterNum; i++ )
+ {
+ bFound = (strncmp( pstTempProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ io_pProfile->m_wsApplianceAddress,
+ KMS_MAX_NETWORK_ADDRESS) == 0);
+
+ if ( bFound )
+ {
+ break;
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ log_printf ("KMSClient_LoadProfile : Appliance Address doesn't match");
+#endif
+ }
+
+ if ( !bFound )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf ("KMSClient_LoadProfile : delete cluster");
+#endif
+ DeleteCluster( pstTempProfile );
+ char msg[256];
+ K_snprintf(msg, 256,
+ "KMSClientProfile.LoadProfile(): deleting previous cluster config, %s not found\n",
+ io_pProfile->m_wsApplianceAddress);
+ Log(AUDIT_CLIENT_LOAD_PROFILE,
+ i_wsProfileName,
+ NULL,
+ msg );
+ DeleteCluster( pstTempProfile );
+ }
+ else
+ {
+ // since address is a member of the persisted cluster copy the persisted cluster info to the profile
+ io_pProfile->m_iClusterNum = pstTempProfile->m_iClusterNum;
+ memcpy(io_pProfile->m_aCluster,
+ pstTempProfile->m_aCluster,
+ sizeof(KMSClusterEntry)*io_pProfile->m_iClusterNum);
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else
+ log_printf ("KMSClient_LoadProfile : no persisted cluster information");
+#endif
+
+ if ( pstTempProfile )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf ("KMSClient_LoadProfile : free the temporary profile");
+#endif
+ free( pstTempProfile );
+ pstTempProfile = 0;
+ }
+
+ if ( bSuccess && !io_pProfile->m_iEnrolled )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf ("KMSClient_LoadProfile : call EnrollAgent");
+#endif
+ // enroll the agent
+ bSuccess = EnrollAgent( io_pProfile,
+ i_wsEntityID,
+ i_wsPassphrase );
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else if (io_pProfile->m_iEnrolled)
+ log_printf ("KMSClient_LoadProfile : Already Enrolled");
+#endif
+
+
+
+ if (bSuccess)
+ {
+ // Initialize SSL - use CLIENT AUTH
+ // CLIENT_AUTHENTICATION needs the pstSoap, and expects
+ // the profile io_pProfile to be full (have the other certificates
+ // and keypair)
+
+ if ( bSuccess )
+ {
+ bSuccess =
+ K_soap_ssl_client_context(
+ io_pProfile, // in/out
+ pstSoap, // out
+ SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION // in - flags
+ ) == SOAP_OK;
+
+ if ( !bSuccess )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ if (!bSuccess)
+ log_printf ("KMSClient_LoadProfile : K_soap_ssl_client_context failed");
+#endif
+ GetSoapFault(sSoapFaultMsg, (struct soap*)pstSoap);
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+
+ LogError(io_pProfile,
+ AUDIT_CLIENT_LOAD_PROFILE_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg );
+ }
+ }
+
+ // discover the cluster
+
+ if ( bSuccess &&
+ io_pProfile->m_iClusterDiscoveryFrequency > 0 )
+ {
+ bSuccess = ( KMSClient_GetClusterInformation(
+ io_pProfile,
+ io_pProfile->m_wsEntitySiteID,
+ sizeof(io_pProfile->m_wsEntitySiteID),
+ &(io_pProfile->m_iClusterNum),
+ io_pProfile->m_aCluster,
+ KMS_MAX_CLUSTER_NUM) != 0 );
+ // KMSClient_GetClusterInformation logs errors
+
+ if (bSuccess && i_eKMSmode == FIPS_MODE)
+ {
+ bSuccess = !KMSClient_NoFIPSCompatibleKMAs(io_pProfile);
+ if (!bSuccess)
+ {
+ LogError(io_pProfile,
+ AUDIT_CLIENT_AGENT_LOAD_PROFILE_NO_FIPS_COMPATIBLE_KMAS_AVAILABLE,
+ NULL,
+ NULL,
+ NULL );
+ }
+ }
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ if (!bSuccess)
+ log_printf ("KMSClient_LoadProfile : getClusterInformation failed");
+#endif
+
+#ifdef KMSUSERPKCS12
+ /*
+ * Once the SSL context is established, delete the
+ * private key file.
+ */
+ (void) CleanupPrivateKeyFile(io_pProfile);
+#endif
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ else if (!bSuccess)
+ log_printf ("KMSClient_LoadProfile : EnrollAgent failed");
+#endif
+
+ CAgentLoadBalancer *pAgentLoadBalancer = new CAgentLoadBalancer(io_pProfile);
+ if(pAgentLoadBalancer == NULL)
+ {
+ bSuccess = false;
+ }
+
+#if defined(DEBUG) && defined(METAWARE)
+ if (!bSuccess)
+ log_printf ("KMSClient_LoadProfile : new CAgentLoadBalancer failed");
+#endif
+
+ io_pProfile->m_pAgentLoadBalancer = pAgentLoadBalancer;
+
+ // create a data unit server affinity cache for Agents
+
+ if ( bSuccess )
+ {
+ io_pProfile->m_pDataUnitCache = new CDataUnitCache();
+
+ bSuccess = ( io_pProfile->m_pDataUnitCache != NULL );
+ }
+
+ if ( bSuccess )
+ {
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf ("KMSClient_LoadProfile : set version to KMS_AGENT_VERSION = %x",
+ KMS_AGENT_VERSION);
+ log_printf ("KMSClient_LoadProfile : profile is: %x\n", io_pProfile);
+#endif
+ // this is checked later by ProfileLoaded and is taken
+ // to indicate that the profile was correctly loaded
+ io_pProfile->m_iVersion = KMS_AGENT_VERSION;
+ }
+
+ if( !bSuccess )
+ {
+ K_DestroyMutex((K_MUTEX_HANDLE)io_pProfile->m_pLock);
+ io_pProfile->m_pLock = 0;
+
+ if ( io_pProfile->m_pvSoap )
+ {
+ soap_destroy( (struct soap*)io_pProfile->m_pvSoap );
+ soap_end( (struct soap*)io_pProfile->m_pvSoap );
+ soap_done( (struct soap*)io_pProfile->m_pvSoap );
+
+ free( (struct soap*)io_pProfile->m_pvSoap );
+ io_pProfile->m_pvSoap = 0;
+
+ if( io_pProfile->m_pAgentLoadBalancer != NULL)
+ {
+ delete(reinterpret_cast <CAgentLoadBalancer *>(io_pProfile->m_pAgentLoadBalancer));
+ }
+
+ if( io_pProfile->m_pDataUnitCache != NULL)
+ {
+ delete(reinterpret_cast <CDataUnitCache *>(io_pProfile->m_pDataUnitCache));
+ }
+
+ }
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf ("KMSClient_LoadProfile : failed - returning");
+#endif
+ }
+
+ return bSuccess;
+}
+
+/**
+ * compare cluster entries having equivalent KMA names (aka Appliance alias) and
+ * return true if equal. Note: KMANetworkAddress comparison is handled separately
+ * due to IPv4/IPv6
+ */
+static bool EqualClusterEntry(
+ struct KMS_Discovery::KMS_Discovery_ClusterMember const *i_pLeft,
+ KMSClusterEntry const *i_pRight)
+{
+ bool bEnabled = i_pRight->m_iEnabled ? true : false;
+ if ( i_pLeft->Enabled != bEnabled )
+ {
+ return false;
+ }
+ if ( i_pLeft->KMAID != i_pRight->m_lApplianceID )
+ {
+ return false;
+ }
+ if ( strncmp(i_pLeft->KMASiteID,
+ i_pRight->m_wsApplianceSiteID,
+ KMS_MAX_ENTITY_SITE_ID) != 0 )
+ {
+ return false;
+ }
+ // Note: we now minimize persistence of cluster changes by not saving
+ // whenever m_iResponding changes
+
+ return true;
+}
+/**
+ * @return true if the current address matches the provided IPv6Address
+ * when the i_bUseIPv6 arg is true, otherwise compare the current address
+ * with the IPv4Address. If i_bUseIPv6 then i_pCurrentAddress must be
+ * enclosed in brackets, i.e. as in RFC 2396.
+ */
+static bool EqualKMANetworkAddress (
+ bool i_bUseIPv6,
+ const char * const i_pIPv6Address,
+ const char * const i_pIPv4Address,
+ const char * const i_pCurrentAddress
+ )
+{
+ bool bEqualAddress = true;
+
+ if ( i_pCurrentAddress == NULL )
+ {
+ return false;
+ }
+
+ if (i_bUseIPv6)
+ {
+ if ( i_pIPv6Address == NULL )
+ {
+ return false;
+ }
+ char sIPv6Address[KMS_MAX_NETWORK_ADDRESS] = "[";
+
+ strcat(sIPv6Address, i_pIPv6Address);
+
+ char * pLoc = strchr(sIPv6Address, '/');
+
+ if ( pLoc != NULL )
+ {
+ // remove prefix from address
+ *pLoc = '\0';
+ }
+ strcat(sIPv6Address, "]");
+ bEqualAddress = strncmp(sIPv6Address, i_pCurrentAddress, KMS_MAX_NETWORK_ADDRESS) == 0;
+ }
+ else
+ {
+ if ( i_pIPv4Address == NULL )
+ {
+ return false;
+ }
+ bEqualAddress = strncmp(i_pIPv4Address, i_pCurrentAddress, KMS_MAX_NETWORK_ADDRESS) == 0;
+ }
+
+ return bEqualAddress;
+}
+
+/**
+ * compares the profile's current cluster state with the filtered discover
+ * cluster response and returns true if the repsonse
+ * differs from i_pProfile->m_aCluster. A cluster has changed if the state of any
+ * cluster node has changed or if the set of cluster nodes has changed.
+ * The order of nodes is immaterial.
+ */
+static bool ClusterConfigChanged (
+ KMSClientProfile const *i_pProfile,
+ char * const i_sResponseEntitySiteID,
+ struct KMS_Discovery::KMS_Discovery__ArrayOfClusterMembers const *i_pFilteredCluster)
+{
+ int i, j;
+
+ FATAL_ASSERT(i_pProfile);
+ FATAL_ASSERT(i_pFilteredCluster);
+
+ // cardinality check
+ if (i_pProfile->m_iClusterNum !=
+ i_pFilteredCluster->__size)
+ {
+ return true;
+ }
+
+ // check if the agent's site ID changed
+ if (strncmp(i_pProfile->m_wsEntitySiteID,
+ i_sResponseEntitySiteID, KMS_MAX_ENTITY_SITE_ID) != 0)
+ {
+ return true;
+ }
+
+ // for all KMAs in filtered response check if they exist unchanged in the profile
+ for (i = 0; i < i_pFilteredCluster->__size; i++)
+ {
+ bool bFound = false;
+ for (j = 0; j < i_pProfile->m_iClusterNum; j++)
+ {
+ if (strncmp(i_pFilteredCluster->__ptr[i].KMAName,
+ i_pProfile->m_aCluster[j].m_wsApplianceAlias,
+ KMS_MAX_ENTITY_ID) == 0)
+ {
+ bFound = true;
+ if (
+ !EqualKMANetworkAddress(
+ strchr(i_pProfile->m_wsApplianceAddress, ':') ? true : false,
+ i_pFilteredCluster->__ptr[i].KMANetworkAddressIPv6,
+ i_pFilteredCluster->__ptr[i].KMANetworkAddress,
+ i_pProfile->m_aCluster[j].m_wsApplianceNetworkAddress) ||
+ !EqualClusterEntry((i_pFilteredCluster->__ptr + i),
+ &i_pProfile->m_aCluster[j]))
+
+ {
+ return true;
+ }
+ }
+ }
+ if ( !bFound )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * returns true if the string is a valid IPv6 address syntactically
+ */
+static bool ValidIPv6KMAaddress( const char * const i_pIPAddress )
+{
+ FATAL_ASSERT( i_pIPAddress );
+
+ if ( strlen(i_pIPAddress) <= 0 )
+ {
+ return false;
+ }
+
+ // simple check
+ if ( strchr( i_pIPAddress, ':'))
+ {
+ return true;
+ }
+
+ return false;
+}
+/**
+ *
+ */
+static void FreeFilteredCluster (
+ struct KMS_Discovery::KMS_Discovery__ArrayOfClusterMembers * const io_stFilteredCluster,
+ int iLimit )
+{
+ int j = 0;
+ for (; j < iLimit; j++ )
+ {
+ free( io_stFilteredCluster->__ptr[j].KMAName );
+ free( io_stFilteredCluster->__ptr[j].KMASiteID );
+ free( io_stFilteredCluster->__ptr[j].KMAHostName );
+ free( io_stFilteredCluster->__ptr[j].KMANetworkAddress );
+ free( io_stFilteredCluster->__ptr[j].KMAVersion );
+ free( io_stFilteredCluster->__ptr[j].KMAHostNameIPv6 );
+ free( io_stFilteredCluster->__ptr[j].KMANetworkAddressIPv6 );
+ }
+
+ free( io_stFilteredCluster->__ptr );
+}
+
+/**
+ * filters the discover cluster response to be less than or equal to KMS_MAX_CLUSTER_NUM KMAs. The heuristic used to filter
+ * the response is the same as used by CAgentLoadBalancer::KMSClient_SortClusterArray(), FIPS compatibility, then within site,
+ * then responding and enabled KMAs.
+ * @param i_stResponse pointer to gsoap discover cluster service response
+ * @param io_stFilteredCluster pointer to gsoap discover cluster array to be populated with the filtered list of KMAs
+ * @return true on success and io_stFilteredCluster->__size less than or equal to KMS_MAX_CLUSTER_NUM,
+ * otherwise io_stFilteredCluster is undefined. io_stFilteredCluster->__ptr is populated with the array of elements
+ * malloc'd.
+ */
+static bool FilterCluster (struct KMS_Discovery::KMS_Discovery__DiscoverClusterResponse * const i_stResponse,
+ bool i_bFIPS,
+ struct KMS_Discovery::KMS_Discovery__ArrayOfClusterMembers * const io_stFilteredCluster)
+{
+ /*
+ * do something like KMSAgentLoadBalancer:SortClusterArray() to the stResponse array
+ * return 1st KMS_MAX_CLUSTER_NUM entries and free the rest.
+ */
+
+ FATAL_ASSERT(i_stResponse);
+ FATAL_ASSERT(io_stFilteredCluster);
+
+ io_stFilteredCluster->__size = i_stResponse->ArrayOfClusterMembers.__size;
+ io_stFilteredCluster->__ptr = reinterpret_cast < struct KMS_Discovery::KMS_Discovery_ClusterMember * >
+ ( calloc( io_stFilteredCluster->__size,
+ sizeof (struct KMS_Discovery::KMS_Discovery_ClusterMember ) ) );
+
+ if (io_stFilteredCluster->__ptr == NULL)
+ {
+ Log(AUDIT_CLIENT_FILTER_CLUSTER_FAILED,
+ NULL,
+ NULL,
+ "calloc failed");
+ return false;
+ }
+
+ if (io_stFilteredCluster->__size <= 0)
+ {
+ Log(AUDIT_CLIENT_FILTER_CLUSTER_FAILED,
+ NULL,
+ NULL,
+ "returned cluster size is not positive");
+ return false;
+ }
+
+ // copy response cluster members
+ for (int i = 0; i < io_stFilteredCluster->__size; i++)
+ {
+ bool bSuccess = true;
+
+ size_t iKMANameSize = 0, iKMASiteIDSize = 0, iKMAHostNameSize = 0,
+ iKMANetworkAddressSize = 0, iKMAVersionSize = 0, iKMAHostNameIPv6Size = 0,
+ iKMANetworkAddressIPv6Size = 0;
+
+ // allocate storage for the various struct member's arrays
+ iKMANameSize = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAName)+1;
+ io_stFilteredCluster->__ptr[i].KMAName = reinterpret_cast <char *> (malloc(iKMANameSize));
+
+ iKMASiteIDSize = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMASiteID)+1;
+ io_stFilteredCluster->__ptr[i].KMASiteID = reinterpret_cast <char *> (malloc(iKMASiteIDSize));
+
+ iKMAHostNameSize = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAHostName)+1;
+ io_stFilteredCluster->__ptr[i].KMAHostName = reinterpret_cast <char *> (malloc(iKMAHostNameSize));
+
+ iKMANetworkAddressSize = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMANetworkAddress)+1;
+ io_stFilteredCluster->__ptr[i].KMANetworkAddress = reinterpret_cast <char *> (malloc(iKMANetworkAddressSize));
+
+ // KMAVersion is an optional field derived from an xml attribute in the soap interface that will not be present in 2.0 KMAs
+ if (i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAVersion)
+ {
+ iKMAVersionSize = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAVersion)+1;
+ io_stFilteredCluster->__ptr[i].KMAVersion = reinterpret_cast <char *> (malloc(iKMAVersionSize));
+ if (io_stFilteredCluster->__ptr[i].KMAVersion == NULL)
+ {
+ bSuccess = false;
+ }
+ }
+ else
+ {
+ io_stFilteredCluster->__ptr[i].KMAVersion = NULL;
+ }
+
+ // KMAHostNameIPv6 is an optional field derived from an xml attribute in the soap interface that will not be present in 2.0 KMAs
+ if (i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAHostNameIPv6)
+ {
+ iKMAHostNameIPv6Size = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAHostNameIPv6)+1;
+ io_stFilteredCluster->__ptr[i].KMAHostNameIPv6 = reinterpret_cast <char *> (malloc(iKMAHostNameIPv6Size));
+ if ( io_stFilteredCluster->__ptr[i].KMAHostNameIPv6 == NULL )
+ {
+ bSuccess = false;
+ }
+ }
+ else
+ {
+ io_stFilteredCluster->__ptr[i].KMAHostNameIPv6 = NULL;
+ }
+
+ // KMANetworkAddressIPv6 is an optional field derived from an xml attribute in the soap interface that will not be present in 2.0 KMAs
+ if (i_stResponse->ArrayOfClusterMembers.__ptr[i].KMANetworkAddressIPv6)
+ {
+ iKMANetworkAddressIPv6Size = strlen(i_stResponse->ArrayOfClusterMembers.__ptr[i].KMANetworkAddressIPv6)+1;
+ io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6 = reinterpret_cast <char *> (malloc(iKMANetworkAddressIPv6Size));
+ if ( io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6 == NULL )
+ {
+ bSuccess = false;
+ }
+ }
+ else
+ {
+ io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6 = NULL;
+ }
+
+ if ( io_stFilteredCluster->__ptr[i].KMAName == NULL ||
+ io_stFilteredCluster->__ptr[i].KMASiteID == NULL ||
+ io_stFilteredCluster->__ptr[i].KMAHostName == NULL ||
+ io_stFilteredCluster->__ptr[i].KMANetworkAddress == NULL ||
+ !bSuccess )
+ {
+ // cleanup and return
+ FreeFilteredCluster( io_stFilteredCluster, i+1 );
+ Log( AUDIT_CLIENT_FILTER_CLUSTER_FAILED,
+ NULL,
+ NULL,
+ "malloc failed" );
+ return false;
+ }
+
+ strncpy(io_stFilteredCluster->__ptr[i].KMAName,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAName,
+ iKMANameSize);
+ io_stFilteredCluster->__ptr[i].KMAName[iKMANameSize-1] = '\0';
+
+ strncpy(io_stFilteredCluster->__ptr[i].KMASiteID,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMASiteID,
+ iKMASiteIDSize);
+ io_stFilteredCluster->__ptr[i].KMASiteID[iKMASiteIDSize-1] = '\0';
+
+ strncpy(io_stFilteredCluster->__ptr[i].KMAHostName,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAHostName,
+ iKMAHostNameSize);
+ io_stFilteredCluster->__ptr[i].KMAHostName[iKMAHostNameSize-1] = '\0';
+
+ strncpy(io_stFilteredCluster->__ptr[i].KMANetworkAddress,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMANetworkAddress,
+ iKMANetworkAddressSize);
+ io_stFilteredCluster->__ptr[i].KMANetworkAddress[iKMANetworkAddressSize-1] = '\0';
+
+ if ( io_stFilteredCluster->__ptr[i].KMAVersion )
+ {
+ strncpy( io_stFilteredCluster->__ptr[i].KMAVersion,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAVersion,
+ iKMAVersionSize );
+ io_stFilteredCluster->__ptr[i].KMAVersion[iKMAVersionSize-1] = '\0';
+ }
+
+ if (io_stFilteredCluster->__ptr[i].KMAHostNameIPv6)
+ {
+ strncpy(io_stFilteredCluster->__ptr[i].KMAHostNameIPv6,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAHostNameIPv6,
+ iKMAHostNameIPv6Size);
+ io_stFilteredCluster->__ptr[i].KMAHostNameIPv6[iKMAHostNameIPv6Size-1] = '\0';
+ }
+
+ if ( io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6 )
+ {
+ strncpy( io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6,
+ i_stResponse->ArrayOfClusterMembers.__ptr[i].KMANetworkAddressIPv6,
+ iKMANetworkAddressIPv6Size );
+ io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6[iKMANetworkAddressIPv6Size-1] = '\0';
+ }
+
+ io_stFilteredCluster->__ptr[i].KMAID = i_stResponse->ArrayOfClusterMembers.__ptr[i].KMAID;
+ io_stFilteredCluster->__ptr[i].Enabled = i_stResponse->ArrayOfClusterMembers.__ptr[i].Enabled;
+ io_stFilteredCluster->__ptr[i].KMS_Discovery__Locked = i_stResponse->ArrayOfClusterMembers.__ptr[i].KMS_Discovery__Locked;
+
+ // set load to zero, KMA with version <= Build600 don't initialize
+ // the load field from the service network
+ if ( ( io_stFilteredCluster->__ptr[i].KMAVersion &&
+ strcmp( io_stFilteredCluster->__ptr[i].KMAVersion, "Build600" ) <= 0 ) ||
+ io_stFilteredCluster->__ptr[i].KMAVersion == NULL )
+ {
+ io_stFilteredCluster->__ptr[i].Load = 0;
+ }
+ else
+ {
+ io_stFilteredCluster->__ptr[i].Load = i_stResponse->ArrayOfClusterMembers.__ptr[i].Load;
+ }
+
+ io_stFilteredCluster->__ptr[i].Responding = i_stResponse->ArrayOfClusterMembers.__ptr[i].Responding;
+
+ if (!bSuccess)
+ {
+ FreeFilteredCluster( io_stFilteredCluster, i );
+ Log(AUDIT_CLIENT_FILTER_CLUSTER_FAILED,
+ NULL,
+ NULL,
+ "cluster member copy failed");
+ return false;
+ }
+ }
+
+ // is filtering necessary?
+ if (io_stFilteredCluster->__size <= KMS_MAX_CLUSTER_NUM)
+ {
+ // no filtering required
+ return true;
+ }
+ else
+ {
+ char sMesg[100];
+ K_snprintf(sMesg, sizeof (sMesg), "DiscoverCluster returned %d KMAs, filtering to %d ...", io_stFilteredCluster->__size, KMS_MAX_CLUSTER_NUM);
+ Log(AUDIT_CLIENT_FILTER_CLUSTER,
+ NULL,
+ NULL,
+ sMesg);
+
+ }
+
+ // adjust loads according to availability, site and FIPS compatibility
+ {
+ int i = 0;
+ for (; i < io_stFilteredCluster->__size; i++)
+ {
+ if (io_stFilteredCluster->__ptr[i].Enabled == false
+ || io_stFilteredCluster->__ptr[i].Responding == false
+ || io_stFilteredCluster->__ptr[i].KMS_Discovery__Locked == true)
+ {
+ io_stFilteredCluster->__ptr[i].Load += 0x40;
+ }
+
+ if (strcmp(io_stFilteredCluster->__ptr[i].KMASiteID,
+ i_stResponse->EntitySiteID) != 0)
+ {
+ io_stFilteredCluster->__ptr[i].Load += 0x20;
+
+ }
+
+ if ( i_bFIPS &&
+ !FIPScompatibleKMA(io_stFilteredCluster->__ptr[i].KMAVersion))
+ {
+ io_stFilteredCluster->__ptr[i].Load += 0x80;
+ }
+ }
+ }
+
+ // sort ascending by load
+
+ // gnome sort: the simplest sort algoritm
+ {
+ int i = 0;
+ while (i < io_stFilteredCluster->__size)
+ {
+ if (i == 0 || io_stFilteredCluster->__ptr[i - 1].Load <= io_stFilteredCluster->__ptr[i].Load)
+ {
+ i++;
+ }
+ else
+ {
+ struct KMS_Discovery::KMS_Discovery_ClusterMember tmp = io_stFilteredCluster->__ptr[i];
+ io_stFilteredCluster->__ptr[i] = io_stFilteredCluster->__ptr[i - 1];
+ io_stFilteredCluster->__ptr[--i] = tmp;
+ }
+ }
+ }
+
+ // now filter the list, freeing memory allocated for copied elements that are not being retained
+ {
+ int i=KMS_MAX_CLUSTER_NUM;
+ for (; i < io_stFilteredCluster->__size; i++)
+ {
+ free(io_stFilteredCluster->__ptr[i].KMAName);
+ free(io_stFilteredCluster->__ptr[i].KMASiteID);
+ free(io_stFilteredCluster->__ptr[i].KMAHostName);
+ free(io_stFilteredCluster->__ptr[i].KMANetworkAddress);
+ free(io_stFilteredCluster->__ptr[i].KMAVersion);
+ free(io_stFilteredCluster->__ptr[i].KMAHostNameIPv6);
+ free(io_stFilteredCluster->__ptr[i].KMANetworkAddressIPv6);
+ }
+ }
+
+ io_stFilteredCluster->__size = KMS_MAX_CLUSTER_NUM;
+
+ Log(AUDIT_CLIENT_FILTER_CLUSTER,
+ NULL,
+ NULL,
+ "success");
+
+ return true;
+};
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_GetClusterInformation
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_GetClusterInformation(
+ KMSClientProfile *i_pProfile,
+ utf8char *o_wsEntitySiteID,
+ int i_iEntitySiteIDSize,
+ int *o_pApplianceNum,
+ KMSClusterEntry *o_pClusterEntryArray,
+ int i_iClusterEntryArraySize)
+{
+ FATAL_ASSERT(i_pProfile);
+ FATAL_ASSERT( o_wsEntitySiteID );
+ FATAL_ASSERT( o_pApplianceNum );
+ FATAL_ASSERT( o_pClusterEntryArray );
+ FATAL_ASSERT( i_iEntitySiteIDSize <= KMS_MAX_ENTITY_ID+1 );
+
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+
+ bool bSuccess = true;
+ char sSoapFaultMsg[g_iMAX_SOAP_FAULT_MESSAGE_LENGTH];
+ char sKmaAddress[g_iMAX_PEER_NETWORK_ADDRESS_LENGTH];
+
+ char sURL[KMS_MAX_URL+1];
+
+ // set URL from the initial appliance address
+ utf8cstr sApplianceAddress = i_pProfile->m_wsApplianceAddress;
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_GetClusterInformation : entered");
+#endif
+
+ K_snprintf(sURL,
+ KMS_MAX_URL,
+ "https://%s:%d",
+ sApplianceAddress,
+ i_pProfile->m_iPortForDiscoveryService);
+ strncpy(i_pProfile->m_sURL, sURL, KMS_MAX_URL);
+ i_pProfile->m_sURL[KMS_MAX_URL] = 0;
+
+ // allocate and initialize a new soap env for the cluster discovery call
+ struct soap *pstSoap = (struct soap*)i_pProfile->m_pvDiscoverySoap;
+
+ if ( !i_pProfile->m_iEnrolled )
+ {
+ bSuccess = false;
+ }
+
+ if ( bSuccess )
+ {
+ // allocate discovery soap runtime
+ if (pstSoap == NULL )
+ {
+ pstSoap = soap_new();
+ i_pProfile->m_pvDiscoverySoap = pstSoap;
+ /* soap_copy results in a segfault in sk_free() within libcrytpo.so
+ pstSoap = soap_copy( (soap*)i_pProfile->m_pvSoap );
+ */
+ if (pstSoap == NULL)
+ {
+ bSuccess = false;
+ }
+ else
+ {
+ pstSoap->connect_timeout = i_pProfile->m_iTransactionTimeout;
+ pstSoap->send_timeout = i_pProfile->m_iTransactionTimeout;
+ pstSoap->recv_timeout = i_pProfile->m_iTransactionTimeout;
+
+ soap_set_imode( pstSoap, (SOAP_XML_STRICT | SOAP_C_UTFSTRING) );
+ soap_set_omode( pstSoap, (SOAP_XML_STRICT | SOAP_C_UTFSTRING) );
+
+ soap_set_namespaces( pstSoap, KMS_Discovery_namespaces );
+ bSuccess = K_soap_ssl_client_context(
+ i_pProfile,
+ pstSoap,
+ SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION
+ ) == SOAP_OK;
+ if ( !bSuccess )
+ {
+ Log(AUDIT_CLIENT_GetClusterInformation,
+ NULL,
+ NULL,
+ "K_soap_ssl_client_context failed");
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ soap_done(pstSoap);
+ }
+ }
+ }
+ }
+
+ // Discovery
+ struct KMS_Discovery::KMS_Discovery__DiscoverClusterResponse stResponse;
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf("KMSClient_GetClusterInformation : call KMS_Discovery_DiscoverCluster");
+#endif
+
+ // SOAP - discover cluster
+ if ( bSuccess )
+ {
+#ifdef DEBUG
+ int iStartTickCount = K_GetTickCount();
+ int iEndTickCount;
+ char sDiscoverTimeMsg[100];
+#endif
+ bSuccess =
+ KMS_Discovery::soap_call_KMS_Discovery__DiscoverCluster(
+ pstSoap,
+ sURL,
+ NULL,
+ NULL,
+ stResponse ) == SOAP_OK;
+#ifdef DEBUG
+ iEndTickCount = K_GetTickCount();
+ sprintf(sDiscoverTimeMsg, "DiscoverCluster soapcall elapsed time=%u ms",
+ iEndTickCount-iStartTickCount);
+ Log(AUDIT_CLIENT_GetClusterInformation,
+ NULL,
+ sApplianceAddress,
+ sDiscoverTimeMsg);
+#endif
+
+ if ( !bSuccess )
+ {
+ GetSoapFault(sSoapFaultMsg, (struct soap*)pstSoap);
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CLUSTER_INFORMATION_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg );
+
+ if ( !ServerError( sSoapFaultMsg, pstSoap->errnum ) )
+ {
+ // do not failover if error is client related
+ soap_destroy( pstSoap );
+ soap_end( pstSoap );
+ soap_free( pstSoap );
+ return false;
+ }
+ }
+
+ // If we did not succeed to Discover from the initial appliance,
+ // try to discover from other appliances that we know about that are enabled.
+ // Disabled Appliances are not attempted because they may have a stale view
+ // of the cluster. In particular, they themselves are not aware that they
+ // are disabled.
+
+ if ( !bSuccess && i_pProfile->m_iClusterNum > 0 )
+ {
+ // Copy the profile's cluster array so that we don't have to lock the
+ // profile around a SOAP call
+
+ int j = 0;
+ int iClusterNum = 0;
+ KMSClusterEntry* aCluster =
+ (KMSClusterEntry*)malloc(sizeof(KMSClusterEntry) * KMS_MAX_CLUSTER_NUM);
+
+ bSuccess = ( aCluster != 0 );
+#if defined(DEBUG) && defined(METAWARE)
+ if (!bSuccess)
+ log_printf("Malloc %x aCluster returned null\n",
+ sizeof(KMSClusterEntry) * KMS_MAX_CLUSTER_NUM);
+#endif
+
+ if ( bSuccess )
+ {
+ iClusterNum = i_pProfile->m_iClusterNum;
+ memcpy( aCluster, i_pProfile->m_aCluster,
+ sizeof(KMSClusterEntry) * iClusterNum );
+
+ // initialize to false since all KMAs could be disabled
+ bSuccess = false;
+ for ( j = 0; j < iClusterNum; j++ )
+ {
+ if ( aCluster[j].m_iEnabled == FALSE )
+ {
+ continue;
+ }
+
+ sApplianceAddress = aCluster[j].m_wsApplianceNetworkAddress;
+ K_snprintf(sURL,
+ KMS_MAX_URL,
+ "https://%s:%d",
+ sApplianceAddress,
+ i_pProfile->m_iPortForDiscoveryService);
+
+ Log(AUDIT_CLIENT_GetClusterInformation,
+ NULL,
+ sApplianceAddress,
+ "Failing over and trying this appliance");
+
+ // SOAP - discover cluster
+ bSuccess =
+ KMS_Discovery::soap_call_KMS_Discovery__DiscoverCluster(
+ pstSoap,
+ sURL,
+ NULL,
+ NULL,
+ stResponse ) == SOAP_OK;
+
+ if ( !bSuccess )
+ {
+ GetSoapFault(sSoapFaultMsg, (struct soap*)pstSoap);
+ GetPeerNetworkAddress(sKmaAddress, pstSoap);
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CLUSTER_INFORMATION_SOAP_ERROR,
+ NULL,
+ sKmaAddress,
+ sSoapFaultMsg );
+ }
+ else
+ {
+ // The discover succeeded
+ break;
+ }
+ }
+ }
+
+ if ( aCluster != 0 )
+ {
+ free(aCluster);
+ }
+
+ if ( bSuccess )
+ {
+ // Set the Profile's initial appliance to the Appliance
+ // that we just succeeded to Discover from. KMSClient_SelectAppliance()
+ // persists the updated config
+ KMSClient_SelectAppliance( i_pProfile,
+ i_pProfile->m_aCluster[j].m_wsApplianceNetworkAddress );
+ }
+ }
+ }
+
+ if ( bSuccess )
+ {
+ if (((int)strlen(stResponse.EntitySiteID) > i_iEntitySiteIDSize - 1))
+ {
+ bSuccess = false;
+ LogError(i_pProfile,AUDIT_CLIENT_GET_CLUSTER_INFORMATION,
+ NULL,
+ NULL,
+ "returned site id size too large" );
+ }
+ }
+
+ // copy returned cluster information into i_pProfile->m_aCluster after
+ // filtering the cluster members to a list with size <= KMS_MAX_CLUSTER_NUM
+ if ( bSuccess )
+ {
+ KMS_Discovery::KMS_Discovery__ArrayOfClusterMembers aFilteredCluster;
+
+ bSuccess = FilterCluster(&stResponse, i_pProfile->m_eKMSmode == FIPS_MODE, &aFilteredCluster);
+ if (!bSuccess )
+ {
+ LogError(i_pProfile, AUDIT_CLIENT_GET_CLUSTER_INFORMATION,
+ NULL,
+ NULL,
+ "cluster response filtering failed" );
+ }
+
+ if(bSuccess)
+ {
+ int i;
+ bool bPersistClusterConfig = ClusterConfigChanged(i_pProfile,
+ stResponse.EntitySiteID,
+ &aFilteredCluster);
+
+ strncpy(o_wsEntitySiteID,stResponse.EntitySiteID, i_iEntitySiteIDSize-1 );
+ o_wsEntitySiteID[i_iEntitySiteIDSize-1] = '\0';
+
+ strncpy(i_pProfile->m_wsEntitySiteID, stResponse.EntitySiteID, i_iEntitySiteIDSize-1 );
+ i_pProfile->m_wsEntitySiteID[i_iEntitySiteIDSize-1] = '\0';
+
+ // fill the aCluster array in the i_pProfile
+ i_pProfile->m_iClusterNum = aFilteredCluster.__size;
+ for (i = 0; i < i_pProfile->m_iClusterNum; i++)
+ {
+ i_pProfile->m_aCluster[i].m_lApplianceID =
+ (aFilteredCluster.__ptr+i)->KMAID;
+ i_pProfile->m_aCluster[i].m_iEnabled =
+ (aFilteredCluster.__ptr+i)->Enabled;
+ i_pProfile->m_aCluster[i].m_iResponding =
+ (aFilteredCluster.__ptr+i)->Responding;
+
+ i_pProfile->m_aCluster[i].m_lLoad = (aFilteredCluster.__ptr+i)->Load;
+ strncpy(i_pProfile->m_aCluster[i].m_wsApplianceAlias,
+ (aFilteredCluster.__ptr+i)->KMAName,
+ KMS_MAX_ENTITY_ID);
+ i_pProfile->m_aCluster[i].m_wsApplianceAlias[KMS_MAX_ENTITY_ID] = '\0';
+ // if the m_wsApplianceAddress is IPv6 then we'll store
+ // KMA IPv6 addresses if they have one
+ if ( strchr( i_pProfile->m_wsApplianceAddress, ':') )
+ {
+ // KMAs prior to 2.1, or 2.1 KMAs at rep schema < 10
+ // will not have IPv6 attributes in the soap response
+ if ( (aFilteredCluster.__ptr+i)->KMANetworkAddressIPv6 &&
+ ValidIPv6KMAaddress((aFilteredCluster.__ptr+i)->KMANetworkAddressIPv6))
+ {
+ strcpy(i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress, "[");
+ char * pLoc = strchr((aFilteredCluster.__ptr+i)->KMANetworkAddressIPv6,
+ '/');
+ if ( pLoc != NULL )
+ {
+ // remove prefix from address
+ *pLoc = '\0';
+ strcat(i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ (aFilteredCluster.__ptr+i)->KMANetworkAddressIPv6 );
+ }
+ else
+ {
+ strcat(i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ (aFilteredCluster.__ptr + i)->KMANetworkAddressIPv6);
+ }
+ strcat(i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress, "]");
+ }
+ else
+ {
+ // use the IPv4 address
+ strncpy(i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ (aFilteredCluster.__ptr+i)->KMANetworkAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ }
+ }
+ else
+ {
+ strncpy(i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ (aFilteredCluster.__ptr+i)->KMANetworkAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ }
+ i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS] = '\0';
+ strncpy(i_pProfile->m_aCluster[i].m_wsApplianceSiteID,
+ (aFilteredCluster.__ptr+i)->KMASiteID,
+ KMS_MAX_ENTITY_SITE_ID);
+ i_pProfile->m_aCluster[i].m_wsApplianceSiteID[KMS_MAX_ENTITY_SITE_ID] = '\0';
+
+ if ((aFilteredCluster.__ptr + i)->KMAVersion)
+ {
+ strncpy(i_pProfile->m_aCluster[i].m_sKMAVersion,
+ (aFilteredCluster.__ptr + i)->KMAVersion,
+ KMS_MAX_VERSION_LENGTH);
+ i_pProfile->m_aCluster[i].m_sKMAVersion[KMS_MAX_VERSION_LENGTH] = '\0';
+ }
+ else
+ {
+ i_pProfile->m_aCluster[i].m_sKMAVersion[0] = '\0';
+ }
+
+ if ((aFilteredCluster.__ptr + i)->KMS_Discovery__Locked)
+ {
+ i_pProfile->m_aCluster[i].m_iKMALocked = TRUE;
+ }
+ else
+ {
+ i_pProfile->m_aCluster[i].m_iKMALocked = FALSE;
+ }
+ }
+
+ // now release malloc'd storage from filtering the cluster response
+ FreeFilteredCluster( &aFilteredCluster, aFilteredCluster.__size );
+
+ // fill the array specified by the caller
+ *o_pApplianceNum = i_pProfile->m_iClusterNum;
+ for (i = 0; i < i_pProfile->m_iClusterNum; i++)
+ {
+ o_pClusterEntryArray[i].m_lApplianceID = i_pProfile->m_aCluster[i].m_lApplianceID;
+ o_pClusterEntryArray[i].m_iEnabled = i_pProfile->m_aCluster[i].m_iEnabled;
+ o_pClusterEntryArray[i].m_iResponding = i_pProfile->m_aCluster[i].m_iResponding;
+ o_pClusterEntryArray[i].m_lLoad = i_pProfile->m_aCluster[i].m_lLoad;
+ strncpy(o_pClusterEntryArray[i].m_wsApplianceAlias,
+ i_pProfile->m_aCluster[i].m_wsApplianceAlias,
+ KMS_MAX_ENTITY_ID);
+ o_pClusterEntryArray[i].m_wsApplianceAlias[KMS_MAX_ENTITY_ID] = '\0';
+ strncpy(o_pClusterEntryArray[i].m_wsApplianceNetworkAddress,
+ i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ o_pClusterEntryArray[i].m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS] = '\0';
+ strncpy(o_pClusterEntryArray[i].m_wsApplianceSiteID,
+ i_pProfile->m_aCluster[i].m_wsApplianceSiteID,
+ KMS_MAX_ENTITY_SITE_ID);
+ o_pClusterEntryArray[i].m_wsApplianceSiteID[KMS_MAX_ENTITY_SITE_ID] = '\0';
+ strncpy(o_pClusterEntryArray[i].m_sKMAVersion, i_pProfile->m_aCluster[i].m_sKMAVersion,
+ KMS_MAX_VERSION_LENGTH);
+ o_pClusterEntryArray[i].m_sKMAVersion[KMS_MAX_VERSION_LENGTH] = '\0';
+ }
+
+ i_pProfile->m_iLastClusterDiscoveryTime = K_GetTickCount() / 1000;
+ i_pProfile->m_bIsClusterDiscoveryCalled = true;
+
+ if ( bPersistClusterConfig )
+ {
+ bSuccess = StoreCluster(i_pProfile);
+ if (!bSuccess)
+ {
+ Log(AUDIT_CLIENT_GetClusterInformation,
+ NULL,
+ NULL,
+ "Could not store cluster");
+ }
+ }
+ }
+ }
+
+ // cleanup
+ if (pstSoap)
+ {
+ soap_destroy(pstSoap);
+ soap_end(pstSoap);
+ if (!bSuccess)
+ {
+ soap_free(pstSoap);
+ }
+ else
+ {
+ // we want to persist discovery soap runtime to avoid ssl handshakes so soap_free() is not called
+ }
+ }
+
+ // if we're enrolled but cannot get cluster information from an appliance, then we'll try to load
+ // it from the profile
+ if ( !bSuccess && i_pProfile->m_iEnrolled )
+ {
+ int bClusterInformationFound = false;
+
+ bSuccess = LoadClusterInformation( i_pProfile, bClusterInformationFound );
+
+ if ( bSuccess && bClusterInformationFound )
+ {
+ Log(AUDIT_CLIENT_GetClusterInformation,
+ NULL,
+ NULL,
+ "Using persisted cluster information");
+
+ strncpy(o_wsEntitySiteID, i_pProfile->m_wsEntitySiteID, i_iEntitySiteIDSize-1);
+ o_wsEntitySiteID[i_iEntitySiteIDSize-1] = '\0';
+
+ // fill the array specified by the caller
+ *o_pApplianceNum = i_pProfile->m_iClusterNum;
+ for (int i = 0; i < i_pProfile->m_iClusterNum; i++)
+ {
+ o_pClusterEntryArray[i].m_lApplianceID = i_pProfile->m_aCluster[i].m_lApplianceID;
+ o_pClusterEntryArray[i].m_iEnabled = i_pProfile->m_aCluster[i].m_iEnabled;
+ o_pClusterEntryArray[i].m_iResponding = TRUE; // since cluster info comes from a file, set it to TRUE
+
+ o_pClusterEntryArray[i].m_lLoad = i_pProfile->m_aCluster[i].m_lLoad;
+ strncpy(o_pClusterEntryArray[i].m_wsApplianceAlias,
+ i_pProfile->m_aCluster[i].m_wsApplianceAlias,
+ KMS_MAX_ENTITY_ID);
+ o_pClusterEntryArray[i].m_wsApplianceAlias[KMS_MAX_ENTITY_ID] = '\0';
+ strncpy(o_pClusterEntryArray[i].m_wsApplianceNetworkAddress,
+ i_pProfile->m_aCluster[i].m_wsApplianceNetworkAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ o_pClusterEntryArray[i].m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS] = '\0';
+ strncpy(o_pClusterEntryArray[i].m_wsApplianceSiteID,
+ i_pProfile->m_aCluster[i].m_wsApplianceSiteID,
+ KMS_MAX_ENTITY_SITE_ID);
+ o_pClusterEntryArray[i].m_wsApplianceSiteID[KMS_MAX_ENTITY_SITE_ID] = '\0';
+ strncpy(o_pClusterEntryArray[i].m_sKMAVersion,
+ i_pProfile->m_aCluster[i].m_sKMAVersion,
+ KMS_MAX_VERSION_LENGTH);
+ o_pClusterEntryArray[i].m_sKMAVersion[KMS_MAX_VERSION_LENGTH] = '\0';
+ }
+
+ i_pProfile->m_iLastClusterDiscoveryTime = K_GetTickCount() / 1000;
+ }
+ else if ( bSuccess && !bClusterInformationFound )
+ {
+ // if we're here, then we need to return an error
+ bSuccess = false;
+ }
+ }
+
+ return bSuccess;
+}
+
+bool KMSClient_NoFIPSCompatibleKMAs(const KMSClientProfile * const i_pProfile)
+{
+ bool bNoFIPScompatibleKMA = true;
+ for (int i=0; i < i_pProfile->m_iClusterNum; i++)
+ {
+ if ( FIPScompatibleKMA(i_pProfile->m_aCluster[i].m_sKMAVersion))
+ {
+ bNoFIPScompatibleKMA = false;
+ break;
+ }
+ }
+ return bNoFIPScompatibleKMA;
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_SelectAppliance
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_SelectAppliance(KMSClientProfile *i_pProfile,
+ utf8char *i_wsApplianceAddress)
+{
+ FATAL_ASSERT(i_pProfile);
+ FATAL_ASSERT(i_wsApplianceAddress);
+
+ CAutoMutex oAutoMutex( (K_MUTEX_HANDLE)i_pProfile->m_pLock );
+
+ bool bSuccess = true;
+
+ if(strlen(i_wsApplianceAddress) >= KMS_MAX_NETWORK_ADDRESS)
+ {
+ LogError(i_pProfile,AUDIT_CLIENT_SELECT_APPLIANCE,
+ NULL,
+ NULL,
+ "Appliance Address too large" );
+ bSuccess = false;
+ }
+
+ if(bSuccess)
+ {
+ strncpy(i_pProfile->m_wsApplianceAddress,
+ i_wsApplianceAddress,
+ KMS_MAX_NETWORK_ADDRESS);
+ i_pProfile->m_wsApplianceAddress[KMS_MAX_NETWORK_ADDRESS] = 0;
+ }
+
+ bSuccess = StoreConfig( i_pProfile );
+
+ return bSuccess;
+}
+
+bool KMSClient_ProfileLoaded( KMSClientProfile *i_pProfile )
+{
+
+#if defined(DEBUG) && defined(METAWARE)
+ log_printf ("profile: %x", i_pProfile);
+ log_printf ("profile: enrolled %x", i_pProfile->m_iEnrolled);
+ log_printf ("profile: version %x", i_pProfile->m_iVersion);
+#endif
+
+ // more extensive tests could be performed but this should suffice
+ if ( i_pProfile &&
+ i_pProfile->m_iEnrolled &&
+ i_pProfile->m_iVersion == KMS_AGENT_VERSION )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_DeleteProfile
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_DeleteProfile(utf8char *i_wsProfileName)
+{
+ FATAL_ASSERT( i_wsProfileName && (strlen(i_wsProfileName) > 0) );
+
+ bool bSuccess = true;
+
+ if (ProfileExists(g_wsWorkingDirectory, /* pass in default */
+ i_wsProfileName))
+ {
+ bSuccess = DeleteStorageProfile(i_wsProfileName);
+ }
+
+ return bSuccess;
+}
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_UnloadProfile
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_UnloadProfile(KMSClientProfile *i_pProfile)
+{
+ if(i_pProfile != NULL && i_pProfile->m_pLock != NULL )
+ {
+#ifdef KMSUSERPKCS12
+ /* Delete the private client key file if it's still around */
+ CleanupPrivateKeyFile(i_pProfile);
+#endif
+ if (i_pProfile->m_pAgentLoadBalancer != NULL)
+ {
+ delete reinterpret_cast
+ <CAgentLoadBalancer *> (i_pProfile->m_pAgentLoadBalancer);
+ }
+ if (i_pProfile->m_pDataUnitCache != NULL)
+ {
+ delete reinterpret_cast<CDataUnitCache *> (i_pProfile->m_pDataUnitCache);
+ }
+ K_DestroyMutex((K_MUTEX_HANDLE)i_pProfile->m_pLock);
+ i_pProfile->m_pLock = 0;
+
+ if ( i_pProfile->m_pvSoap )
+ {
+ soap_destroy( (struct soap*)i_pProfile->m_pvSoap );
+ soap_end( (struct soap*)i_pProfile->m_pvSoap );
+ soap_done( (struct soap*)i_pProfile->m_pvSoap );
+
+ free( (struct soap*)i_pProfile->m_pvSoap );
+ i_pProfile->m_pvSoap = 0;
+ }
+
+ if ( i_pProfile->m_pvDiscoverySoap)
+ {
+ soap_destroy( (struct soap*)i_pProfile->m_pvDiscoverySoap );
+ soap_end( (struct soap*)i_pProfile->m_pvDiscoverySoap );
+ soap_done( (struct soap*)i_pProfile->m_pvDiscoverySoap );
+
+ free( (struct soap*)i_pProfile->m_pvDiscoverySoap );
+ i_pProfile->m_pvDiscoverySoap = 0;
+ }
+ }
+
+ i_pProfile->m_iEnrolled = FALSE;
+
+ return true; /* always return true, maybe there are cases which return false in the future */
+}
+
+bool FIPScompatibleKMA(
+ const char * const i_sKMAVersion) {
+ return (strcmp(i_sKMAVersion,
+ FIPS_COMPATIBLE_KMA_VERSION) >= 0);
+}
+
+#ifdef KMSUSERPKCS12
+extern "C"
+KMS_AGENT_STATUS
+KMSAgent_GetProfileStatus(
+ char* i_pProfileName,
+ KMSAGENT_PROFILE_FLAGS *flags)
+{
+ /*
+ * Determine how "initialized" the KMS token is by checking for
+ * the profile config file and also the entity key container (pkcs#12).
+ */
+ if (ProfileExists(g_wsWorkingDirectory, i_pProfileName)) {
+ *flags |= KMSAGENT_PROFILE_EXISTS_FLAG;
+ if (ClientKeyP12Exists(i_pProfileName))
+ *flags |= KMSAGENT_CLIENTKEY_EXISTS_FLAG;
+ }
+ return (KMS_AGENT_STATUS_OK);
+}
+#endif
diff --git a/usr/src/lib/libkmsagent/common/KMSClientProfile.h b/usr/src/lib/libkmsagent/common/KMSClientProfile.h
new file mode 100644
index 0000000000..e0a635e7eb
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSClientProfile.h
@@ -0,0 +1,456 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*-------------------------------------------------------------------------*/
+/**
+ * \file KMSClientProfile.h
+ *
+ * The KMS Client profile management API, including profile setup, CA
+ * certificate download, and Certificate retrieval
+ *
+ */
+/*-------------------------------------------------------------------------*/
+
+#ifndef KMSCLIENT_PROFILE_H
+#define KMSCLIENT_PROFILE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef KMS_LONG_LONG
+#define KMS_LONG_LONG
+
+#ifdef WIN32
+ typedef __int64 Long64;
+#else
+ typedef long long Long64;
+#endif
+
+
+#endif
+
+#ifdef KMSUSERPKCS12
+#define CLIENT_PK12_FILE "clientkey.p12"
+#endif
+
+/**
+ * \note UTF-8 encoding is used for the underlying SOAP RPC transactions by
+ * this API. In order to support environments lacking wchar.h
+ * traditional C strings are used instead.
+ */
+typedef char * utf8cstr;
+
+/**
+ * @see commments for utf8cstr.
+ */
+typedef char utf8char;
+
+/**
+ * KMS Agent Toolkit Version identifier
+ */
+#define KMS_AGENT_VERSION 0x210
+
+/*---------------------------------------------------------------------------
+ * Limits and sizes
+ *--------------------------------------------------------------------------*/
+/**
+ * The maximum length of an agent name.
+ */
+#define KMS_MAX_AGENT_NAME 64
+
+/**
+ * The size of a data unit ID in bytes.
+ */
+#define KMS_DATA_UNIT_ID_SIZE 16
+
+/**
+ * The maximum lenght of a description for key group or data unit.
+ */
+#define KMS_MAX_DESCRIPTION 64
+
+/**
+ * The maximum maximum length of an external unique id.
+ */
+#define KMS_MAX_EXTERNAL_UNIQUE_ID_SIZE 32
+
+/**
+ * The maximum external tag length.
+ */
+#define KMS_MAX_EXTERNAL_TAG 64
+
+/**
+ * The size of a key ID in bytes.
+ */
+#define KMS_KEY_ID_SIZE 30
+
+/**
+ * The size of an AES Key Wrapping Key ID.
+ */
+#define KMS_KWK_KEY_ID_SIZE 8
+
+/**
+ * The maximum size of a key in bytes.
+ */
+#define KMS_MAX_KEY_SIZE 32
+
+/**
+ * The maximum size of an wrapped key(RFC3394 AES Key Wrap) in bytes.
+ */
+#define KMS_MAX_WRAPPED_KEY_SIZE KMS_MAX_KEY_SIZE+8
+
+/**
+ * The maximum length of a key group ID.
+ */
+#define KMS_MAX_KEY_GROUP_ID_SIZE 64
+
+/**
+ * The maximum size of a key group list to be returned. This should
+ * be sufficient for agents as this is an atypical call.
+ */
+#define KMS_MAX_LIST_KEY_GROUPS 100
+
+/**
+ * The maximum number of keys returned in a key list.
+ */
+#define KMS_MAX_PAGE_SIZE 32
+
+/**
+ * The maximum passphrase length.
+ */
+#define KMS_MAX_PASSPHRASE 64
+
+/**
+ * The maximum length of agent's name, aka ID.
+ */
+#define KMS_MAX_ENTITY_ID 64
+
+/**
+ * The maximum length of an agent's sited ID.
+ */
+#define KMS_MAX_ENTITY_SITE_ID 64
+
+/**
+ * The maximum length of a URL.
+ */
+#define KMS_MAX_URL 512
+
+/**
+ * The maximum length of a filter parameter field name.
+ */
+#define KMS_MAX_FIELD_NAME 64
+
+/**
+ * The maximum length of a query parameter sort field value.
+ */
+#define KMS_MAX_FIELD_VALUE 64
+
+/**
+ * The maximum ID length used in various types of IDs.
+ */
+#define KMS_MAX_ID 64
+
+/**
+ * The maximum length of a KMA network address, either IPv4 or IPv6.
+ * Also maximum hostname length if/when hostnames are supported
+ */
+#define KMS_MAX_NETWORK_ADDRESS 256
+
+/**
+ * The maximum length of a file name.
+ */
+#define KMS_MAX_FILE_NAME 256
+
+/**
+ * The maximum length of error strings.
+ */
+#define KMS_MAX_ERROR_STRING 1024
+
+/**
+ * the number of nodes in a KMS is variable. This constant
+ * dictates how many of the KMAs in a KMS will be saved to the
+ * profile, persisted to storage and used for load balancing and failover. See
+ * <code>KMSAgent_GetClusterInformation</code>
+ * Range: 1 .. max int, users should con
+ */
+#ifndef KMS_MAX_CLUSTER_NUM
+#define KMS_MAX_CLUSTER_NUM 20
+#endif
+
+/**
+ * The maximum length for SHA1 hashes used in authentication.
+ */
+#define KMS_MAX_HASH_SIZE 20
+
+/**
+ * The maximum length of a KMS verstion string.
+ */
+#define KMS_MAX_VERSION_LENGTH 100
+
+/**
+ * The maximum length of working directory.
+ */
+#define KMS_MAX_PATH_LENGTH 1024
+
+/**
+ * typedef for Key ID
+ */
+typedef unsigned char KEY_ID [KMS_KEY_ID_SIZE];
+
+/**
+ * typedef for an unwrapped Key
+ */
+typedef unsigned char KEY [KMS_MAX_KEY_SIZE];
+
+/**
+ * typedef for an AES wrapped key
+ */
+typedef unsigned char WRAPPED_KEY [KMS_MAX_WRAPPED_KEY_SIZE];
+
+/**
+ * typedef for KMSClusterEntry struct
+ */
+typedef struct KMSClusterEntry KMSClusterEntry;
+
+/** \struct KMSClusterEntry
+ * A struct representing each Key Management Appliance discovered in the KMS cluster
+ */
+struct KMSClusterEntry
+{
+ /**
+ * The KMA's identifier.
+ */
+ Long64 m_lApplianceID;
+
+ /**
+ * The KMA's name.
+ */
+ utf8char m_wsApplianceAlias[KMS_MAX_ENTITY_ID + 1];
+
+ /**
+ * The Sited ID for the KMA.
+ */
+ utf8char m_wsApplianceSiteID[KMS_MAX_ENTITY_SITE_ID + 1];
+
+ /**
+ * A network address for the KMA that corresponds to the agent's network.
+ * KMAs are multi-homed so only an address useful to the agent is provided.
+ */
+ utf8char m_wsApplianceNetworkAddress[KMS_MAX_NETWORK_ADDRESS + 1];
+
+ /**
+ * Enabled status for the KMA, 1 for enabled, 0 if disabled.
+ */
+ int m_iEnabled;
+
+ /**
+ * Unused at present but may be used for reporting a KMAs load to be used
+ * as a load balancing heuristic.
+ */
+ Long64 m_lLoad;
+
+ /**
+ * A boolean indicating the current response status of a KMA on the network.
+ * A non-responding KMA may be either down or unreachable due to the network.
+ */
+ int m_iResponding;
+
+ /**
+ * The KMA's version level.
+ */
+ utf8char m_sKMAVersion[KMS_MAX_VERSION_LENGTH+1];
+
+ /**
+ * KMA lock status as provided by KMS Discover Cluster service. Defaults
+ * to false for KMAs earlier than KMS 2.3 where it was first introduced.
+ */
+ int m_iKMALocked;
+};
+
+
+/**
+ * the profile for an agent. The profile contains sections that are persisted
+ * and fields that are volatile. See KMSAgentStorage.h for interfaces to load/store
+ * the persistent sections.
+ * <p><b>Note</b> that members of this struct should
+ * not be accessed directly by users of this library.
+ */
+
+/** \struct KMSClientProfile
+ * the properties comprising the profile, some of which must be persisted.
+ */
+typedef struct KMSClientProfile_s
+{
+ /**
+ * the version of the KMS Agent Library
+ */
+ int m_iVersion;
+
+ /**
+ * Profile Name
+ */
+ utf8char m_wsProfileName[KMS_MAX_ENTITY_ID + 1];
+
+ /**
+ * Subject Name
+ */
+ utf8char m_wsEntityID[KMS_MAX_ENTITY_ID + 1];
+
+ /**
+ * Appliance Address used for enrollment and discovery
+ */
+ utf8char m_wsApplianceAddress[KMS_MAX_NETWORK_ADDRESS + 1];
+
+ /**
+ * KMS CA service port
+ */
+ int m_iPortForCAService;
+ /**
+ * KMS Certificate service port
+ */
+ int m_iPortForCertificateService;
+
+ /**
+ * KMS Agent service port
+ */
+ int m_iPortForAgentService;
+
+ /**
+ * KMS Discovery service port
+ */
+ int m_iPortForDiscoveryService;
+
+ /**
+ * timeout in seconds before failover to alternate KMS in cluster
+ */
+ int m_iTransactionTimeout;
+
+ /**
+ * the number of times failover will be attempted
+ */
+ int m_iFailoverLimit;
+
+ /**
+ * the number of times the current transaction has failed over
+ */
+ int m_iFailoverAttempts;
+
+ /**
+ * TRUE when agent has enrolled and stored its certificates.
+ */
+ int m_iEnrolled;
+
+ /**
+ * The agent's passphrase after "key stretching", i.e. hashing the number of
+ * times specified by the KMA during enrollment, and converted to hexadecimal.
+ */
+ char m_sHexHashedPassphrase[2*KMS_MAX_HASH_SIZE+1];
+
+ /**
+ * gSOAP runtime context.
+ */
+ void *m_pvSoap;
+
+ /**
+ * gSOAP runtime context for discovery.
+ */
+ void *m_pvDiscoverySoap;
+
+ /**
+ * A lock used internally by the agent library.
+ */
+ void *m_pLock;
+
+ /**
+ * The minimum interval between automatic cluster discovery requests in seconds.
+ * A value of zero seconds disables load balancing and periodic cluster
+ * discovery calls.
+ */
+ int m_iClusterDiscoveryFrequency;
+
+ /**
+ * The time in seconds when the cluster discovery service was last called for the
+ * current session.
+ */
+ int m_iLastClusterDiscoveryTime;
+
+ /**
+ * The Site ID assigned to the agent by the KMS administrators.
+ */
+ utf8char m_wsEntitySiteID[KMS_MAX_ENTITY_SITE_ID + 1];
+
+ /**
+ * The total number of KMA in the KMS cluster as reported by the last
+ * cluster discovery.
+ */
+ int m_iClusterNum;
+
+ /**
+ * An array of the KMAs withhin the cluster.
+ */
+ KMSClusterEntry m_aCluster[KMS_MAX_CLUSTER_NUM];
+
+ /**
+ * A boolean flag for the first cluster discovery call.
+ */
+ int m_bIsClusterDiscoveryCalled;
+
+ /**
+ * A handle to the DataUnitCache used for selection of a KMA.
+ */
+ void *m_pDataUnitCache;
+
+ /**
+ * A handle to the load balancer.
+ */
+ void *m_pAgentLoadBalancer;
+
+ /**
+ * error string
+ */
+ utf8char m_wsErrorString[KMS_MAX_ERROR_STRING + 1];
+
+ /**
+ * URL to KMA service within cluster
+ */
+ char m_sURL[KMS_MAX_URL + 1];
+
+ /**
+ * The security mode specified to <code>KMSAgent_LoadProfile</code>
+ */
+ int m_eKMSmode;
+
+#ifdef KMSUSERPKCS12
+ int m_iLastErrorCode;
+#endif
+} KMSClientProfile;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
+
diff --git a/usr/src/lib/libkmsagent/common/KMSClientProfileImpl.h b/usr/src/lib/libkmsagent/common/KMSClientProfileImpl.h
new file mode 100644
index 0000000000..f4a2d9e39d
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/KMSClientProfileImpl.h
@@ -0,0 +1,344 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/**
+ * \file KMSClientProfileImpl.h
+ */
+
+#ifndef CLIENT_PROFILE_IMPL_H
+#define CLIENT_PROFILE_IMPL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AGENT_LOG_FILE "KMSAgentLog.log"
+
+/**
+ * Build383 corresponds to 2.0.2 which does not support AES Key Wrap and
+ * enforcment of FIPS mode.
+ */
+#define FIPS_COMPATIBLE_KMA_VERSION "Build384"
+
+
+extern bool g_bUseFileLog;
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_InitializeLibrary
+ *
+ * Description: This function initializes the KMS Agent or Management API library.
+ * It should be called before any other functions are invoked.
+ * Internally, it setups SSL library and Logging module.
+ *
+ *
+ * Input
+ * -----
+ * i_wsWorkingDirectory -- Working directory of the program which uses the library
+ * i_bIsManager -- TRUE: Initialize Management Library; FALSE: initialize Agent Library.
+ * i_bUseFileLog: True if logs should go to a log file in the working directory.
+ * False otherwise.
+ *
+ * Output
+ * ------
+ * return value TRUE or FALSE
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_InitializeLibrary(
+ const utf8cstr i_wsWorkingDirectory,
+ int i_bUseFileLog );
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_FinalizeLibrary
+ *
+ * Description: This function finalizes the KMS Agent(Or Management) API library.
+ * It should be called when the library is not needed by the program.
+ * Internally it cleans up SSL library and Logging module.
+ *
+ *
+ * Input
+ * -----
+ * i_bIsManager -- TRUE: Finalize Management Library; FALSE: Finalize Agent Library.
+ *
+ * Output
+ * ------
+ * return value TRUE or FALSE
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_FinalizeLibrary();
+
+utf8cstr KMSClient_GetLastErrorMessage(KMSClientProfile *i_pProfile);
+
+bool KMSClient_LoadProfile(
+ KMSClientProfile *io_pProfile,
+ utf8cstr i_wsProfileName,
+ utf8cstr i_wsEntityID,
+ utf8cstr i_wsPassphrase,
+ utf8cstr i_wsApplianceAddress,
+ int i_iTransactionTimeout,
+ int i_iFailOverLimit,
+ int i_iClusterDiscoveryFrequency,
+ int i_eKMSmode);
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_GetClusterInformation
+ *
+ * Description: Get the cluster information by calling cluster discovery
+ * service.
+ *
+ * Input
+ * -----
+ * i_pProfile -- a pointer to an initialized KMSClientProfile structure
+ * i_iEntitySiteIDSize -- the buffer size of the entity site ID
+ * (KMS_MAX_ENTITIY_SITE_ID)
+ * i_iClusterEntryArraySize -- the array size for cluster entries
+ * (KMS_MAX_CLUSTER_NUM)
+ * Output
+ * ------
+ * o_wsEntitySiteID -- the entity's Site ID
+ * o_pApplianceNum -- the returned number of the appliances in the cluster
+ * o_pClusterEntryArray -- the array of cluster entries
+ *
+ * return value TRUE/FALSE
+ * Use KMSAgent_GetLastErrorMessage() to get the error message
+ *
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_GetClusterInformation(KMSClientProfile *i_pProfile,
+ utf8cstr o_wsEntitySiteID,
+ int i_iEntitySiteIDSize,
+ int *o_pApplianceNum,
+ KMSClusterEntry *o_pClusterEntryArray,
+ int i_iClusterEntryArraySize);
+
+/**
+ * @return true if any KMAs are not FIPS compatible, i.e. perform AES key
+ * wrap.
+ */
+bool KMSClient_NoFIPSCompatibleKMAs(const KMSClientProfile * const i_pProfile);
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_SelectAppliance
+ *
+ * Description: Select the current appliance. The current appliance is used for
+ * retrieving cluster information.
+ *
+ * Input
+ * -----
+ * i_pProfile -- a pointer to an initialized KMSClientProfile structure
+ * i_wsApplianceAddress -- the IP address of the appliance
+ * Output
+ * ------
+ * (none)
+ * return value TRUE/FALSE
+ * Use KMSAgent_GetLastErrorMessage() to get the error message
+ *
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_SelectAppliance(KMSClientProfile *i_pProfile,
+ utf8cstr i_wsApplianceAddress);
+
+/**
+ * check if the profile was loaded successfully
+ *
+ * @param i_pProfile a pointer that may, or may not be to a loaded profile
+ *
+ * @return true if the profile was loaded
+ */
+bool KMSClient_ProfileLoaded( KMSClientProfile *i_pProfile );
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_DeleteProfile
+ *
+ * Description: Delete the profile information from the local disk
+ *
+ *
+ * Input
+ * -----
+ * i_wsProfileName -- the profile name
+
+ * Output
+ * ------
+ * return value TRUE/FALSE
+ * Use KMSAgent_GetLastErrorMessage() to get the error message
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_DeleteProfile(utf8cstr i_wsProfileName);
+
+/*---------------------------------------------------------------------------
+ * Function: KMSClient_UnloadProfile
+ *
+ * Description: Destroy the profile information in memory including agent's private
+ * key.
+ *
+ *
+ * Input
+ * -----
+ * i_pProfile -- a pointer to an initialized KMSClientProfile structure
+
+ * Output
+ * ------
+ * return value TRUE/FALSE
+ * Use KMSAgent_GetLastErrorMessage() to get the error message
+ *
+ *--------------------------------------------------------------------------*/
+bool KMSClient_UnloadProfile(KMSClientProfile *i_pProfile);
+
+/**
+ * @return true if the soap fault string indicates that the SSL handshake
+ * did not succeed due to an invalid certificate.
+ */
+bool SSL_InvalidCertificate(const char * const i_sErrorString );
+
+/**
+ * compares the error string with various soap fault substrings to determine if the
+ * error was a server-side error or not, also checks the supplied errno codes against
+ * various POSIX errno macros that would imply server connection issues
+ */
+bool ServerError (const char * i_sErrorString, int i_iErrno );
+
+#ifdef __cplusplus
+}
+
+// helper macro to turn value into a string
+#define LogError(a,b,c,d,e) LogError_function(a,b,#b,c,d,e)
+
+/**
+ * Log an error after saving the message in the profile. This supports <code>KMSAgent_GetLastErrorMessage</code>
+ * @param i_pProfile an initialized profile
+ *
+ * @param i_iErrno, the error expressed as a number
+ * @param i_sOperation, the operation number as a string
+ * @param i_sEntityID optional, the agent ID
+ * @param i_sNetworkAddress optional, the address of the KMA involved in the error
+ * @param i_sMessage optional, an informative error message
+ */
+void LogError_function(KMSClientProfile *i_pProfile,
+ int i_iErrno,
+ const char* i_sOperation,
+ const char* i_sEntityID,
+ const char* i_sNetworkAddress,
+ const char* i_sMessage );
+
+#endif
+
+/**
+ * @return true if the KMA version string corresponds to a FIPS compatible
+ * KMA
+ */
+bool FIPScompatibleKMA (
+ const char * const i_sKMAVersion);
+
+#define AUDIT_CLIENT_LOG_ERROR_BASE 0x300
+
+#define AUDIT_CLIENT_AGENT_CREATE_AUDIT_LOG_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x00)
+#define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_RESPONSE_INVALID_DESCRIPTION_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x01)
+#define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_RESPONSE_INVALID_DU_ID_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x02)
+#define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_RESPONSE_INVALID_EXTERNAL_TAG_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x03)
+#define AUDIT_CLIENT_AGENT_CREATE_DATA_UNIT_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x04)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEYID_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x05)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_GROUP_ID_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x06)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x07)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_STATE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x08)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_KEY_TYPE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x09)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_KEY_CALLOUT_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x0a)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x0b)
+#define AUDIT_CLIENT_AGENT_DISASSOCIATE_DATA_UNIT_KEYS_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x0c)
+#define AUDIT_CLIENT_AGENT_LIST_KEY_GROUPS_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x0d)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_RESPONSE_INVALID_DESCRIPTION_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x0e)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_RESPONSE_INVALID_EXTERNAL_TAG_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x0f)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_BY_EXTERNAL_UNIQUE_ID_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x10)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEYS_REMAINING_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x11)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEYS_SIZE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x12)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_ARRAY_SIZE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x13)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x14)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x15)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_STATE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x16)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_KEY_TYPE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x17)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_KEY_CALLOUT_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x18)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x19)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_RESPONSE_INVALID_DESCRIPTION_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x1a)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_RESPONSE_INVALID_EXTERNAL_TAG_LENGTH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x1b)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x1c)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEYID_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x1d)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_GROUP_ID_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x1e)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x1f)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_STATE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x20)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_KEY_TYPE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x21)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_KEY_CALLOUT_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x22)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x23)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEYID_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x24)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_GROUP_ID_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x25)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x26)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_STATE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x27)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_KEY_TYPE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x28)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_KEY_CALLOUT_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x29)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x2a)
+#define AUDIT_CLIENT_COMPUTE_CHALLENGE_RESPONSE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x2b)
+#define AUDIT_CLIENT_COMPUTE_FIXED_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x2c)
+#define AUDIT_CLIENT_GET_CERTIFICATE_INVALID_CERTIFICATE_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x2d)
+#define AUDIT_CLIENT_GET_CERTIFICATE_INVALID_CHALLENGE_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x2e)
+#define AUDIT_CLIENT_GET_CERTIFICATE_INVALID_KEY_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x2f)
+#define AUDIT_CLIENT_GET_CERTIFICATE_INVALID_RESPONSE_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x30)
+#define AUDIT_CLIENT_GET_CERTIFICATE_SAVE_CA_CERTIFICATE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x31)
+#define AUDIT_CLIENT_GET_CERTIFICATE_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x32)
+#define AUDIT_CLIENT_GET_CLUSTER_INFORMATION (AUDIT_CLIENT_LOG_ERROR_BASE + 0x33)
+#define AUDIT_CLIENT_GET_CLUSTER_INFORMATION_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x34)
+#define AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_INVALID_CA_CERTIFICATE_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x35)
+#define AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_INVALID_RESPONSE_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x36)
+#define AUDIT_CLIENT_LOAD_CLUSTER_INFORMATION_INVALID_CLUSTER_FILE_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x37)
+#define AUDIT_CLIENT_LOAD_CLUSTER_INFORMATION_OPEN_CLUSTER_FILE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x38)
+#define AUDIT_CLIENT_LOAD_PROFILE_EXPORT_CERTIFICATE_AND_KEY_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x39)
+#define AUDIT_CLIENT_LOAD_PROFILE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x3a)
+#define AUDIT_CLIENT_LOAD_PROFILE_SAVE_CA_CERTIFICATE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x3b)
+#define AUDIT_CLIENT_LOAD_PROFILE_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x3c)
+#define AUDIT_CLIENT_SAVE_CLUSTER_INFORMATION_OPEN_CLUSTER_FILE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x3d)
+#define AUDIT_CLIENT_SAVE_ROOTCA_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x3e)
+#define AUDIT_CLIENT_SELECT_APPLIANCE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x3f)
+#define AUDIT_PROFILE_READ_CONFIG_FILE_INVALID_CONFIGURATION_FILE_FORMAT (AUDIT_CLIENT_LOG_ERROR_BASE + 0x40)
+#define AUDIT_PROFILE_READ_CONFIG_FILE_OPEN_CONFIGURATION_FILE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x41)
+#define AUDIT_PROFILE_WRITE_CONFIG_FILE_OPEN_CONFIGURATION_FILE_FAILED (AUDIT_CLIENT_LOG_ERROR_BASE + 0x42)
+#define LoadProfile_AUDIT_CLIENT_GET_ROOT_CA_CERTIFICATE_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x43)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_AESKEYUNWRAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x44)
+#define AUDIT_CLIENT_AGENT_REGISTER_KWK_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x45)
+#define AUDIT_CLIENT_AGENT_REGISTER_KWK_INVALID_KEYID_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x46)
+#define AUDIT_CLIENT_AGENT_CREATE_KWK_RNG_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x47)
+#define AUDIT_CLIENT_GET_KWK_WRAPPING_KEY_SOAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x48)
+#define AUDIT_CLIENT_GET_KWK_WRAPPING_KEY_INVALID_KEY_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x49)
+#define AUDIT_CLIENT_GET_KWK_WRAPPING_KEY_INVALID_RSA_PUB_KEY (AUDIT_CLIENT_LOG_ERROR_BASE + 0x50)
+#define AUDIT_CLIENT_AGENT_CREATE_KWK_PUBLIC_ENCRYPT_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x51)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_AESKEYUNWRAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x52)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_AESKEYUNWRAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x53)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_AESKEYUNWRAP_ERROR (AUDIT_CLIENT_LOG_ERROR_BASE + 0x54)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_INVALID_WRAPPED_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x55)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_INVALID_WRAPPED_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x56)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_INVALID_WRAPPED_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x57)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_INVALID_WRAPPED_KEY_LENGTH_RESPONSE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x58)
+#define AUDIT_CLIENT_AGENT_CREATE_KEY_KWKID_MISMATCH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x59)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_KEY_KWKID_MISMATCH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x60)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_DATA_UNIT_KEYS_KWKID_MISMATCH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x61)
+#define AUDIT_CLIENT_AGENT_RETRIEVE_PROTECT_AND_PROCESS_KEY_KWKID_MISMATCH (AUDIT_CLIENT_LOG_ERROR_BASE + 0x62)
+#define AUDIT_CLIENT_AGENT_LOAD_PROFILE_NO_FIPS_COMPATIBLE_KMAS_AVAILABLE (AUDIT_CLIENT_LOG_ERROR_BASE + 0x63)
+
+#endif
diff --git a/usr/src/lib/libkmsagent/common/SOAP/AgentServiceNamespace.cpp b/usr/src/lib/libkmsagent/common/SOAP/AgentServiceNamespace.cpp
new file mode 100644
index 0000000000..825e0b022c
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/AgentServiceNamespace.cpp
@@ -0,0 +1,22 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#include "KMS_Agent.nsmap"
diff --git a/usr/src/lib/libkmsagent/common/SOAP/CAServiceNamespace.cpp b/usr/src/lib/libkmsagent/common/SOAP/CAServiceNamespace.cpp
new file mode 100644
index 0000000000..e33f96bd4c
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/CAServiceNamespace.cpp
@@ -0,0 +1,21 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+#include "KMS_CA.nsmap"
diff --git a/usr/src/lib/libkmsagent/common/SOAP/CertificateServiceNamespace.cpp b/usr/src/lib/libkmsagent/common/SOAP/CertificateServiceNamespace.cpp
new file mode 100644
index 0000000000..8b6ebc71a2
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/CertificateServiceNamespace.cpp
@@ -0,0 +1,22 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#include "KMS_Certificate.nsmap"
diff --git a/usr/src/lib/libkmsagent/common/SOAP/DiscoveryServiceNamespace.cpp b/usr/src/lib/libkmsagent/common/SOAP/DiscoveryServiceNamespace.cpp
new file mode 100644
index 0000000000..9acf17e9cb
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/DiscoveryServiceNamespace.cpp
@@ -0,0 +1,22 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+#include "KMS_Discovery.nsmap"
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.h b/usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.h
new file mode 100644
index 0000000000..90ec43a0a9
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMSAgentWebServiceNamespaces.h
@@ -0,0 +1,34 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*-----------------------------------------------------------------------------
+ * File: WebServiceNamespaces.h
+ *
+ -----------------------------------------------------------------------------*/
+
+#ifndef ClientWebServiceNamespaces_H
+#define ClientWebServiceNamespaces_H
+
+extern SOAP_NMAC struct Namespace KMS_CA_namespaces[];
+extern SOAP_NMAC struct Namespace KMS_Certificate_namespaces[];
+extern SOAP_NMAC struct Namespace KMS_Agent_namespaces[];
+extern SOAP_NMAC struct Namespace KMS_Discovery_namespaces[];
+
+#endif //ClientWebServiceNamespaces_H
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_Agent.nsmap b/usr/src/lib/libkmsagent/common/SOAP/KMS_Agent.nsmap
new file mode 100644
index 0000000000..215ae019a8
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_Agent.nsmap
@@ -0,0 +1,36 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include "KMS_AgentH.h"
+SOAP_NMAC struct Namespace KMS_Agent_namespaces[] =
+{
+ {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope"},
+ {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding"},
+ {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},
+ {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},
+ {"KMS-Agent", "http://www.sun.com/KMS/KMS-Agent"},
+ {NULL, NULL}
+};
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentC.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentC.cpp
new file mode 100644
index 0000000000..d8abc614b8
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentC.cpp
@@ -0,0 +1,8820 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_AgentC.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/AgentService/KMS_Agent_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+
+#include "KMS_AgentH.h"
+
+namespace KMS_Agent {
+
+SOAP_SOURCE_STAMP("@(#) KMS_AgentC.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap)
+{
+ if (soap->header)
+ soap_serialize_SOAP_ENV__Header(soap, soap->header);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap)
+{
+ if (soap->header)
+ { soap->part = SOAP_IN_HEADER;
+ if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, NULL))
+ return soap->error;
+ soap->part = SOAP_END_HEADER;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap)
+{
+ soap->part = SOAP_IN_HEADER;
+ soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", NULL, NULL);
+ soap->part = SOAP_END_HEADER;
+ return soap->header == NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap)
+{
+ if (!soap->header)
+ { if ((soap->header = soap_new_SOAP_ENV__Header(soap, -1)))
+ soap_default_SOAP_ENV__Header(soap, soap->header);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap)
+{
+ if (!soap->fault)
+ { soap->fault = soap_new_SOAP_ENV__Fault(soap, -1);
+ if (!soap->fault)
+ return;
+ soap_default_SOAP_ENV__Fault(soap, soap->fault);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Code)
+ { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason)
+ { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap, -1);
+ soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->fault)
+ soap_serialize_SOAP_ENV__Fault(soap, soap->fault);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap)
+{
+ if (soap->fault)
+ return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", NULL);
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap)
+{
+ return (soap->fault = soap_get_SOAP_ENV__Fault(soap, NULL, "SOAP-ENV:Fault", NULL)) == NULL;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value;
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ { if (!soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
+ { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value;
+ }
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text;
+ return (const char**)&soap->fault->faultstring;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 1)
+ { if (!soap->fault->detail)
+ { soap->fault->detail = (struct SOAP_ENV__Detail*)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail));
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->detail);
+ }
+ return (const char**)&soap->fault->detail->__any;
+ }
+ if (!soap->fault->SOAP_ENV__Detail)
+ { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1);
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->SOAP_ENV__Detail);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Detail->__any;
+}
+
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap)
+{
+ int t;
+ if (soap->version == 1)
+ { for (;;)
+ { if (!soap_getelement(soap, &t))
+ if (soap->error || soap_ignore_element(soap))
+ break;
+ }
+ }
+ if (soap->error == SOAP_NO_TAG || soap->error == SOAP_EOF)
+ soap->error = SOAP_OK;
+ return soap->error;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type)
+{
+ if (soap_peek_element(soap))
+ return NULL;
+ if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id)))
+ *type = soap_lookup_type(soap, soap->href);
+ switch (*type)
+ {
+ case SOAP_TYPE_KMS_Agent_byte:
+ return soap_in_byte(soap, NULL, NULL, "xsd:byte");
+ case SOAP_TYPE_KMS_Agent_int:
+ return soap_in_int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_Agent_xsd__int:
+ return soap_in_xsd__int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_Agent_long:
+ return soap_in_long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Agent_xsd__long:
+ return soap_in_xsd__long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Agent_LONG64:
+ return soap_in_LONG64(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Agent_xsd__float:
+ return soap_in_xsd__float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_Agent_float:
+ return soap_in_float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_Agent_unsignedByte:
+ return soap_in_unsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Agent_unsignedInt:
+ return soap_in_unsignedInt(soap, NULL, NULL, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition:
+ return soap_in_KMS_Agent__AuditLogCondition(soap, NULL, NULL, "KMS-Agent:AuditLogCondition");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention:
+ return soap_in_KMS_Agent__AuditLogRetention(soap, NULL, NULL, "KMS-Agent:AuditLogRetention");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState:
+ return soap_in_KMS_Agent__DataUnitState(soap, NULL, NULL, "KMS-Agent:DataUnitState");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState:
+ return soap_in_KMS_Agent__KeyState(soap, NULL, NULL, "KMS-Agent:KeyState");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType:
+ return soap_in_KMS_Agent__KeyType(soap, NULL, NULL, "KMS-Agent:KeyType");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator:
+ return soap_in_KMS_Agent__FilterOperator(soap, NULL, NULL, "KMS-Agent:FilterOperator");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder:
+ return soap_in_KMS_Agent__SortOrder(soap, NULL, NULL, "KMS-Agent:SortOrder");
+ case SOAP_TYPE_KMS_Agent_xsd__boolean:
+ return soap_in_xsd__boolean(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_Agent_bool:
+ return soap_in_bool(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK:
+ return soap_in_KMS_Agent__RegisterAgentKWK(soap, NULL, NULL, "KMS-Agent:RegisterAgentKWK");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse:
+ return soap_in_KMS_Agent__RegisterAgentKWKResponse(soap, NULL, NULL, "KMS-Agent:RegisterAgentKWKResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey:
+ return soap_in_KMS_Agent__GetAgentKWKPublicKey(soap, NULL, NULL, "KMS-Agent:GetAgentKWKPublicKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse:
+ return soap_in_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, NULL, NULL, "KMS-Agent:GetAgentKWKPublicKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog:
+ return soap_in_KMS_Agent__CreateAuditLog(soap, NULL, NULL, "KMS-Agent:CreateAuditLog");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse:
+ return soap_in_KMS_Agent__CreateAuditLogResponse(soap, NULL, NULL, "KMS-Agent:CreateAuditLogResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2:
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKey2(soap, NULL, NULL, "KMS-Agent:RetrieveProtectAndProcessKey2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response:
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, NULL, NULL, "KMS-Agent:RetrieveProtectAndProcessKey2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey:
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKey(soap, NULL, NULL, "KMS-Agent:RetrieveProtectAndProcessKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse:
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, NULL, NULL, "KMS-Agent:RetrieveProtectAndProcessKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2:
+ return soap_in_KMS_Agent__RetrieveDataUnitKeys2(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitKeys2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response:
+ return soap_in_KMS_Agent__RetrieveDataUnitKeys2Response(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitKeys2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys:
+ return soap_in_KMS_Agent__RetrieveDataUnitKeys(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitKeys");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse:
+ return soap_in_KMS_Agent__RetrieveDataUnitKeysResponse(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitKeysResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2:
+ return soap_in_KMS_Agent__RetrieveKey2(soap, NULL, NULL, "KMS-Agent:RetrieveKey2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response:
+ return soap_in_KMS_Agent__RetrieveKey2Response(soap, NULL, NULL, "KMS-Agent:RetrieveKey2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey:
+ return soap_in_KMS_Agent__RetrieveKey(soap, NULL, NULL, "KMS-Agent:RetrieveKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse:
+ return soap_in_KMS_Agent__RetrieveKeyResponse(soap, NULL, NULL, "KMS-Agent:RetrieveKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2:
+ return soap_in_KMS_Agent__CreateKey2(soap, NULL, NULL, "KMS-Agent:CreateKey2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response:
+ return soap_in_KMS_Agent__CreateKey2Response(soap, NULL, NULL, "KMS-Agent:CreateKey2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey:
+ return soap_in_KMS_Agent__CreateKey(soap, NULL, NULL, "KMS-Agent:CreateKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse:
+ return soap_in_KMS_Agent__CreateKeyResponse(soap, NULL, NULL, "KMS-Agent:CreateKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys:
+ return soap_in_KMS_Agent__DisassociateDataUnitKeys(soap, NULL, NULL, "KMS-Agent:DisassociateDataUnitKeys");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse:
+ return soap_in_KMS_Agent__DisassociateDataUnitKeysResponse(soap, NULL, NULL, "KMS-Agent:DisassociateDataUnitKeysResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID:
+ return soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitByExternalUniqueID");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse:
+ return soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitByExternalUniqueIDResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit:
+ return soap_in_KMS_Agent__RetrieveDataUnit(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnit");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse:
+ return soap_in_KMS_Agent__RetrieveDataUnitResponse(soap, NULL, NULL, "KMS-Agent:RetrieveDataUnitResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit:
+ return soap_in_KMS_Agent__CreateDataUnit(soap, NULL, NULL, "KMS-Agent:CreateDataUnit");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse:
+ return soap_in_KMS_Agent__CreateDataUnitResponse(soap, NULL, NULL, "KMS-Agent:CreateDataUnitResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups:
+ return soap_in_KMS_Agent__ListKeyGroups(soap, NULL, NULL, "KMS-Agent:ListKeyGroups");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse:
+ return soap_in_KMS_Agent__ListKeyGroupsResponse(soap, NULL, NULL, "KMS-Agent:ListKeyGroupsResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit:
+ return soap_in_KMS_Agent__DataUnit(soap, NULL, NULL, "KMS-Agent:DataUnit");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys:
+ return soap_in_KMS_Agent__ArrayOfKeys(soap, NULL, NULL, "KMS-Agent:ArrayOfKeys");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__Key:
+ return soap_in_KMS_Agent__Key(soap, NULL, NULL, "KMS-Agent:Key");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups:
+ return soap_in_KMS_Agent__ArrayOfKeyGroups(soap, NULL, NULL, "KMS-Agent:ArrayOfKeyGroups");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup:
+ return soap_in_KMS_Agent__KeyGroup(soap, NULL, NULL, "KMS-Agent:KeyGroup");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters:
+ return soap_in_KMS_Agent__QueryParameters(soap, NULL, NULL, "KMS-Agent:QueryParameters");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters:
+ return soap_in_KMS_Agent__ArrayOfFilterParameters(soap, NULL, NULL, "KMS-Agent:ArrayOfFilterParameters");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters:
+ return soap_in_KMS_Agent__FilterParameters(soap, NULL, NULL, "KMS-Agent:FilterParameters");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary:
+ return soap_in_KMS_Agent__ArrayOfHexBinary(soap, NULL, NULL, "KMS-Agent:ArrayOfHexBinary");
+ case SOAP_TYPE_KMS_Agent_xsd__hexBinary:
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__Key:
+ return soap_in_PointerToKMS_Agent__Key(soap, NULL, NULL, "KMS-Agent:Key");
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__KeyGroup:
+ return soap_in_PointerToKMS_Agent__KeyGroup(soap, NULL, NULL, "KMS-Agent:KeyGroup");
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__FilterParameters:
+ return soap_in_PointerToKMS_Agent__FilterParameters(soap, NULL, NULL, "KMS-Agent:FilterParameters");
+ case SOAP_TYPE_KMS_Agent_PointerToxsd__hexBinary:
+ return soap_in_PointerToxsd__hexBinary(soap, NULL, NULL, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Agent_PointerTounsignedByte:
+ return soap_in_PointerTounsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Agent_xsd__duration:
+ { char **s;
+ s = soap_in_xsd__duration(soap, NULL, NULL, "xsd:duration");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Agent_xsd__dateTime:
+ { char **s;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, "xsd:dateTime");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Agent_xsd__string:
+ { char **s;
+ s = soap_in_xsd__string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Agent__QName:
+ { char **s;
+ s = soap_in__QName(soap, NULL, NULL, "xsd:QName");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Agent_string:
+ { char **s;
+ s = soap_in_string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ default:
+ { const char *t = soap->type;
+ if (!*t)
+ t = soap->tag;
+ if (!soap_match_tag(soap, t, "xsd:byte"))
+ { *type = SOAP_TYPE_KMS_Agent_byte;
+ return soap_in_byte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_Agent_int;
+ return soap_in_int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_Agent_xsd__int;
+ return soap_in_xsd__int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Agent_long;
+ return soap_in_long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Agent_xsd__long;
+ return soap_in_xsd__long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Agent_LONG64;
+ return soap_in_LONG64(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_Agent_xsd__float;
+ return soap_in_xsd__float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_Agent_float;
+ return soap_in_float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedByte"))
+ { *type = SOAP_TYPE_KMS_Agent_unsignedByte;
+ return soap_in_unsignedByte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedInt"))
+ { *type = SOAP_TYPE_KMS_Agent_unsignedInt;
+ return soap_in_unsignedInt(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:AuditLogCondition"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition;
+ return soap_in_KMS_Agent__AuditLogCondition(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:AuditLogRetention"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention;
+ return soap_in_KMS_Agent__AuditLogRetention(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:DataUnitState"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState;
+ return soap_in_KMS_Agent__DataUnitState(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:KeyState"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState;
+ return soap_in_KMS_Agent__KeyState(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:KeyType"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType;
+ return soap_in_KMS_Agent__KeyType(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:FilterOperator"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator;
+ return soap_in_KMS_Agent__FilterOperator(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:SortOrder"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder;
+ return soap_in_KMS_Agent__SortOrder(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_Agent_xsd__boolean;
+ return soap_in_xsd__boolean(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_Agent_bool;
+ return soap_in_bool(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RegisterAgentKWK"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK;
+ return soap_in_KMS_Agent__RegisterAgentKWK(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RegisterAgentKWKResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse;
+ return soap_in_KMS_Agent__RegisterAgentKWKResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:GetAgentKWKPublicKey"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey;
+ return soap_in_KMS_Agent__GetAgentKWKPublicKey(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:GetAgentKWKPublicKeyResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse;
+ return soap_in_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateAuditLog"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog;
+ return soap_in_KMS_Agent__CreateAuditLog(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateAuditLogResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse;
+ return soap_in_KMS_Agent__CreateAuditLogResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveProtectAndProcessKey2"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2;
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKey2(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveProtectAndProcessKey2Response"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response;
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveProtectAndProcessKey"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey;
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKey(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveProtectAndProcessKeyResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse;
+ return soap_in_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitKeys2"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2;
+ return soap_in_KMS_Agent__RetrieveDataUnitKeys2(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitKeys2Response"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response;
+ return soap_in_KMS_Agent__RetrieveDataUnitKeys2Response(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitKeys"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys;
+ return soap_in_KMS_Agent__RetrieveDataUnitKeys(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitKeysResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse;
+ return soap_in_KMS_Agent__RetrieveDataUnitKeysResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveKey2"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2;
+ return soap_in_KMS_Agent__RetrieveKey2(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveKey2Response"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response;
+ return soap_in_KMS_Agent__RetrieveKey2Response(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveKey"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey;
+ return soap_in_KMS_Agent__RetrieveKey(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveKeyResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse;
+ return soap_in_KMS_Agent__RetrieveKeyResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateKey2"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2;
+ return soap_in_KMS_Agent__CreateKey2(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateKey2Response"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response;
+ return soap_in_KMS_Agent__CreateKey2Response(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateKey"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey;
+ return soap_in_KMS_Agent__CreateKey(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateKeyResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse;
+ return soap_in_KMS_Agent__CreateKeyResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:DisassociateDataUnitKeys"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys;
+ return soap_in_KMS_Agent__DisassociateDataUnitKeys(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:DisassociateDataUnitKeysResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse;
+ return soap_in_KMS_Agent__DisassociateDataUnitKeysResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitByExternalUniqueID"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID;
+ return soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitByExternalUniqueIDResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse;
+ return soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnit"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit;
+ return soap_in_KMS_Agent__RetrieveDataUnit(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:RetrieveDataUnitResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse;
+ return soap_in_KMS_Agent__RetrieveDataUnitResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateDataUnit"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit;
+ return soap_in_KMS_Agent__CreateDataUnit(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:CreateDataUnitResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse;
+ return soap_in_KMS_Agent__CreateDataUnitResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:ListKeyGroups"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups;
+ return soap_in_KMS_Agent__ListKeyGroups(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:ListKeyGroupsResponse"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse;
+ return soap_in_KMS_Agent__ListKeyGroupsResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:DataUnit"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit;
+ return soap_in_KMS_Agent__DataUnit(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:ArrayOfKeys"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys;
+ return soap_in_KMS_Agent__ArrayOfKeys(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:Key"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__Key;
+ return soap_in_KMS_Agent__Key(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:ArrayOfKeyGroups"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups;
+ return soap_in_KMS_Agent__ArrayOfKeyGroups(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:KeyGroup"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup;
+ return soap_in_KMS_Agent__KeyGroup(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:QueryParameters"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters;
+ return soap_in_KMS_Agent__QueryParameters(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:ArrayOfFilterParameters"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters;
+ return soap_in_KMS_Agent__ArrayOfFilterParameters(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:FilterParameters"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters;
+ return soap_in_KMS_Agent__FilterParameters(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Agent:ArrayOfHexBinary"))
+ { *type = SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary;
+ return soap_in_KMS_Agent__ArrayOfHexBinary(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:hexBinary"))
+ { *type = SOAP_TYPE_KMS_Agent_xsd__hexBinary;
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:duration"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Agent_xsd__duration;
+ s = soap_in_xsd__duration(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:dateTime"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Agent_xsd__dateTime;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Agent_xsd__string;
+ s = soap_in_xsd__string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:QName"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Agent__QName;
+ s = soap_in__QName(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Agent_string;
+ s = soap_in_string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ t = soap->tag;
+ }
+ }
+ soap->error = SOAP_TAG_MISMATCH;
+ return NULL;
+}
+#endif
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap)
+{
+ if (!soap_peek_element(soap))
+ { int t;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body));
+ if (soap->mustUnderstand && !soap->other)
+ return soap->error = SOAP_MUSTUNDERSTAND;
+ if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag));
+ return soap->error = SOAP_TAG_MISMATCH;
+ }
+ if (!*soap->id || !soap_getelement(soap, &t))
+ { soap->peeked = 0;
+ if (soap->fignore)
+ soap->error = soap->fignore(soap, soap->tag);
+ else
+ soap->error = SOAP_OK;
+ DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag));
+ if (!soap->error && soap->body)
+ { soap->level++;
+ while (!soap_ignore_element(soap))
+ ;
+ if (soap->error == SOAP_NO_TAG)
+ soap->error = soap_element_end_in(soap, NULL);
+ }
+ }
+ }
+ return soap->error;
+}
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap)
+{
+ int i;
+ struct soap_plist *pp;
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)))
+ for (i = 0; i < SOAP_PTRHASH; i++)
+ for (pp = soap->pht[i]; pp; pp = pp->next)
+ if (pp->mark1 == 2 || pp->mark2 == 2)
+ if (soap_putelement(soap, pp->ptr, "id", pp->id, pp->type))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, const char *tag, int id, int type)
+{
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_Agent_byte:
+ return soap_out_byte(soap, tag, id, (const char *)ptr, "xsd:byte");
+ case SOAP_TYPE_KMS_Agent_int:
+ return soap_out_int(soap, tag, id, (const int *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_Agent_xsd__int:
+ return soap_out_xsd__int(soap, tag, id, (const long *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_Agent_long:
+ return soap_out_long(soap, tag, id, (const long *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Agent_xsd__long:
+ return soap_out_xsd__long(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Agent_LONG64:
+ return soap_out_LONG64(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Agent_xsd__float:
+ return soap_out_xsd__float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_Agent_float:
+ return soap_out_float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_Agent_unsignedByte:
+ return soap_out_unsignedByte(soap, tag, id, (const unsigned char *)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Agent_unsignedInt:
+ return soap_out_unsignedInt(soap, tag, id, (const unsigned int *)ptr, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition:
+ return soap_out_KMS_Agent__AuditLogCondition(soap, tag, id, (const enum KMS_Agent__AuditLogCondition *)ptr, "KMS-Agent:AuditLogCondition");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention:
+ return soap_out_KMS_Agent__AuditLogRetention(soap, tag, id, (const enum KMS_Agent__AuditLogRetention *)ptr, "KMS-Agent:AuditLogRetention");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState:
+ return soap_out_KMS_Agent__DataUnitState(soap, tag, id, (const enum KMS_Agent__DataUnitState *)ptr, "KMS-Agent:DataUnitState");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState:
+ return soap_out_KMS_Agent__KeyState(soap, tag, id, (const enum KMS_Agent__KeyState *)ptr, "KMS-Agent:KeyState");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType:
+ return soap_out_KMS_Agent__KeyType(soap, tag, id, (const enum KMS_Agent__KeyType *)ptr, "KMS-Agent:KeyType");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator:
+ return soap_out_KMS_Agent__FilterOperator(soap, tag, id, (const enum KMS_Agent__FilterOperator *)ptr, "KMS-Agent:FilterOperator");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder:
+ return soap_out_KMS_Agent__SortOrder(soap, tag, id, (const enum KMS_Agent__SortOrder *)ptr, "KMS-Agent:SortOrder");
+ case SOAP_TYPE_KMS_Agent_xsd__boolean:
+ return soap_out_xsd__boolean(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_Agent_bool:
+ return soap_out_bool(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK:
+ return soap_out_KMS_Agent__RegisterAgentKWK(soap, tag, id, (const struct KMS_Agent__RegisterAgentKWK *)ptr, "KMS-Agent:RegisterAgentKWK");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse:
+ return soap_out_KMS_Agent__RegisterAgentKWKResponse(soap, tag, id, (const struct KMS_Agent__RegisterAgentKWKResponse *)ptr, "KMS-Agent:RegisterAgentKWKResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey:
+ return soap_out_KMS_Agent__GetAgentKWKPublicKey(soap, tag, id, (const struct KMS_Agent__GetAgentKWKPublicKey *)ptr, "KMS-Agent:GetAgentKWKPublicKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse:
+ return soap_out_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, tag, id, (const struct KMS_Agent__GetAgentKWKPublicKeyResponse *)ptr, "KMS-Agent:GetAgentKWKPublicKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog:
+ return soap_out_KMS_Agent__CreateAuditLog(soap, tag, id, (const struct KMS_Agent__CreateAuditLog *)ptr, "KMS-Agent:CreateAuditLog");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse:
+ return soap_out_KMS_Agent__CreateAuditLogResponse(soap, tag, id, (const struct KMS_Agent__CreateAuditLogResponse *)ptr, "KMS-Agent:CreateAuditLogResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2:
+ return soap_out_KMS_Agent__RetrieveProtectAndProcessKey2(soap, tag, id, (const struct KMS_Agent__RetrieveProtectAndProcessKey2 *)ptr, "KMS-Agent:RetrieveProtectAndProcessKey2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response:
+ return soap_out_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, tag, id, (const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *)ptr, "KMS-Agent:RetrieveProtectAndProcessKey2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey:
+ return soap_out_KMS_Agent__RetrieveProtectAndProcessKey(soap, tag, id, (const struct KMS_Agent__RetrieveProtectAndProcessKey *)ptr, "KMS-Agent:RetrieveProtectAndProcessKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse:
+ return soap_out_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, tag, id, (const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *)ptr, "KMS-Agent:RetrieveProtectAndProcessKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2:
+ return soap_out_KMS_Agent__RetrieveDataUnitKeys2(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitKeys2 *)ptr, "KMS-Agent:RetrieveDataUnitKeys2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response:
+ return soap_out_KMS_Agent__RetrieveDataUnitKeys2Response(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitKeys2Response *)ptr, "KMS-Agent:RetrieveDataUnitKeys2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys:
+ return soap_out_KMS_Agent__RetrieveDataUnitKeys(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitKeys *)ptr, "KMS-Agent:RetrieveDataUnitKeys");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse:
+ return soap_out_KMS_Agent__RetrieveDataUnitKeysResponse(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitKeysResponse *)ptr, "KMS-Agent:RetrieveDataUnitKeysResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2:
+ return soap_out_KMS_Agent__RetrieveKey2(soap, tag, id, (const struct KMS_Agent__RetrieveKey2 *)ptr, "KMS-Agent:RetrieveKey2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response:
+ return soap_out_KMS_Agent__RetrieveKey2Response(soap, tag, id, (const struct KMS_Agent__RetrieveKey2Response *)ptr, "KMS-Agent:RetrieveKey2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey:
+ return soap_out_KMS_Agent__RetrieveKey(soap, tag, id, (const struct KMS_Agent__RetrieveKey *)ptr, "KMS-Agent:RetrieveKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse:
+ return soap_out_KMS_Agent__RetrieveKeyResponse(soap, tag, id, (const struct KMS_Agent__RetrieveKeyResponse *)ptr, "KMS-Agent:RetrieveKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2:
+ return soap_out_KMS_Agent__CreateKey2(soap, tag, id, (const struct KMS_Agent__CreateKey2 *)ptr, "KMS-Agent:CreateKey2");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response:
+ return soap_out_KMS_Agent__CreateKey2Response(soap, tag, id, (const struct KMS_Agent__CreateKey2Response *)ptr, "KMS-Agent:CreateKey2Response");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey:
+ return soap_out_KMS_Agent__CreateKey(soap, tag, id, (const struct KMS_Agent__CreateKey *)ptr, "KMS-Agent:CreateKey");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse:
+ return soap_out_KMS_Agent__CreateKeyResponse(soap, tag, id, (const struct KMS_Agent__CreateKeyResponse *)ptr, "KMS-Agent:CreateKeyResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys:
+ return soap_out_KMS_Agent__DisassociateDataUnitKeys(soap, tag, id, (const struct KMS_Agent__DisassociateDataUnitKeys *)ptr, "KMS-Agent:DisassociateDataUnitKeys");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse:
+ return soap_out_KMS_Agent__DisassociateDataUnitKeysResponse(soap, tag, id, (const struct KMS_Agent__DisassociateDataUnitKeysResponse *)ptr, "KMS-Agent:DisassociateDataUnitKeysResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID:
+ return soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *)ptr, "KMS-Agent:RetrieveDataUnitByExternalUniqueID");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse:
+ return soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *)ptr, "KMS-Agent:RetrieveDataUnitByExternalUniqueIDResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit:
+ return soap_out_KMS_Agent__RetrieveDataUnit(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnit *)ptr, "KMS-Agent:RetrieveDataUnit");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse:
+ return soap_out_KMS_Agent__RetrieveDataUnitResponse(soap, tag, id, (const struct KMS_Agent__RetrieveDataUnitResponse *)ptr, "KMS-Agent:RetrieveDataUnitResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit:
+ return soap_out_KMS_Agent__CreateDataUnit(soap, tag, id, (const struct KMS_Agent__CreateDataUnit *)ptr, "KMS-Agent:CreateDataUnit");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse:
+ return soap_out_KMS_Agent__CreateDataUnitResponse(soap, tag, id, (const struct KMS_Agent__CreateDataUnitResponse *)ptr, "KMS-Agent:CreateDataUnitResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups:
+ return soap_out_KMS_Agent__ListKeyGroups(soap, tag, id, (const struct KMS_Agent__ListKeyGroups *)ptr, "KMS-Agent:ListKeyGroups");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse:
+ return soap_out_KMS_Agent__ListKeyGroupsResponse(soap, tag, id, (const struct KMS_Agent__ListKeyGroupsResponse *)ptr, "KMS-Agent:ListKeyGroupsResponse");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit:
+ return soap_out_KMS_Agent__DataUnit(soap, tag, id, (const struct KMS_Agent__DataUnit *)ptr, "KMS-Agent:DataUnit");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys:
+ return soap_out_KMS_Agent__ArrayOfKeys(soap, tag, id, (const struct KMS_Agent__ArrayOfKeys *)ptr, "KMS-Agent:ArrayOfKeys");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__Key:
+ return soap_out_KMS_Agent__Key(soap, tag, id, (const struct KMS_Agent__Key *)ptr, "KMS-Agent:Key");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups:
+ return soap_out_KMS_Agent__ArrayOfKeyGroups(soap, tag, id, (const struct KMS_Agent__ArrayOfKeyGroups *)ptr, "KMS-Agent:ArrayOfKeyGroups");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup:
+ return soap_out_KMS_Agent__KeyGroup(soap, tag, id, (const struct KMS_Agent__KeyGroup *)ptr, "KMS-Agent:KeyGroup");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters:
+ return soap_out_KMS_Agent__QueryParameters(soap, tag, id, (const struct KMS_Agent__QueryParameters *)ptr, "KMS-Agent:QueryParameters");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters:
+ return soap_out_KMS_Agent__ArrayOfFilterParameters(soap, tag, id, (const struct KMS_Agent__ArrayOfFilterParameters *)ptr, "KMS-Agent:ArrayOfFilterParameters");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters:
+ return soap_out_KMS_Agent__FilterParameters(soap, tag, id, (const struct KMS_Agent__FilterParameters *)ptr, "KMS-Agent:FilterParameters");
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary:
+ return soap_out_KMS_Agent__ArrayOfHexBinary(soap, tag, id, (const struct KMS_Agent__ArrayOfHexBinary *)ptr, "KMS-Agent:ArrayOfHexBinary");
+ case SOAP_TYPE_KMS_Agent_xsd__hexBinary:
+ return soap_out_xsd__hexBinary(soap, tag, id, (const struct xsd__hexBinary *)ptr, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__Key:
+ return soap_out_PointerToKMS_Agent__Key(soap, tag, id, (struct KMS_Agent__Key *const*)ptr, "KMS-Agent:Key");
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__KeyGroup:
+ return soap_out_PointerToKMS_Agent__KeyGroup(soap, tag, id, (struct KMS_Agent__KeyGroup *const*)ptr, "KMS-Agent:KeyGroup");
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__FilterParameters:
+ return soap_out_PointerToKMS_Agent__FilterParameters(soap, tag, id, (struct KMS_Agent__FilterParameters *const*)ptr, "KMS-Agent:FilterParameters");
+ case SOAP_TYPE_KMS_Agent_PointerToxsd__hexBinary:
+ return soap_out_PointerToxsd__hexBinary(soap, tag, id, (struct xsd__hexBinary *const*)ptr, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Agent_PointerTounsignedByte:
+ return soap_out_PointerTounsignedByte(soap, tag, id, (unsigned char *const*)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Agent_xsd__duration:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:duration");
+ case SOAP_TYPE_KMS_Agent_xsd__dateTime:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:dateTime");
+ case SOAP_TYPE_KMS_Agent_xsd__string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ case SOAP_TYPE_KMS_Agent__QName:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:QName");
+ case SOAP_TYPE_KMS_Agent_string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ }
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, int type)
+{
+ (void)soap; (void)ptr; (void)type; /* appease -Wall -Werror */
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK:
+ soap_serialize_KMS_Agent__RegisterAgentKWK(soap, (const struct KMS_Agent__RegisterAgentKWK *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse:
+ soap_serialize_KMS_Agent__RegisterAgentKWKResponse(soap, (const struct KMS_Agent__RegisterAgentKWKResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey:
+ soap_serialize_KMS_Agent__GetAgentKWKPublicKey(soap, (const struct KMS_Agent__GetAgentKWKPublicKey *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse:
+ soap_serialize_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, (const struct KMS_Agent__GetAgentKWKPublicKeyResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog:
+ soap_serialize_KMS_Agent__CreateAuditLog(soap, (const struct KMS_Agent__CreateAuditLog *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse:
+ soap_serialize_KMS_Agent__CreateAuditLogResponse(soap, (const struct KMS_Agent__CreateAuditLogResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2:
+ soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2(soap, (const struct KMS_Agent__RetrieveProtectAndProcessKey2 *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response:
+ soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, (const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey:
+ soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey(soap, (const struct KMS_Agent__RetrieveProtectAndProcessKey *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse:
+ soap_serialize_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, (const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2:
+ soap_serialize_KMS_Agent__RetrieveDataUnitKeys2(soap, (const struct KMS_Agent__RetrieveDataUnitKeys2 *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response:
+ soap_serialize_KMS_Agent__RetrieveDataUnitKeys2Response(soap, (const struct KMS_Agent__RetrieveDataUnitKeys2Response *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys:
+ soap_serialize_KMS_Agent__RetrieveDataUnitKeys(soap, (const struct KMS_Agent__RetrieveDataUnitKeys *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse:
+ soap_serialize_KMS_Agent__RetrieveDataUnitKeysResponse(soap, (const struct KMS_Agent__RetrieveDataUnitKeysResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2:
+ soap_serialize_KMS_Agent__RetrieveKey2(soap, (const struct KMS_Agent__RetrieveKey2 *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response:
+ soap_serialize_KMS_Agent__RetrieveKey2Response(soap, (const struct KMS_Agent__RetrieveKey2Response *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey:
+ soap_serialize_KMS_Agent__RetrieveKey(soap, (const struct KMS_Agent__RetrieveKey *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse:
+ soap_serialize_KMS_Agent__RetrieveKeyResponse(soap, (const struct KMS_Agent__RetrieveKeyResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2:
+ soap_serialize_KMS_Agent__CreateKey2(soap, (const struct KMS_Agent__CreateKey2 *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response:
+ soap_serialize_KMS_Agent__CreateKey2Response(soap, (const struct KMS_Agent__CreateKey2Response *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey:
+ soap_serialize_KMS_Agent__CreateKey(soap, (const struct KMS_Agent__CreateKey *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse:
+ soap_serialize_KMS_Agent__CreateKeyResponse(soap, (const struct KMS_Agent__CreateKeyResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys:
+ soap_serialize_KMS_Agent__DisassociateDataUnitKeys(soap, (const struct KMS_Agent__DisassociateDataUnitKeys *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse:
+ soap_serialize_KMS_Agent__DisassociateDataUnitKeysResponse(soap, (const struct KMS_Agent__DisassociateDataUnitKeysResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID:
+ soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, (const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse:
+ soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, (const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit:
+ soap_serialize_KMS_Agent__RetrieveDataUnit(soap, (const struct KMS_Agent__RetrieveDataUnit *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse:
+ soap_serialize_KMS_Agent__RetrieveDataUnitResponse(soap, (const struct KMS_Agent__RetrieveDataUnitResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit:
+ soap_serialize_KMS_Agent__CreateDataUnit(soap, (const struct KMS_Agent__CreateDataUnit *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse:
+ soap_serialize_KMS_Agent__CreateDataUnitResponse(soap, (const struct KMS_Agent__CreateDataUnitResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups:
+ soap_serialize_KMS_Agent__ListKeyGroups(soap, (const struct KMS_Agent__ListKeyGroups *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse:
+ soap_serialize_KMS_Agent__ListKeyGroupsResponse(soap, (const struct KMS_Agent__ListKeyGroupsResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit:
+ soap_serialize_KMS_Agent__DataUnit(soap, (const struct KMS_Agent__DataUnit *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys:
+ soap_serialize_KMS_Agent__ArrayOfKeys(soap, (const struct KMS_Agent__ArrayOfKeys *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__Key:
+ soap_serialize_KMS_Agent__Key(soap, (const struct KMS_Agent__Key *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups:
+ soap_serialize_KMS_Agent__ArrayOfKeyGroups(soap, (const struct KMS_Agent__ArrayOfKeyGroups *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup:
+ soap_serialize_KMS_Agent__KeyGroup(soap, (const struct KMS_Agent__KeyGroup *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters:
+ soap_serialize_KMS_Agent__QueryParameters(soap, (const struct KMS_Agent__QueryParameters *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters:
+ soap_serialize_KMS_Agent__ArrayOfFilterParameters(soap, (const struct KMS_Agent__ArrayOfFilterParameters *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters:
+ soap_serialize_KMS_Agent__FilterParameters(soap, (const struct KMS_Agent__FilterParameters *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary:
+ soap_serialize_KMS_Agent__ArrayOfHexBinary(soap, (const struct KMS_Agent__ArrayOfHexBinary *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_xsd__hexBinary:
+ soap_serialize_xsd__hexBinary(soap, (const struct xsd__hexBinary *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__Key:
+ soap_serialize_PointerToKMS_Agent__Key(soap, (struct KMS_Agent__Key *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__KeyGroup:
+ soap_serialize_PointerToKMS_Agent__KeyGroup(soap, (struct KMS_Agent__KeyGroup *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__FilterParameters:
+ soap_serialize_PointerToKMS_Agent__FilterParameters(soap, (struct KMS_Agent__FilterParameters *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_PointerToxsd__hexBinary:
+ soap_serialize_PointerToxsd__hexBinary(soap, (struct xsd__hexBinary *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_PointerTounsignedByte:
+ soap_serialize_PointerTounsignedByte(soap, (unsigned char *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_xsd__duration:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_xsd__dateTime:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_xsd__string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent__QName:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ }
+}
+#endif
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n)
+{
+ switch (t)
+ {
+ case SOAP_TYPE_KMS_Agent_xsd__hexBinary:
+ return (void*)soap_instantiate_xsd__hexBinary(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary:
+ return (void*)soap_instantiate_KMS_Agent__ArrayOfHexBinary(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters:
+ return (void*)soap_instantiate_KMS_Agent__FilterParameters(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters:
+ return (void*)soap_instantiate_KMS_Agent__ArrayOfFilterParameters(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters:
+ return (void*)soap_instantiate_KMS_Agent__QueryParameters(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup:
+ return (void*)soap_instantiate_KMS_Agent__KeyGroup(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups:
+ return (void*)soap_instantiate_KMS_Agent__ArrayOfKeyGroups(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__Key:
+ return (void*)soap_instantiate_KMS_Agent__Key(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys:
+ return (void*)soap_instantiate_KMS_Agent__ArrayOfKeys(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit:
+ return (void*)soap_instantiate_KMS_Agent__DataUnit(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse:
+ return (void*)soap_instantiate_KMS_Agent__ListKeyGroupsResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups:
+ return (void*)soap_instantiate_KMS_Agent__ListKeyGroups(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse:
+ return (void*)soap_instantiate_KMS_Agent__CreateDataUnitResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit:
+ return (void*)soap_instantiate_KMS_Agent__CreateDataUnit(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnit(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse:
+ return (void*)soap_instantiate_KMS_Agent__DisassociateDataUnitKeysResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys:
+ return (void*)soap_instantiate_KMS_Agent__DisassociateDataUnitKeys(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse:
+ return (void*)soap_instantiate_KMS_Agent__CreateKeyResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey:
+ return (void*)soap_instantiate_KMS_Agent__CreateKey(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response:
+ return (void*)soap_instantiate_KMS_Agent__CreateKey2Response(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2:
+ return (void*)soap_instantiate_KMS_Agent__CreateKey2(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveKeyResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveKey(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveKey2Response(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveKey2(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitKeysResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitKeys(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2Response(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2:
+ return (void*)soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse:
+ return (void*)soap_instantiate_KMS_Agent__CreateAuditLogResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog:
+ return (void*)soap_instantiate_KMS_Agent__CreateAuditLog(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse:
+ return (void*)soap_instantiate_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey:
+ return (void*)soap_instantiate_KMS_Agent__GetAgentKWKPublicKey(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse:
+ return (void*)soap_instantiate_KMS_Agent__RegisterAgentKWKResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK:
+ return (void*)soap_instantiate_KMS_Agent__RegisterAgentKWK(soap, -1, type, arrayType, n);
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Header:
+ return (void*)soap_instantiate_SOAP_ENV__Header(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Code:
+ return (void*)soap_instantiate_SOAP_ENV__Code(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail:
+ return (void*)soap_instantiate_SOAP_ENV__Detail(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason:
+ return (void*)soap_instantiate_SOAP_ENV__Reason(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault:
+ return (void*)soap_instantiate_SOAP_ENV__Fault(soap, -1, type, arrayType, n);
+#endif
+ }
+ return NULL;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p)
+{ switch (p->type)
+ {
+ case SOAP_TYPE_KMS_Agent_xsd__hexBinary:
+ if (p->size < 0)
+ SOAP_DELETE((struct xsd__hexBinary*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct xsd__hexBinary*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__ArrayOfHexBinary*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__ArrayOfHexBinary*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__FilterParameters*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__FilterParameters*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__ArrayOfFilterParameters*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__ArrayOfFilterParameters*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__QueryParameters*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__QueryParameters*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__KeyGroup*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__KeyGroup*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__ArrayOfKeyGroups*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__ArrayOfKeyGroups*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__Key:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__Key*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__Key*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__ArrayOfKeys*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__ArrayOfKeys*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__DataUnit*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__DataUnit*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__ListKeyGroupsResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__ListKeyGroupsResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__ListKeyGroups*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__ListKeyGroups*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateDataUnitResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateDataUnitResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateDataUnit*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateDataUnit*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnit*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnit*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitByExternalUniqueID*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitByExternalUniqueID*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__DisassociateDataUnitKeysResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__DisassociateDataUnitKeysResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__DisassociateDataUnitKeys*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__DisassociateDataUnitKeys*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateKeyResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateKeyResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateKey*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateKey*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateKey2Response*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateKey2Response*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateKey2*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateKey2*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveKeyResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveKeyResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveKey*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveKey*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveKey2Response*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveKey2Response*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveKey2*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveKey2*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitKeysResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitKeysResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitKeys*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitKeys*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitKeys2Response*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitKeys2Response*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveDataUnitKeys2*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveDataUnitKeys2*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveProtectAndProcessKeyResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveProtectAndProcessKeyResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveProtectAndProcessKey*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveProtectAndProcessKey*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveProtectAndProcessKey2Response*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveProtectAndProcessKey2Response*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RetrieveProtectAndProcessKey2*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RetrieveProtectAndProcessKey2*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateAuditLogResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateAuditLogResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__CreateAuditLog*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__CreateAuditLog*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__GetAgentKWKPublicKeyResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__GetAgentKWKPublicKeyResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__GetAgentKWKPublicKey*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__GetAgentKWKPublicKey*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RegisterAgentKWKResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RegisterAgentKWKResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Agent__RegisterAgentKWK*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Agent__RegisterAgentKWK*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Header:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Code:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr);
+ break;
+ default: return SOAP_ERR;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType)
+{ return soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_byte
+ *a = SOAP_DEFAULT_byte;
+#else
+ *a = (char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type)
+{
+ return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_byte);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap *soap, const char *tag, char *a, const char *type)
+{ char *p;
+ p = soap_inbyte(soap, tag, a, type, SOAP_TYPE_KMS_Agent_byte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap *soap, const char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_byte);
+ if (soap_out_byte(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap *soap, char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_byte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_int
+ *a = SOAP_DEFAULT_int;
+#else
+ *a = (int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type)
+{
+ return soap_outint(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_int);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap *soap, const char *tag, int *a, const char *type)
+{ int *p;
+ p = soap_inint(soap, tag, a, type, SOAP_TYPE_KMS_Agent_int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap *soap, const int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_int);
+ if (soap_out_int(soap, tag?tag:"int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap *soap, int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_xsd__int);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_Agent_xsd__int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__int);
+ if (soap_out_xsd__int(soap, tag?tag:"xsd:int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap *soap, long *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_long
+ *a = SOAP_DEFAULT_long;
+#else
+ *a = (long)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_long);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_Agent_long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_long);
+ if (soap_out_long(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_xsd__long);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_Agent_xsd__long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__long);
+ if (soap_out_xsd__long(soap, tag?tag:"xsd:long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap *soap, LONG64 *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_LONG64
+ *a = SOAP_DEFAULT_LONG64;
+#else
+ *a = (LONG64)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_LONG64);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_Agent_LONG64);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_LONG64);
+ if (soap_out_LONG64(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_LONG64(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_xsd__float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_Agent_xsd__float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__float);
+ if (soap_out_xsd__float(soap, tag?tag:"xsd:float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap *soap, float *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_float
+ *a = SOAP_DEFAULT_float;
+#else
+ *a = (float)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_Agent_float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_float);
+ if (soap_out_float(soap, tag?tag:"float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap *soap, unsigned char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedByte
+ *a = SOAP_DEFAULT_unsignedByte;
+#else
+ *a = (unsigned char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *a, const char *type)
+{
+ return soap_outunsignedByte(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_unsignedByte);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap *soap, const char *tag, unsigned char *a, const char *type)
+{ unsigned char *p;
+ p = soap_inunsignedByte(soap, tag, a, type, SOAP_TYPE_KMS_Agent_unsignedByte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap *soap, const unsigned char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_unsignedByte);
+ if (soap_out_unsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap *soap, unsigned char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap *soap, unsigned int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedInt
+ *a = SOAP_DEFAULT_unsignedInt;
+#else
+ *a = (unsigned int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *a, const char *type)
+{
+ return soap_outunsignedInt(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_unsignedInt);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap *soap, const char *tag, unsigned int *a, const char *type)
+{ unsigned int *p;
+ p = soap_inunsignedInt(soap, tag, a, type, SOAP_TYPE_KMS_Agent_unsignedInt);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap *soap, const unsigned int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_unsignedInt);
+ if (soap_out_unsignedInt(soap, tag?tag:"unsignedInt", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap *soap, unsigned int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedInt(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__AuditLogCondition(struct soap *soap, enum KMS_Agent__AuditLogCondition *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__AuditLogCondition
+ *a = SOAP_DEFAULT_KMS_Agent__AuditLogCondition;
+#else
+ *a = (enum KMS_Agent__AuditLogCondition)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__AuditLogCondition[] =
+{ { (long)AUDIT_LOG_SUCCESS_CONDITION, "AUDIT-LOG-SUCCESS-CONDITION" },
+ { (long)AUDIT_LOG_ERROR_CONDITION, "AUDIT-LOG-ERROR-CONDITION" },
+ { (long)AUDIT_LOG_WARNING_CONDITION, "AUDIT-LOG-WARNING-CONDITION" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__AuditLogCondition2s(struct soap *soap, enum KMS_Agent__AuditLogCondition n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__AuditLogCondition, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__AuditLogCondition(struct soap *soap, const char *tag, int id, const enum KMS_Agent__AuditLogCondition *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition), type) || soap_send(soap, soap_KMS_Agent__AuditLogCondition2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__AuditLogCondition(struct soap *soap, const char *s, enum KMS_Agent__AuditLogCondition *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__AuditLogCondition, s);
+ if (map)
+ *a = (enum KMS_Agent__AuditLogCondition)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 2)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__AuditLogCondition)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__AuditLogCondition * SOAP_FMAC4 soap_in_KMS_Agent__AuditLogCondition(struct soap *soap, const char *tag, enum KMS_Agent__AuditLogCondition *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__AuditLogCondition *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition, sizeof(enum KMS_Agent__AuditLogCondition), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__AuditLogCondition(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__AuditLogCondition *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition, 0, sizeof(enum KMS_Agent__AuditLogCondition), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__AuditLogCondition(struct soap *soap, const enum KMS_Agent__AuditLogCondition *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition);
+ if (soap_out_KMS_Agent__AuditLogCondition(soap, tag?tag:"KMS-Agent:AuditLogCondition", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__AuditLogCondition * SOAP_FMAC4 soap_get_KMS_Agent__AuditLogCondition(struct soap *soap, enum KMS_Agent__AuditLogCondition *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__AuditLogCondition(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__AuditLogRetention(struct soap *soap, enum KMS_Agent__AuditLogRetention *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__AuditLogRetention
+ *a = SOAP_DEFAULT_KMS_Agent__AuditLogRetention;
+#else
+ *a = (enum KMS_Agent__AuditLogRetention)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__AuditLogRetention[] =
+{ { (long)AUDIT_LOG_LONG_TERM_RETENTION, "AUDIT-LOG-LONG-TERM-RETENTION" },
+ { (long)AUDIT_LOG_MEDIUM_TERM_RETENTION, "AUDIT-LOG-MEDIUM-TERM-RETENTION" },
+ { (long)AUDIT_LOG_SHORT_TERM_RETENTION, "AUDIT-LOG-SHORT-TERM-RETENTION" },
+ { (long)AUDIT_LOG_ZERO_RETENTION, "AUDIT-LOG-ZERO-RETENTION" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__AuditLogRetention2s(struct soap *soap, enum KMS_Agent__AuditLogRetention n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__AuditLogRetention, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__AuditLogRetention(struct soap *soap, const char *tag, int id, const enum KMS_Agent__AuditLogRetention *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention), type) || soap_send(soap, soap_KMS_Agent__AuditLogRetention2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__AuditLogRetention(struct soap *soap, const char *s, enum KMS_Agent__AuditLogRetention *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__AuditLogRetention, s);
+ if (map)
+ *a = (enum KMS_Agent__AuditLogRetention)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 3)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__AuditLogRetention)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__AuditLogRetention * SOAP_FMAC4 soap_in_KMS_Agent__AuditLogRetention(struct soap *soap, const char *tag, enum KMS_Agent__AuditLogRetention *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__AuditLogRetention *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention, sizeof(enum KMS_Agent__AuditLogRetention), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__AuditLogRetention(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__AuditLogRetention *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention, 0, sizeof(enum KMS_Agent__AuditLogRetention), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__AuditLogRetention(struct soap *soap, const enum KMS_Agent__AuditLogRetention *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention);
+ if (soap_out_KMS_Agent__AuditLogRetention(soap, tag?tag:"KMS-Agent:AuditLogRetention", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__AuditLogRetention * SOAP_FMAC4 soap_get_KMS_Agent__AuditLogRetention(struct soap *soap, enum KMS_Agent__AuditLogRetention *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__AuditLogRetention(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DataUnitState(struct soap *soap, enum KMS_Agent__DataUnitState *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__DataUnitState
+ *a = SOAP_DEFAULT_KMS_Agent__DataUnitState;
+#else
+ *a = (enum KMS_Agent__DataUnitState)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__DataUnitState[] =
+{ { (long)DATA_UNIT_STATE_NO_KEY, "DATA-UNIT-STATE-NO-KEY" },
+ { (long)DATA_UNIT_STATE_READABLE_NORMAL, "DATA-UNIT-STATE-READABLE-NORMAL" },
+ { (long)DATA_UNIT_STATE_READABLE_NEEDS_REKEY, "DATA-UNIT-STATE-READABLE-NEEDS-REKEY" },
+ { (long)DATA_UNIT_STATE_SHREDDED, "DATA-UNIT-STATE-SHREDDED" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__DataUnitState2s(struct soap *soap, enum KMS_Agent__DataUnitState n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__DataUnitState, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DataUnitState(struct soap *soap, const char *tag, int id, const enum KMS_Agent__DataUnitState *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState), type) || soap_send(soap, soap_KMS_Agent__DataUnitState2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__DataUnitState(struct soap *soap, const char *s, enum KMS_Agent__DataUnitState *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__DataUnitState, s);
+ if (map)
+ *a = (enum KMS_Agent__DataUnitState)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 3)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__DataUnitState)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__DataUnitState * SOAP_FMAC4 soap_in_KMS_Agent__DataUnitState(struct soap *soap, const char *tag, enum KMS_Agent__DataUnitState *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__DataUnitState *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState, sizeof(enum KMS_Agent__DataUnitState), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__DataUnitState(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__DataUnitState *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState, 0, sizeof(enum KMS_Agent__DataUnitState), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DataUnitState(struct soap *soap, const enum KMS_Agent__DataUnitState *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState);
+ if (soap_out_KMS_Agent__DataUnitState(soap, tag?tag:"KMS-Agent:DataUnitState", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__DataUnitState * SOAP_FMAC4 soap_get_KMS_Agent__DataUnitState(struct soap *soap, enum KMS_Agent__DataUnitState *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__DataUnitState(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__KeyState(struct soap *soap, enum KMS_Agent__KeyState *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__KeyState
+ *a = SOAP_DEFAULT_KMS_Agent__KeyState;
+#else
+ *a = (enum KMS_Agent__KeyState)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__KeyState[] =
+{ { (long)KEY_STATE_GENERATED, "KEY-STATE-GENERATED" },
+ { (long)KEY_STATE_READY, "KEY-STATE-READY" },
+ { (long)KEY_STATE_PROTECT_AND_PROCESS, "KEY-STATE-PROTECT-AND-PROCESS" },
+ { (long)KEY_STATE_PROCESS_ONLY, "KEY-STATE-PROCESS-ONLY" },
+ { (long)KEY_STATE_DEACTIVATED, "KEY-STATE-DEACTIVATED" },
+ { (long)KEY_STATE_COMPROMISED, "KEY-STATE-COMPROMISED" },
+ { (long)KEY_STATE_DESTROYED_INCOMPLETE, "KEY-STATE-DESTROYED-INCOMPLETE" },
+ { (long)KEY_STATE_DESTROYED_COMPLETE, "KEY-STATE-DESTROYED-COMPLETE" },
+ { (long)KEY_STATE_DESTROYED_COMPROMISED_INCOMPLETE, "KEY-STATE-DESTROYED-COMPROMISED-INCOMPLETE" },
+ { (long)KEY_STATE_DESTROYED_COMPROMISED_COMPLETE, "KEY-STATE-DESTROYED-COMPROMISED-COMPLETE" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__KeyState2s(struct soap *soap, enum KMS_Agent__KeyState n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__KeyState, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__KeyState(struct soap *soap, const char *tag, int id, const enum KMS_Agent__KeyState *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState), type) || soap_send(soap, soap_KMS_Agent__KeyState2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__KeyState(struct soap *soap, const char *s, enum KMS_Agent__KeyState *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__KeyState, s);
+ if (map)
+ *a = (enum KMS_Agent__KeyState)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 9)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__KeyState)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__KeyState * SOAP_FMAC4 soap_in_KMS_Agent__KeyState(struct soap *soap, const char *tag, enum KMS_Agent__KeyState *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__KeyState *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState, sizeof(enum KMS_Agent__KeyState), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__KeyState(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__KeyState *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState, 0, sizeof(enum KMS_Agent__KeyState), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__KeyState(struct soap *soap, const enum KMS_Agent__KeyState *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState);
+ if (soap_out_KMS_Agent__KeyState(soap, tag?tag:"KMS-Agent:KeyState", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__KeyState * SOAP_FMAC4 soap_get_KMS_Agent__KeyState(struct soap *soap, enum KMS_Agent__KeyState *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__KeyState(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__KeyType(struct soap *soap, enum KMS_Agent__KeyType *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__KeyType
+ *a = SOAP_DEFAULT_KMS_Agent__KeyType;
+#else
+ *a = (enum KMS_Agent__KeyType)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__KeyType[] =
+{ { (long)KEY_TYPE_AES_256, "KEY-TYPE-AES-256" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__KeyType2s(struct soap *soap, enum KMS_Agent__KeyType n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__KeyType, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__KeyType(struct soap *soap, const char *tag, int id, const enum KMS_Agent__KeyType *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType), type) || soap_send(soap, soap_KMS_Agent__KeyType2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__KeyType(struct soap *soap, const char *s, enum KMS_Agent__KeyType *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__KeyType, s);
+ if (map)
+ *a = (enum KMS_Agent__KeyType)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 0)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__KeyType)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__KeyType * SOAP_FMAC4 soap_in_KMS_Agent__KeyType(struct soap *soap, const char *tag, enum KMS_Agent__KeyType *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__KeyType *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType, sizeof(enum KMS_Agent__KeyType), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__KeyType(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__KeyType *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType, 0, sizeof(enum KMS_Agent__KeyType), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__KeyType(struct soap *soap, const enum KMS_Agent__KeyType *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType);
+ if (soap_out_KMS_Agent__KeyType(soap, tag?tag:"KMS-Agent:KeyType", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__KeyType * SOAP_FMAC4 soap_get_KMS_Agent__KeyType(struct soap *soap, enum KMS_Agent__KeyType *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__KeyType(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__FilterOperator(struct soap *soap, enum KMS_Agent__FilterOperator *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__FilterOperator
+ *a = SOAP_DEFAULT_KMS_Agent__FilterOperator;
+#else
+ *a = (enum KMS_Agent__FilterOperator)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__FilterOperator[] =
+{ { (long)FILTER_OPERATOR_EQUAL, "FILTER-OPERATOR-EQUAL" },
+ { (long)FILTER_OPERATOR_NOT_EQUAL, "FILTER-OPERATOR-NOT-EQUAL" },
+ { (long)FILTER_OPERATOR_GREATER_THAN, "FILTER-OPERATOR-GREATER-THAN" },
+ { (long)FILTER_OPERATOR_LESS_THAN, "FILTER-OPERATOR-LESS-THAN" },
+ { (long)FILTER_OPERATOR_GREATER_THAN_OR_EQUAL, "FILTER-OPERATOR-GREATER-THAN-OR-EQUAL" },
+ { (long)FILTER_OPERATOR_LESS_THAN_OR_EQUAL, "FILTER-OPERATOR-LESS-THAN-OR-EQUAL" },
+ { (long)FILTER_OPERATOR_STARTS_WITH, "FILTER-OPERATOR-STARTS-WITH" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__FilterOperator2s(struct soap *soap, enum KMS_Agent__FilterOperator n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__FilterOperator, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__FilterOperator(struct soap *soap, const char *tag, int id, const enum KMS_Agent__FilterOperator *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator), type) || soap_send(soap, soap_KMS_Agent__FilterOperator2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__FilterOperator(struct soap *soap, const char *s, enum KMS_Agent__FilterOperator *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__FilterOperator, s);
+ if (map)
+ *a = (enum KMS_Agent__FilterOperator)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 6)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__FilterOperator)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__FilterOperator * SOAP_FMAC4 soap_in_KMS_Agent__FilterOperator(struct soap *soap, const char *tag, enum KMS_Agent__FilterOperator *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__FilterOperator *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator, sizeof(enum KMS_Agent__FilterOperator), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__FilterOperator(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__FilterOperator *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator, 0, sizeof(enum KMS_Agent__FilterOperator), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__FilterOperator(struct soap *soap, const enum KMS_Agent__FilterOperator *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator);
+ if (soap_out_KMS_Agent__FilterOperator(soap, tag?tag:"KMS-Agent:FilterOperator", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__FilterOperator * SOAP_FMAC4 soap_get_KMS_Agent__FilterOperator(struct soap *soap, enum KMS_Agent__FilterOperator *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__FilterOperator(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__SortOrder(struct soap *soap, enum KMS_Agent__SortOrder *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_KMS_Agent__SortOrder
+ *a = SOAP_DEFAULT_KMS_Agent__SortOrder;
+#else
+ *a = (enum KMS_Agent__SortOrder)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_KMS_Agent__SortOrder[] =
+{ { (long)SORT_ORDER_ASCENDING, "SORT-ORDER-ASCENDING" },
+ { (long)SORT_ORDER_DESCENDING, "SORT-ORDER-DESCENDING" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__SortOrder2s(struct soap *soap, enum KMS_Agent__SortOrder n)
+{ const char *s = soap_code_str(soap_codes_KMS_Agent__SortOrder, (long)n);
+ if (s)
+ return s;
+ return soap_long2s(soap, (long)n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__SortOrder(struct soap *soap, const char *tag, int id, const enum KMS_Agent__SortOrder *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder), type) || soap_send(soap, soap_KMS_Agent__SortOrder2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__SortOrder(struct soap *soap, const char *s, enum KMS_Agent__SortOrder *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_KMS_Agent__SortOrder, s);
+ if (map)
+ *a = (enum KMS_Agent__SortOrder)map->code;
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || ((soap->mode & SOAP_XML_STRICT) && (n < 0 || n > 1)))
+ return soap->error = SOAP_TYPE;
+ *a = (enum KMS_Agent__SortOrder)n;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 enum KMS_Agent__SortOrder * SOAP_FMAC4 soap_in_KMS_Agent__SortOrder(struct soap *soap, const char *tag, enum KMS_Agent__SortOrder *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (enum KMS_Agent__SortOrder *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder, sizeof(enum KMS_Agent__SortOrder), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2KMS_Agent__SortOrder(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (enum KMS_Agent__SortOrder *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder, 0, sizeof(enum KMS_Agent__SortOrder), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__SortOrder(struct soap *soap, const enum KMS_Agent__SortOrder *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder);
+ if (soap_out_KMS_Agent__SortOrder(soap, tag?tag:"KMS-Agent:SortOrder", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 enum KMS_Agent__SortOrder * SOAP_FMAC4 soap_get_KMS_Agent__SortOrder(struct soap *soap, enum KMS_Agent__SortOrder *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__SortOrder(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap *soap, bool n)
+{ return soap_bool2s(soap, n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_xsd__boolean), type) || soap_send(soap, soap_xsd__boolean2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap *soap, const char *s, bool *a)
+{
+ return soap_s2bool(soap, s, a);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_xsd__boolean, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2xsd__boolean(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_xsd__boolean, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__boolean);
+ if (soap_out_xsd__boolean(soap, tag?tag:"xsd:boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__boolean(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap *soap, bool *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_bool
+ *a = SOAP_DEFAULT_bool;
+#else
+ *a = (bool)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_bool[] =
+{ { (long)false, "false" },
+ { (long)true, "true" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap *soap, bool n)
+{
+ (void)soap; /* appease -Wall -Werror */
+return soap_code_str(soap_codes_bool, n!=0);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_bool), type) || soap_send(soap, soap_bool2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap *soap, const char *s, bool *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_bool, s);
+ if (map)
+ *a = (bool)(map->code != 0);
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || n < 0 || n > 1)
+ return soap->error = SOAP_TYPE;
+ *a = (bool)(n != 0);
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_bool, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2bool(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_bool, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_bool);
+ if (soap_out_bool(soap, tag?tag:"boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_bool(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->faultcode);
+ soap_default_string(soap, &a->faultstring);
+ soap_default_string(soap, &a->faultactor);
+ a->detail = NULL;
+ a->SOAP_ENV__Code = NULL;
+ a->SOAP_ENV__Reason = NULL;
+ soap_default_string(soap, &a->SOAP_ENV__Node);
+ soap_default_string(soap, &a->SOAP_ENV__Role);
+ a->SOAP_ENV__Detail = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->faultcode);
+ soap_serialize_string(soap, &a->faultstring);
+ soap_serialize_string(soap, &a->faultactor);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->detail);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Code);
+ soap_serialize_PointerToSOAP_ENV__Reason(soap, &a->SOAP_ENV__Reason);
+ soap_serialize_string(soap, &a->SOAP_ENV__Node);
+ soap_serialize_string(soap, &a->SOAP_ENV__Role);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->SOAP_ENV__Detail);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type)
+{
+ const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault), type))
+ return soap->error;
+ if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, ""))
+ return soap->error;
+ if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "xsd:string"))
+ return soap->error;
+ if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "xsd:string"))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", -1, &a->SOAP_ENV__Code, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", -1, &a->SOAP_ENV__Reason, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Node", -1, &a->SOAP_ENV__Node, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Role", -1, &a->SOAP_ENV__Role, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", -1, &a->SOAP_ENV__Detail, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap *soap, const char *tag, struct SOAP_ENV__Fault *a, const char *type)
+{
+ size_t soap_flag_faultcode = 1;
+ size_t soap_flag_faultstring = 1;
+ size_t soap_flag_faultactor = 1;
+ size_t soap_flag_detail = 1;
+ size_t soap_flag_SOAP_ENV__Code = 1;
+ size_t soap_flag_SOAP_ENV__Reason = 1;
+ size_t soap_flag_SOAP_ENV__Node = 1;
+ size_t soap_flag_SOAP_ENV__Role = 1;
+ size_t soap_flag_SOAP_ENV__Detail = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Fault(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_faultcode && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "faultcode", &a->faultcode, ""))
+ { soap_flag_faultcode--;
+ continue;
+ }
+ if (soap_flag_faultstring && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultstring", &a->faultstring, "xsd:string"))
+ { soap_flag_faultstring--;
+ continue;
+ }
+ if (soap_flag_faultactor && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultactor", &a->faultactor, "xsd:string"))
+ { soap_flag_faultactor--;
+ continue;
+ }
+ if (soap_flag_detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "detail", &a->detail, ""))
+ { soap_flag_detail--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Code && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", &a->SOAP_ENV__Code, ""))
+ { soap_flag_SOAP_ENV__Code--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Reason && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", &a->SOAP_ENV__Reason, ""))
+ { soap_flag_SOAP_ENV__Reason--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Node && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Node", &a->SOAP_ENV__Node, "xsd:string"))
+ { soap_flag_SOAP_ENV__Node--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Role && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Role", &a->SOAP_ENV__Role, "xsd:string"))
+ { soap_flag_SOAP_ENV__Role--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", &a->SOAP_ENV__Detail, ""))
+ { soap_flag_SOAP_ENV__Detail--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault, 0, sizeof(struct SOAP_ENV__Fault), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault);
+ if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Fault(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Fault);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Fault);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Fault*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason), type))
+ return soap->error;
+ if (soap->lang)
+ soap_set_attr(soap, "xml:lang", soap->lang, 1);
+ if (soap_out_string(soap, "SOAP-ENV:Text", -1, &a->SOAP_ENV__Text, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Text = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Reason(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Text && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Text", &a->SOAP_ENV__Text, "xsd:string"))
+ { soap_flag_SOAP_ENV__Text--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason, 0, sizeof(struct SOAP_ENV__Reason), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason);
+ if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Reason);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Reason);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Reason*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ a->__type = 0;
+ a->fault = NULL;
+ a->__any = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_markelement(soap, a->fault, a->__type);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail), type))
+ return soap->error;
+ if (soap_putelement(soap, a->fault, "fault", -1, a->__type))
+ return soap->error;
+ soap_outliteral(soap, "-any", &a->__any, NULL);
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail *a, const char *type)
+{
+ size_t soap_flag_fault = 1;
+ size_t soap_flag___any = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Detail(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_fault && soap->error == SOAP_TAG_MISMATCH)
+ if ((a->fault = soap_getelement(soap, &a->__type)))
+ { soap_flag_fault = 0;
+ continue;
+ }
+ if (soap_flag___any && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_inliteral(soap, "-any", &a->__any))
+ { soap_flag___any--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail, 0, sizeof(struct SOAP_ENV__Detail), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail);
+ if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Detail);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Detail);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Detail*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->SOAP_ENV__Value);
+ a->SOAP_ENV__Subcode = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->SOAP_ENV__Value);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Subcode);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type)
+{
+ const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code), type))
+ return soap->error;
+ if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Value = 1;
+ size_t soap_flag_SOAP_ENV__Subcode = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Code(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Value && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "SOAP-ENV:Value", &a->SOAP_ENV__Value, ""))
+ { soap_flag_SOAP_ENV__Value--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Subcode && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", &a->SOAP_ENV__Subcode, ""))
+ { soap_flag_SOAP_ENV__Subcode--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code, 0, sizeof(struct SOAP_ENV__Code), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code);
+ if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Code);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Code);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Code*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Header), type))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap *soap, const char *tag, struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Header(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_SOAP_ENV__Header, 0, sizeof(struct SOAP_ENV__Header), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_SOAP_ENV__Header);
+ if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Header(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_SOAP_ENV__Header, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Header);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Header);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Header*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RegisterAgentKWK(struct soap *soap, struct KMS_Agent__RegisterAgentKWK *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__hexBinary(soap, &a->AgentKWK);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RegisterAgentKWK(struct soap *soap, const struct KMS_Agent__RegisterAgentKWK *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->AgentKWK, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ soap_serialize_xsd__hexBinary(soap, &a->AgentKWK);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RegisterAgentKWK(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RegisterAgentKWK *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK), type))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "AgentKWK", -1, &a->AgentKWK, "xsd:hexBinary"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWK * SOAP_FMAC4 soap_in_KMS_Agent__RegisterAgentKWK(struct soap *soap, const char *tag, struct KMS_Agent__RegisterAgentKWK *a, const char *type)
+{
+ size_t soap_flag_AgentKWK = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RegisterAgentKWK *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK, sizeof(struct KMS_Agent__RegisterAgentKWK), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RegisterAgentKWK(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_AgentKWK && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "AgentKWK", &a->AgentKWK, "xsd:hexBinary"))
+ { soap_flag_AgentKWK--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RegisterAgentKWK *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK, 0, sizeof(struct KMS_Agent__RegisterAgentKWK), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_AgentKWK > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RegisterAgentKWK(struct soap *soap, const struct KMS_Agent__RegisterAgentKWK *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK);
+ if (soap_out_KMS_Agent__RegisterAgentKWK(soap, tag?tag:"KMS-Agent:RegisterAgentKWK", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWK * SOAP_FMAC4 soap_get_KMS_Agent__RegisterAgentKWK(struct soap *soap, struct KMS_Agent__RegisterAgentKWK *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RegisterAgentKWK(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RegisterAgentKWK * SOAP_FMAC2 soap_instantiate_KMS_Agent__RegisterAgentKWK(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RegisterAgentKWK(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RegisterAgentKWK);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RegisterAgentKWK);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RegisterAgentKWK[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RegisterAgentKWK);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RegisterAgentKWK*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RegisterAgentKWK(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RegisterAgentKWK %p -> %p\n", q, p));
+ *(struct KMS_Agent__RegisterAgentKWK*)p = *(struct KMS_Agent__RegisterAgentKWK*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, struct KMS_Agent__RegisterAgentKWKResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, const struct KMS_Agent__RegisterAgentKWKResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RegisterAgentKWKResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "AgentKWKID", -1, &a->AgentKWKID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWKResponse * SOAP_FMAC4 soap_in_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, const char *tag, struct KMS_Agent__RegisterAgentKWKResponse *a, const char *type)
+{
+ size_t soap_flag_AgentKWKID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RegisterAgentKWKResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse, sizeof(struct KMS_Agent__RegisterAgentKWKResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RegisterAgentKWKResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_AgentKWKID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "AgentKWKID", &a->AgentKWKID, "xsd:string"))
+ { soap_flag_AgentKWKID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RegisterAgentKWKResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse, 0, sizeof(struct KMS_Agent__RegisterAgentKWKResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, const struct KMS_Agent__RegisterAgentKWKResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse);
+ if (soap_out_KMS_Agent__RegisterAgentKWKResponse(soap, tag?tag:"KMS-Agent:RegisterAgentKWKResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWKResponse * SOAP_FMAC4 soap_get_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, struct KMS_Agent__RegisterAgentKWKResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RegisterAgentKWKResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RegisterAgentKWKResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RegisterAgentKWKResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RegisterAgentKWKResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RegisterAgentKWKResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RegisterAgentKWKResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RegisterAgentKWKResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RegisterAgentKWKResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RegisterAgentKWKResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RegisterAgentKWKResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__RegisterAgentKWKResponse*)p = *(struct KMS_Agent__RegisterAgentKWKResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, struct KMS_Agent__GetAgentKWKPublicKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, const struct KMS_Agent__GetAgentKWKPublicKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, const char *tag, int id, const struct KMS_Agent__GetAgentKWKPublicKey *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey), type))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKey * SOAP_FMAC4 soap_in_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, const char *tag, struct KMS_Agent__GetAgentKWKPublicKey *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__GetAgentKWKPublicKey *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey, sizeof(struct KMS_Agent__GetAgentKWKPublicKey), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__GetAgentKWKPublicKey(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__GetAgentKWKPublicKey *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey, 0, sizeof(struct KMS_Agent__GetAgentKWKPublicKey), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, const struct KMS_Agent__GetAgentKWKPublicKey *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey);
+ if (soap_out_KMS_Agent__GetAgentKWKPublicKey(soap, tag?tag:"KMS-Agent:GetAgentKWKPublicKey", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKey * SOAP_FMAC4 soap_get_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, struct KMS_Agent__GetAgentKWKPublicKey *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__GetAgentKWKPublicKey(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__GetAgentKWKPublicKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__GetAgentKWKPublicKey(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__GetAgentKWKPublicKey);
+ if (size)
+ *size = sizeof(struct KMS_Agent__GetAgentKWKPublicKey);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__GetAgentKWKPublicKey[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__GetAgentKWKPublicKey);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__GetAgentKWKPublicKey*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__GetAgentKWKPublicKey %p -> %p\n", q, p));
+ *(struct KMS_Agent__GetAgentKWKPublicKey*)p = *(struct KMS_Agent__GetAgentKWKPublicKey*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, struct KMS_Agent__GetAgentKWKPublicKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__hexBinary(soap, &a->KWKPublicKey);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, const struct KMS_Agent__GetAgentKWKPublicKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->KWKPublicKey, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ soap_serialize_xsd__hexBinary(soap, &a->KWKPublicKey);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__GetAgentKWKPublicKeyResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse), type))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "KWKPublicKey", -1, &a->KWKPublicKey, "xsd:hexBinary"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, const char *tag, struct KMS_Agent__GetAgentKWKPublicKeyResponse *a, const char *type)
+{
+ size_t soap_flag_KWKPublicKey = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__GetAgentKWKPublicKeyResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse, sizeof(struct KMS_Agent__GetAgentKWKPublicKeyResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KWKPublicKey && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "KWKPublicKey", &a->KWKPublicKey, "xsd:hexBinary"))
+ { soap_flag_KWKPublicKey--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__GetAgentKWKPublicKeyResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse, 0, sizeof(struct KMS_Agent__GetAgentKWKPublicKeyResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_KWKPublicKey > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, const struct KMS_Agent__GetAgentKWKPublicKeyResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse);
+ if (soap_out_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, tag?tag:"KMS-Agent:GetAgentKWKPublicKeyResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, struct KMS_Agent__GetAgentKWKPublicKeyResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__GetAgentKWKPublicKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__GetAgentKWKPublicKeyResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__GetAgentKWKPublicKeyResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__GetAgentKWKPublicKeyResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__GetAgentKWKPublicKeyResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__GetAgentKWKPublicKeyResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__GetAgentKWKPublicKeyResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__GetAgentKWKPublicKeyResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__GetAgentKWKPublicKeyResponse*)p = *(struct KMS_Agent__GetAgentKWKPublicKeyResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateAuditLog(struct soap *soap, struct KMS_Agent__CreateAuditLog *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__AuditLogRetention(soap, &a->Retention);
+ soap_default_KMS_Agent__AuditLogCondition(soap, &a->Condition);
+ soap_default_xsd__boolean(soap, &a->IssueAlert);
+ soap_default_xsd__string(soap, &a->Message);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateAuditLog(struct soap *soap, const struct KMS_Agent__CreateAuditLog *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->Message);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateAuditLog(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateAuditLog *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__AuditLogRetention(soap, "Retention", -1, &a->Retention, "KMS-Agent:AuditLogRetention"))
+ return soap->error;
+ if (soap_out_KMS_Agent__AuditLogCondition(soap, "Condition", -1, &a->Condition, "KMS-Agent:AuditLogCondition"))
+ return soap->error;
+ if (soap_out_xsd__boolean(soap, "IssueAlert", -1, &a->IssueAlert, "xsd:boolean"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "Message", -1, &a->Message, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLog * SOAP_FMAC4 soap_in_KMS_Agent__CreateAuditLog(struct soap *soap, const char *tag, struct KMS_Agent__CreateAuditLog *a, const char *type)
+{
+ size_t soap_flag_Retention = 1;
+ size_t soap_flag_Condition = 1;
+ size_t soap_flag_IssueAlert = 1;
+ size_t soap_flag_Message = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateAuditLog *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog, sizeof(struct KMS_Agent__CreateAuditLog), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateAuditLog(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Retention && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__AuditLogRetention(soap, "Retention", &a->Retention, "KMS-Agent:AuditLogRetention"))
+ { soap_flag_Retention--;
+ continue;
+ }
+ if (soap_flag_Condition && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__AuditLogCondition(soap, "Condition", &a->Condition, "KMS-Agent:AuditLogCondition"))
+ { soap_flag_Condition--;
+ continue;
+ }
+ if (soap_flag_IssueAlert && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__boolean(soap, "IssueAlert", &a->IssueAlert, "xsd:boolean"))
+ { soap_flag_IssueAlert--;
+ continue;
+ }
+ if (soap_flag_Message && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "Message", &a->Message, "xsd:string"))
+ { soap_flag_Message--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateAuditLog *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog, 0, sizeof(struct KMS_Agent__CreateAuditLog), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Retention > 0 || soap_flag_Condition > 0 || soap_flag_IssueAlert > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateAuditLog(struct soap *soap, const struct KMS_Agent__CreateAuditLog *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog);
+ if (soap_out_KMS_Agent__CreateAuditLog(soap, tag?tag:"KMS-Agent:CreateAuditLog", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLog * SOAP_FMAC4 soap_get_KMS_Agent__CreateAuditLog(struct soap *soap, struct KMS_Agent__CreateAuditLog *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateAuditLog(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateAuditLog * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateAuditLog(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateAuditLog(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateAuditLog);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateAuditLog);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateAuditLog[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateAuditLog);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateAuditLog*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateAuditLog(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateAuditLog %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateAuditLog*)p = *(struct KMS_Agent__CreateAuditLog*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateAuditLogResponse(struct soap *soap, struct KMS_Agent__CreateAuditLogResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ /* transient _ skipped */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateAuditLogResponse(struct soap *soap, const struct KMS_Agent__CreateAuditLogResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ /* transient _ skipped */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateAuditLogResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateAuditLogResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse), type))
+ return soap->error;
+ /* transient _ skipped */
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLogResponse * SOAP_FMAC4 soap_in_KMS_Agent__CreateAuditLogResponse(struct soap *soap, const char *tag, struct KMS_Agent__CreateAuditLogResponse *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateAuditLogResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse, sizeof(struct KMS_Agent__CreateAuditLogResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateAuditLogResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ /* transient _ skipped */
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateAuditLogResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse, 0, sizeof(struct KMS_Agent__CreateAuditLogResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateAuditLogResponse(struct soap *soap, const struct KMS_Agent__CreateAuditLogResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse);
+ if (soap_out_KMS_Agent__CreateAuditLogResponse(soap, tag?tag:"KMS-Agent:CreateAuditLogResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLogResponse * SOAP_FMAC4 soap_get_KMS_Agent__CreateAuditLogResponse(struct soap *soap, struct KMS_Agent__CreateAuditLogResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateAuditLogResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateAuditLogResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateAuditLogResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateAuditLogResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateAuditLogResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateAuditLogResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateAuditLogResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateAuditLogResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateAuditLogResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateAuditLogResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateAuditLogResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateAuditLogResponse*)p = *(struct KMS_Agent__CreateAuditLogResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKey2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+ soap_default_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKey2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+ soap_serialize_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveProtectAndProcessKey2 *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "AgentKWKID", -1, &a->AgentKWKID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2 * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveProtectAndProcessKey2 *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ size_t soap_flag_AgentKWKID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveProtectAndProcessKey2 *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveProtectAndProcessKey2(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap_flag_AgentKWKID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "AgentKWKID", &a->AgentKWKID, "xsd:string"))
+ { soap_flag_AgentKWKID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveProtectAndProcessKey2 *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2, 0, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKey2 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2);
+ if (soap_out_KMS_Agent__RetrieveProtectAndProcessKey2(soap, tag?tag:"KMS-Agent:RetrieveProtectAndProcessKey2", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2 * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKey2 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveProtectAndProcessKey2(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKey2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKey2);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKey2[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveProtectAndProcessKey2*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveProtectAndProcessKey2 %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveProtectAndProcessKey2*)p = *(struct KMS_Agent__RetrieveProtectAndProcessKey2*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKey2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__Key(soap, "Key", -1, &a->Key, "KMS-Agent:Key"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2Response * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveProtectAndProcessKey2Response *a, const char *type)
+{
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveProtectAndProcessKey2Response *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2Response), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__Key(soap, "Key", &a->Key, "KMS-Agent:Key"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveProtectAndProcessKey2Response *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response, 0, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2Response), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response);
+ if (soap_out_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, tag?tag:"KMS-Agent:RetrieveProtectAndProcessKey2Response", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2Response * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKey2Response *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKey2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2Response(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKey2Response);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2Response);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKey2Response[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey2Response);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveProtectAndProcessKey2Response*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveProtectAndProcessKey2Response %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveProtectAndProcessKey2Response*)p = *(struct KMS_Agent__RetrieveProtectAndProcessKey2Response*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveProtectAndProcessKey *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveProtectAndProcessKey *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveProtectAndProcessKey *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveProtectAndProcessKey(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveProtectAndProcessKey *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey, 0, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKey *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey);
+ if (soap_out_KMS_Agent__RetrieveProtectAndProcessKey(soap, tag?tag:"KMS-Agent:RetrieveProtectAndProcessKey", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKey *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveProtectAndProcessKey(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKey);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKey[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveProtectAndProcessKey);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveProtectAndProcessKey*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveProtectAndProcessKey %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveProtectAndProcessKey*)p = *(struct KMS_Agent__RetrieveProtectAndProcessKey*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__Key(soap, "Key", -1, &a->Key, "KMS-Agent:Key"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *a, const char *type)
+{
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__Key(soap, "Key", &a->Key, "KMS-Agent:Key"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse, 0, sizeof(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse);
+ if (soap_out_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, tag?tag:"KMS-Agent:RetrieveProtectAndProcessKeyResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKeyResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveProtectAndProcessKeyResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveProtectAndProcessKeyResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse*)p = *(struct KMS_Agent__RetrieveProtectAndProcessKeyResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeys2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__int(soap, &a->PageSize);
+ soap_default_xsd__int(soap, &a->PageOffset);
+ soap_default_xsd__string(soap, &a->KeyID);
+ soap_default_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeys2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyID);
+ soap_serialize_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitKeys2 *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "PageSize", -1, &a->PageSize, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "PageOffset", -1, &a->PageOffset, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyID", -1, &a->KeyID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "AgentKWKID", -1, &a->AgentKWKID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2 * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitKeys2 *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_PageSize = 1;
+ size_t soap_flag_PageOffset = 1;
+ size_t soap_flag_KeyID = 1;
+ size_t soap_flag_AgentKWKID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitKeys2 *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2, sizeof(struct KMS_Agent__RetrieveDataUnitKeys2), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitKeys2(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_PageSize && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "PageSize", &a->PageSize, "xsd:int"))
+ { soap_flag_PageSize--;
+ continue;
+ }
+ if (soap_flag_PageOffset && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "PageOffset", &a->PageOffset, "xsd:int"))
+ { soap_flag_PageOffset--;
+ continue;
+ }
+ if (soap_flag_KeyID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyID", &a->KeyID, "xsd:string"))
+ { soap_flag_KeyID--;
+ continue;
+ }
+ if (soap_flag_AgentKWKID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "AgentKWKID", &a->AgentKWKID, "xsd:string"))
+ { soap_flag_AgentKWKID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitKeys2 *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2, 0, sizeof(struct KMS_Agent__RetrieveDataUnitKeys2), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0 || soap_flag_PageSize > 0 || soap_flag_PageOffset > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeys2 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2);
+ if (soap_out_KMS_Agent__RetrieveDataUnitKeys2(soap, tag?tag:"KMS-Agent:RetrieveDataUnitKeys2", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2 * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeys2 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitKeys2(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeys2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeys2);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitKeys2);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeys2[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitKeys2);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitKeys2*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitKeys2 %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitKeys2*)p = *(struct KMS_Agent__RetrieveDataUnitKeys2*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeys2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__long(soap, &a->KeysRemaining);
+ soap_default_KMS_Agent__ArrayOfKeys(soap, &a->Keys);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeys2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__ArrayOfKeys(soap, &a->Keys);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitKeys2Response *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response), type))
+ return soap->error;
+ if (soap_out_xsd__long(soap, "KeysRemaining", -1, &a->KeysRemaining, "xsd:long"))
+ return soap->error;
+ if (soap_out_KMS_Agent__ArrayOfKeys(soap, "Keys", -1, &a->Keys, "KMS-Agent:ArrayOfKeys"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2Response * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitKeys2Response *a, const char *type)
+{
+ size_t soap_flag_KeysRemaining = 1;
+ size_t soap_flag_Keys = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitKeys2Response *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response, sizeof(struct KMS_Agent__RetrieveDataUnitKeys2Response), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitKeys2Response(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeysRemaining && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__long(soap, "KeysRemaining", &a->KeysRemaining, "xsd:long"))
+ { soap_flag_KeysRemaining--;
+ continue;
+ }
+ if (soap_flag_Keys && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__ArrayOfKeys(soap, "Keys", &a->Keys, "KMS-Agent:ArrayOfKeys"))
+ { soap_flag_Keys--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitKeys2Response *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response, 0, sizeof(struct KMS_Agent__RetrieveDataUnitKeys2Response), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_KeysRemaining > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeys2Response *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response);
+ if (soap_out_KMS_Agent__RetrieveDataUnitKeys2Response(soap, tag?tag:"KMS-Agent:RetrieveDataUnitKeys2Response", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2Response * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeys2Response *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitKeys2Response(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeys2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2Response(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeys2Response);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitKeys2Response);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeys2Response[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitKeys2Response);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitKeys2Response*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitKeys2Response %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitKeys2Response*)p = *(struct KMS_Agent__RetrieveDataUnitKeys2Response*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeys *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__int(soap, &a->PageSize);
+ soap_default_xsd__int(soap, &a->PageOffset);
+ soap_default_xsd__string(soap, &a->KeyID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeys *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitKeys *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "PageSize", -1, &a->PageSize, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "PageOffset", -1, &a->PageOffset, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyID", -1, &a->KeyID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitKeys *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_PageSize = 1;
+ size_t soap_flag_PageOffset = 1;
+ size_t soap_flag_KeyID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitKeys *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys, sizeof(struct KMS_Agent__RetrieveDataUnitKeys), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitKeys(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_PageSize && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "PageSize", &a->PageSize, "xsd:int"))
+ { soap_flag_PageSize--;
+ continue;
+ }
+ if (soap_flag_PageOffset && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "PageOffset", &a->PageOffset, "xsd:int"))
+ { soap_flag_PageOffset--;
+ continue;
+ }
+ if (soap_flag_KeyID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyID", &a->KeyID, "xsd:string"))
+ { soap_flag_KeyID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitKeys *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys, 0, sizeof(struct KMS_Agent__RetrieveDataUnitKeys), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0 || soap_flag_PageSize > 0 || soap_flag_PageOffset > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeys *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys);
+ if (soap_out_KMS_Agent__RetrieveDataUnitKeys(soap, tag?tag:"KMS-Agent:RetrieveDataUnitKeys", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeys *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitKeys(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeys * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitKeys(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeys);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitKeys);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeys[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitKeys);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitKeys*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitKeys %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitKeys*)p = *(struct KMS_Agent__RetrieveDataUnitKeys*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeysResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__long(soap, &a->KeysRemaining);
+ soap_default_KMS_Agent__ArrayOfKeys(soap, &a->Keys);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeysResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__ArrayOfKeys(soap, &a->Keys);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitKeysResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse), type))
+ return soap->error;
+ if (soap_out_xsd__long(soap, "KeysRemaining", -1, &a->KeysRemaining, "xsd:long"))
+ return soap->error;
+ if (soap_out_KMS_Agent__ArrayOfKeys(soap, "Keys", -1, &a->Keys, "KMS-Agent:ArrayOfKeys"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeysResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitKeysResponse *a, const char *type)
+{
+ size_t soap_flag_KeysRemaining = 1;
+ size_t soap_flag_Keys = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitKeysResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse, sizeof(struct KMS_Agent__RetrieveDataUnitKeysResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitKeysResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeysRemaining && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__long(soap, "KeysRemaining", &a->KeysRemaining, "xsd:long"))
+ { soap_flag_KeysRemaining--;
+ continue;
+ }
+ if (soap_flag_Keys && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__ArrayOfKeys(soap, "Keys", &a->Keys, "KMS-Agent:ArrayOfKeys"))
+ { soap_flag_Keys--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitKeysResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse, 0, sizeof(struct KMS_Agent__RetrieveDataUnitKeysResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_KeysRemaining > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitKeysResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse);
+ if (soap_out_KMS_Agent__RetrieveDataUnitKeysResponse(soap, tag?tag:"KMS-Agent:RetrieveDataUnitKeysResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeysResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, struct KMS_Agent__RetrieveDataUnitKeysResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitKeysResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeysResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitKeysResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeysResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitKeysResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitKeysResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitKeysResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitKeysResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitKeysResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitKeysResponse*)p = *(struct KMS_Agent__RetrieveDataUnitKeysResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKey2(struct soap *soap, struct KMS_Agent__RetrieveKey2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->KeyID);
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+ soap_default_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKey2(struct soap *soap, const struct KMS_Agent__RetrieveKey2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->KeyID);
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+ soap_serialize_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKey2(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveKey2 *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyID", -1, &a->KeyID, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "AgentKWKID", -1, &a->AgentKWKID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2 * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKey2(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveKey2 *a, const char *type)
+{
+ size_t soap_flag_KeyID = 1;
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ size_t soap_flag_AgentKWKID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveKey2 *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2, sizeof(struct KMS_Agent__RetrieveKey2), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveKey2(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeyID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyID", &a->KeyID, "xsd:string"))
+ { soap_flag_KeyID--;
+ continue;
+ }
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap_flag_AgentKWKID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "AgentKWKID", &a->AgentKWKID, "xsd:string"))
+ { soap_flag_AgentKWKID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveKey2 *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2, 0, sizeof(struct KMS_Agent__RetrieveKey2), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKey2(struct soap *soap, const struct KMS_Agent__RetrieveKey2 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2);
+ if (soap_out_KMS_Agent__RetrieveKey2(soap, tag?tag:"KMS-Agent:RetrieveKey2", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2 * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKey2(struct soap *soap, struct KMS_Agent__RetrieveKey2 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveKey2(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKey2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKey2(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveKey2(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKey2);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveKey2);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKey2[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveKey2);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveKey2*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKey2(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveKey2 %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveKey2*)p = *(struct KMS_Agent__RetrieveKey2*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKey2Response(struct soap *soap, struct KMS_Agent__RetrieveKey2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKey2Response(struct soap *soap, const struct KMS_Agent__RetrieveKey2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKey2Response(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveKey2Response *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__Key(soap, "Key", -1, &a->Key, "KMS-Agent:Key"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2Response * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKey2Response(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveKey2Response *a, const char *type)
+{
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveKey2Response *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response, sizeof(struct KMS_Agent__RetrieveKey2Response), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveKey2Response(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__Key(soap, "Key", &a->Key, "KMS-Agent:Key"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveKey2Response *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response, 0, sizeof(struct KMS_Agent__RetrieveKey2Response), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKey2Response(struct soap *soap, const struct KMS_Agent__RetrieveKey2Response *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response);
+ if (soap_out_KMS_Agent__RetrieveKey2Response(soap, tag?tag:"KMS-Agent:RetrieveKey2Response", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2Response * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKey2Response(struct soap *soap, struct KMS_Agent__RetrieveKey2Response *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveKey2Response(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKey2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKey2Response(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveKey2Response(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKey2Response);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveKey2Response);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKey2Response[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveKey2Response);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveKey2Response*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKey2Response(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveKey2Response %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveKey2Response*)p = *(struct KMS_Agent__RetrieveKey2Response*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKey(struct soap *soap, struct KMS_Agent__RetrieveKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->KeyID);
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKey(struct soap *soap, const struct KMS_Agent__RetrieveKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->KeyID);
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKey(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveKey *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyID", -1, &a->KeyID, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKey(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveKey *a, const char *type)
+{
+ size_t soap_flag_KeyID = 1;
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveKey *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey, sizeof(struct KMS_Agent__RetrieveKey), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveKey(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeyID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyID", &a->KeyID, "xsd:string"))
+ { soap_flag_KeyID--;
+ continue;
+ }
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveKey *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey, 0, sizeof(struct KMS_Agent__RetrieveKey), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKey(struct soap *soap, const struct KMS_Agent__RetrieveKey *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey);
+ if (soap_out_KMS_Agent__RetrieveKey(soap, tag?tag:"KMS-Agent:RetrieveKey", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKey(struct soap *soap, struct KMS_Agent__RetrieveKey *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveKey(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKey(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveKey(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKey);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveKey);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKey[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveKey);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveKey*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKey(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveKey %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveKey*)p = *(struct KMS_Agent__RetrieveKey*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKeyResponse(struct soap *soap, struct KMS_Agent__RetrieveKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKeyResponse(struct soap *soap, const struct KMS_Agent__RetrieveKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKeyResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveKeyResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__Key(soap, "Key", -1, &a->Key, "KMS-Agent:Key"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKeyResponse(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveKeyResponse *a, const char *type)
+{
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveKeyResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse, sizeof(struct KMS_Agent__RetrieveKeyResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveKeyResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__Key(soap, "Key", &a->Key, "KMS-Agent:Key"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveKeyResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse, 0, sizeof(struct KMS_Agent__RetrieveKeyResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKeyResponse(struct soap *soap, const struct KMS_Agent__RetrieveKeyResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse);
+ if (soap_out_KMS_Agent__RetrieveKeyResponse(soap, tag?tag:"KMS-Agent:RetrieveKeyResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKeyResponse(struct soap *soap, struct KMS_Agent__RetrieveKeyResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveKeyResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKeyResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveKeyResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKeyResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveKeyResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveKeyResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveKeyResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveKeyResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKeyResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveKeyResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveKeyResponse*)p = *(struct KMS_Agent__RetrieveKeyResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKey2(struct soap *soap, struct KMS_Agent__CreateKey2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+ soap_default_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKey2(struct soap *soap, const struct KMS_Agent__CreateKey2 *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+ soap_serialize_xsd__string(soap, &a->AgentKWKID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKey2(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateKey2 *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "AgentKWKID", -1, &a->AgentKWKID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey2 * SOAP_FMAC4 soap_in_KMS_Agent__CreateKey2(struct soap *soap, const char *tag, struct KMS_Agent__CreateKey2 *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ size_t soap_flag_AgentKWKID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateKey2 *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2, sizeof(struct KMS_Agent__CreateKey2), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateKey2(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap_flag_AgentKWKID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "AgentKWKID", &a->AgentKWKID, "xsd:string"))
+ { soap_flag_AgentKWKID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateKey2 *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2, 0, sizeof(struct KMS_Agent__CreateKey2), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKey2(struct soap *soap, const struct KMS_Agent__CreateKey2 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2);
+ if (soap_out_KMS_Agent__CreateKey2(soap, tag?tag:"KMS-Agent:CreateKey2", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey2 * SOAP_FMAC4 soap_get_KMS_Agent__CreateKey2(struct soap *soap, struct KMS_Agent__CreateKey2 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateKey2(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateKey2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKey2(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateKey2(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKey2);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateKey2);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKey2[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateKey2);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateKey2*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKey2(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateKey2 %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateKey2*)p = *(struct KMS_Agent__CreateKey2*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKey2Response(struct soap *soap, struct KMS_Agent__CreateKey2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKey2Response(struct soap *soap, const struct KMS_Agent__CreateKey2Response *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKey2Response(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateKey2Response *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__Key(soap, "Key", -1, &a->Key, "KMS-Agent:Key"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey2Response * SOAP_FMAC4 soap_in_KMS_Agent__CreateKey2Response(struct soap *soap, const char *tag, struct KMS_Agent__CreateKey2Response *a, const char *type)
+{
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateKey2Response *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response, sizeof(struct KMS_Agent__CreateKey2Response), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateKey2Response(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__Key(soap, "Key", &a->Key, "KMS-Agent:Key"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateKey2Response *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response, 0, sizeof(struct KMS_Agent__CreateKey2Response), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKey2Response(struct soap *soap, const struct KMS_Agent__CreateKey2Response *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response);
+ if (soap_out_KMS_Agent__CreateKey2Response(soap, tag?tag:"KMS-Agent:CreateKey2Response", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey2Response * SOAP_FMAC4 soap_get_KMS_Agent__CreateKey2Response(struct soap *soap, struct KMS_Agent__CreateKey2Response *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateKey2Response(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateKey2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKey2Response(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateKey2Response(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKey2Response);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateKey2Response);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKey2Response[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateKey2Response);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateKey2Response*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKey2Response(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateKey2Response %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateKey2Response*)p = *(struct KMS_Agent__CreateKey2Response*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKey(struct soap *soap, struct KMS_Agent__CreateKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKey(struct soap *soap, const struct KMS_Agent__CreateKey *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKey(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateKey *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey * SOAP_FMAC4 soap_in_KMS_Agent__CreateKey(struct soap *soap, const char *tag, struct KMS_Agent__CreateKey *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateKey *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey, sizeof(struct KMS_Agent__CreateKey), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateKey(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateKey *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey, 0, sizeof(struct KMS_Agent__CreateKey), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKey(struct soap *soap, const struct KMS_Agent__CreateKey *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey);
+ if (soap_out_KMS_Agent__CreateKey(soap, tag?tag:"KMS-Agent:CreateKey", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey * SOAP_FMAC4 soap_get_KMS_Agent__CreateKey(struct soap *soap, struct KMS_Agent__CreateKey *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateKey(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKey(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateKey(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKey);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateKey);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKey[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateKey);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateKey*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKey(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateKey %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateKey*)p = *(struct KMS_Agent__CreateKey*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKeyResponse(struct soap *soap, struct KMS_Agent__CreateKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKeyResponse(struct soap *soap, const struct KMS_Agent__CreateKeyResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKeyResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateKeyResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__Key(soap, "Key", -1, &a->Key, "KMS-Agent:Key"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__CreateKeyResponse(struct soap *soap, const char *tag, struct KMS_Agent__CreateKeyResponse *a, const char *type)
+{
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateKeyResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse, sizeof(struct KMS_Agent__CreateKeyResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateKeyResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__Key(soap, "Key", &a->Key, "KMS-Agent:Key"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateKeyResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse, 0, sizeof(struct KMS_Agent__CreateKeyResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKeyResponse(struct soap *soap, const struct KMS_Agent__CreateKeyResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse);
+ if (soap_out_KMS_Agent__CreateKeyResponse(soap, tag?tag:"KMS-Agent:CreateKeyResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__CreateKeyResponse(struct soap *soap, struct KMS_Agent__CreateKeyResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateKeyResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKeyResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateKeyResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKeyResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateKeyResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateKeyResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateKeyResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateKeyResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKeyResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateKeyResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateKeyResponse*)p = *(struct KMS_Agent__CreateKeyResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, struct KMS_Agent__DisassociateDataUnitKeys *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, const struct KMS_Agent__DisassociateDataUnitKeys *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, const char *tag, int id, const struct KMS_Agent__DisassociateDataUnitKeys *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeys * SOAP_FMAC4 soap_in_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, const char *tag, struct KMS_Agent__DisassociateDataUnitKeys *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__DisassociateDataUnitKeys *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys, sizeof(struct KMS_Agent__DisassociateDataUnitKeys), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__DisassociateDataUnitKeys(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__DisassociateDataUnitKeys *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys, 0, sizeof(struct KMS_Agent__DisassociateDataUnitKeys), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, const struct KMS_Agent__DisassociateDataUnitKeys *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys);
+ if (soap_out_KMS_Agent__DisassociateDataUnitKeys(soap, tag?tag:"KMS-Agent:DisassociateDataUnitKeys", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeys * SOAP_FMAC4 soap_get_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, struct KMS_Agent__DisassociateDataUnitKeys *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__DisassociateDataUnitKeys(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__DisassociateDataUnitKeys * SOAP_FMAC2 soap_instantiate_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__DisassociateDataUnitKeys(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__DisassociateDataUnitKeys);
+ if (size)
+ *size = sizeof(struct KMS_Agent__DisassociateDataUnitKeys);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__DisassociateDataUnitKeys[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__DisassociateDataUnitKeys);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__DisassociateDataUnitKeys*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__DisassociateDataUnitKeys %p -> %p\n", q, p));
+ *(struct KMS_Agent__DisassociateDataUnitKeys*)p = *(struct KMS_Agent__DisassociateDataUnitKeys*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, struct KMS_Agent__DisassociateDataUnitKeysResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ /* transient _ skipped */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, const struct KMS_Agent__DisassociateDataUnitKeysResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ /* transient _ skipped */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__DisassociateDataUnitKeysResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse), type))
+ return soap->error;
+ /* transient _ skipped */
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeysResponse * SOAP_FMAC4 soap_in_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, const char *tag, struct KMS_Agent__DisassociateDataUnitKeysResponse *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__DisassociateDataUnitKeysResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse, sizeof(struct KMS_Agent__DisassociateDataUnitKeysResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__DisassociateDataUnitKeysResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ /* transient _ skipped */
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__DisassociateDataUnitKeysResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse, 0, sizeof(struct KMS_Agent__DisassociateDataUnitKeysResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, const struct KMS_Agent__DisassociateDataUnitKeysResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse);
+ if (soap_out_KMS_Agent__DisassociateDataUnitKeysResponse(soap, tag?tag:"KMS-Agent:DisassociateDataUnitKeysResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeysResponse * SOAP_FMAC4 soap_get_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, struct KMS_Agent__DisassociateDataUnitKeysResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__DisassociateDataUnitKeysResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__DisassociateDataUnitKeysResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__DisassociateDataUnitKeysResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__DisassociateDataUnitKeysResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__DisassociateDataUnitKeysResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__DisassociateDataUnitKeysResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__DisassociateDataUnitKeysResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__DisassociateDataUnitKeysResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__DisassociateDataUnitKeysResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__DisassociateDataUnitKeysResponse*)p = *(struct KMS_Agent__DisassociateDataUnitKeysResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->ExternalUniqueID);
+ soap_default_xsd__string(soap, &a->ExternalTag);
+ soap_default_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->ExternalUniqueID);
+ soap_serialize_xsd__string(soap, &a->ExternalTag);
+ soap_serialize_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalUniqueID", -1, &a->ExternalUniqueID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalTag", -1, &a->ExternalTag, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "Description", -1, &a->Description, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueID * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *a, const char *type)
+{
+ size_t soap_flag_ExternalUniqueID = 1;
+ size_t soap_flag_ExternalTag = 1;
+ size_t soap_flag_Description = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID, sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_ExternalUniqueID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalUniqueID", &a->ExternalUniqueID, "xsd:string"))
+ { soap_flag_ExternalUniqueID--;
+ continue;
+ }
+ if (soap_flag_ExternalTag && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalTag", &a->ExternalTag, "xsd:string"))
+ { soap_flag_ExternalTag--;
+ continue;
+ }
+ if (soap_flag_Description && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "Description", &a->Description, "xsd:string"))
+ { soap_flag_Description--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID, 0, sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID);
+ if (soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, tag?tag:"KMS-Agent:RetrieveDataUnitByExternalUniqueID", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueID * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitByExternalUniqueID * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueID(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitByExternalUniqueID*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitByExternalUniqueID %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID*)p = *(struct KMS_Agent__RetrieveDataUnitByExternalUniqueID*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse, sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse, 0, sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse);
+ if (soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, tag?tag:"KMS-Agent:RetrieveDataUnitByExternalUniqueIDResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse*)p = *(struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnit(struct soap *soap, struct KMS_Agent__RetrieveDataUnit *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->DataUnitID);
+ soap_default_xsd__string(soap, &a->ExternalUniqueID);
+ soap_default_xsd__string(soap, &a->ExternalTag);
+ soap_default_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnit(struct soap *soap, const struct KMS_Agent__RetrieveDataUnit *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->DataUnitID);
+ soap_serialize_xsd__string(soap, &a->ExternalUniqueID);
+ soap_serialize_xsd__string(soap, &a->ExternalTag);
+ soap_serialize_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnit(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnit *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "DataUnitID", -1, &a->DataUnitID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalUniqueID", -1, &a->ExternalUniqueID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalTag", -1, &a->ExternalTag, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "Description", -1, &a->Description, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnit * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnit(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnit *a, const char *type)
+{
+ size_t soap_flag_DataUnitID = 1;
+ size_t soap_flag_ExternalUniqueID = 1;
+ size_t soap_flag_ExternalTag = 1;
+ size_t soap_flag_Description = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnit *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit, sizeof(struct KMS_Agent__RetrieveDataUnit), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnit(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnitID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "DataUnitID", &a->DataUnitID, "xsd:string"))
+ { soap_flag_DataUnitID--;
+ continue;
+ }
+ if (soap_flag_ExternalUniqueID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalUniqueID", &a->ExternalUniqueID, "xsd:string"))
+ { soap_flag_ExternalUniqueID--;
+ continue;
+ }
+ if (soap_flag_ExternalTag && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalTag", &a->ExternalTag, "xsd:string"))
+ { soap_flag_ExternalTag--;
+ continue;
+ }
+ if (soap_flag_Description && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "Description", &a->Description, "xsd:string"))
+ { soap_flag_Description--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnit *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit, 0, sizeof(struct KMS_Agent__RetrieveDataUnit), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnit(struct soap *soap, const struct KMS_Agent__RetrieveDataUnit *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit);
+ if (soap_out_KMS_Agent__RetrieveDataUnit(soap, tag?tag:"KMS-Agent:RetrieveDataUnit", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnit * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnit(struct soap *soap, struct KMS_Agent__RetrieveDataUnit *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnit(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnit * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnit(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnit(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnit);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnit);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnit[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnit);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnit*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnit(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnit %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnit*)p = *(struct KMS_Agent__RetrieveDataUnit*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, struct KMS_Agent__RetrieveDataUnitResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__RetrieveDataUnitResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, const char *tag, struct KMS_Agent__RetrieveDataUnitResponse *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__RetrieveDataUnitResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse, sizeof(struct KMS_Agent__RetrieveDataUnitResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__RetrieveDataUnitResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__RetrieveDataUnitResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse, 0, sizeof(struct KMS_Agent__RetrieveDataUnitResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, const struct KMS_Agent__RetrieveDataUnitResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse);
+ if (soap_out_KMS_Agent__RetrieveDataUnitResponse(soap, tag?tag:"KMS-Agent:RetrieveDataUnitResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, struct KMS_Agent__RetrieveDataUnitResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__RetrieveDataUnitResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__RetrieveDataUnitResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__RetrieveDataUnitResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__RetrieveDataUnitResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__RetrieveDataUnitResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__RetrieveDataUnitResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__RetrieveDataUnitResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__RetrieveDataUnitResponse*)p = *(struct KMS_Agent__RetrieveDataUnitResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateDataUnit(struct soap *soap, struct KMS_Agent__CreateDataUnit *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->ExternalUniqueID);
+ soap_default_xsd__string(soap, &a->ExternalTag);
+ soap_default_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateDataUnit(struct soap *soap, const struct KMS_Agent__CreateDataUnit *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->ExternalUniqueID);
+ soap_serialize_xsd__string(soap, &a->ExternalTag);
+ soap_serialize_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateDataUnit(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateDataUnit *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalUniqueID", -1, &a->ExternalUniqueID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalTag", -1, &a->ExternalTag, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "Description", -1, &a->Description, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnit * SOAP_FMAC4 soap_in_KMS_Agent__CreateDataUnit(struct soap *soap, const char *tag, struct KMS_Agent__CreateDataUnit *a, const char *type)
+{
+ size_t soap_flag_ExternalUniqueID = 1;
+ size_t soap_flag_ExternalTag = 1;
+ size_t soap_flag_Description = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateDataUnit *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit, sizeof(struct KMS_Agent__CreateDataUnit), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateDataUnit(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_ExternalUniqueID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalUniqueID", &a->ExternalUniqueID, "xsd:string"))
+ { soap_flag_ExternalUniqueID--;
+ continue;
+ }
+ if (soap_flag_ExternalTag && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalTag", &a->ExternalTag, "xsd:string"))
+ { soap_flag_ExternalTag--;
+ continue;
+ }
+ if (soap_flag_Description && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "Description", &a->Description, "xsd:string"))
+ { soap_flag_Description--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateDataUnit *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit, 0, sizeof(struct KMS_Agent__CreateDataUnit), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateDataUnit(struct soap *soap, const struct KMS_Agent__CreateDataUnit *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit);
+ if (soap_out_KMS_Agent__CreateDataUnit(soap, tag?tag:"KMS-Agent:CreateDataUnit", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnit * SOAP_FMAC4 soap_get_KMS_Agent__CreateDataUnit(struct soap *soap, struct KMS_Agent__CreateDataUnit *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateDataUnit(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateDataUnit * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateDataUnit(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateDataUnit(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateDataUnit);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateDataUnit);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateDataUnit[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateDataUnit);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateDataUnit*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateDataUnit(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateDataUnit %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateDataUnit*)p = *(struct KMS_Agent__CreateDataUnit*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateDataUnitResponse(struct soap *soap, struct KMS_Agent__CreateDataUnitResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateDataUnitResponse(struct soap *soap, const struct KMS_Agent__CreateDataUnitResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__DataUnit(soap, &a->DataUnit);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateDataUnitResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__CreateDataUnitResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnit(soap, "DataUnit", -1, &a->DataUnit, "KMS-Agent:DataUnit"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnitResponse * SOAP_FMAC4 soap_in_KMS_Agent__CreateDataUnitResponse(struct soap *soap, const char *tag, struct KMS_Agent__CreateDataUnitResponse *a, const char *type)
+{
+ size_t soap_flag_DataUnit = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__CreateDataUnitResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse, sizeof(struct KMS_Agent__CreateDataUnitResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__CreateDataUnitResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnit && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnit(soap, "DataUnit", &a->DataUnit, "KMS-Agent:DataUnit"))
+ { soap_flag_DataUnit--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__CreateDataUnitResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse, 0, sizeof(struct KMS_Agent__CreateDataUnitResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnit > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateDataUnitResponse(struct soap *soap, const struct KMS_Agent__CreateDataUnitResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse);
+ if (soap_out_KMS_Agent__CreateDataUnitResponse(soap, tag?tag:"KMS-Agent:CreateDataUnitResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnitResponse * SOAP_FMAC4 soap_get_KMS_Agent__CreateDataUnitResponse(struct soap *soap, struct KMS_Agent__CreateDataUnitResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__CreateDataUnitResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__CreateDataUnitResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateDataUnitResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__CreateDataUnitResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateDataUnitResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__CreateDataUnitResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__CreateDataUnitResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__CreateDataUnitResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__CreateDataUnitResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateDataUnitResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__CreateDataUnitResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__CreateDataUnitResponse*)p = *(struct KMS_Agent__CreateDataUnitResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ListKeyGroups(struct soap *soap, struct KMS_Agent__ListKeyGroups *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__QueryParameters(soap, &a->QueryParameters);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ListKeyGroups(struct soap *soap, const struct KMS_Agent__ListKeyGroups *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__QueryParameters(soap, &a->QueryParameters);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ListKeyGroups(struct soap *soap, const char *tag, int id, const struct KMS_Agent__ListKeyGroups *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__QueryParameters(soap, "QueryParameters", -1, &a->QueryParameters, "KMS-Agent:QueryParameters"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroups * SOAP_FMAC4 soap_in_KMS_Agent__ListKeyGroups(struct soap *soap, const char *tag, struct KMS_Agent__ListKeyGroups *a, const char *type)
+{
+ size_t soap_flag_QueryParameters = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__ListKeyGroups *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups, sizeof(struct KMS_Agent__ListKeyGroups), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__ListKeyGroups(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_QueryParameters && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__QueryParameters(soap, "QueryParameters", &a->QueryParameters, "KMS-Agent:QueryParameters"))
+ { soap_flag_QueryParameters--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__ListKeyGroups *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups, 0, sizeof(struct KMS_Agent__ListKeyGroups), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_QueryParameters > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ListKeyGroups(struct soap *soap, const struct KMS_Agent__ListKeyGroups *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups);
+ if (soap_out_KMS_Agent__ListKeyGroups(soap, tag?tag:"KMS-Agent:ListKeyGroups", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroups * SOAP_FMAC4 soap_get_KMS_Agent__ListKeyGroups(struct soap *soap, struct KMS_Agent__ListKeyGroups *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__ListKeyGroups(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__ListKeyGroups * SOAP_FMAC2 soap_instantiate_KMS_Agent__ListKeyGroups(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__ListKeyGroups(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ListKeyGroups);
+ if (size)
+ *size = sizeof(struct KMS_Agent__ListKeyGroups);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ListKeyGroups[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__ListKeyGroups);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__ListKeyGroups*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ListKeyGroups(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__ListKeyGroups %p -> %p\n", q, p));
+ *(struct KMS_Agent__ListKeyGroups*)p = *(struct KMS_Agent__ListKeyGroups*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, struct KMS_Agent__ListKeyGroupsResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_KMS_Agent__ArrayOfKeyGroups(soap, &a->KeyGroups);
+ soap_default_xsd__boolean(soap, &a->LastPage);
+ soap_default_KMS_Agent__QueryParameters(soap, &a->NextPageQueryParameters);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, const struct KMS_Agent__ListKeyGroupsResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_KMS_Agent__ArrayOfKeyGroups(soap, &a->KeyGroups);
+ soap_serialize_KMS_Agent__QueryParameters(soap, &a->NextPageQueryParameters);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, const char *tag, int id, const struct KMS_Agent__ListKeyGroupsResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse), type))
+ return soap->error;
+ if (soap_out_KMS_Agent__ArrayOfKeyGroups(soap, "KeyGroups", -1, &a->KeyGroups, "KMS-Agent:ArrayOfKeyGroups"))
+ return soap->error;
+ if (soap_out_xsd__boolean(soap, "LastPage", -1, &a->LastPage, "xsd:boolean"))
+ return soap->error;
+ if (soap_out_KMS_Agent__QueryParameters(soap, "NextPageQueryParameters", -1, &a->NextPageQueryParameters, "KMS-Agent:QueryParameters"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroupsResponse * SOAP_FMAC4 soap_in_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, const char *tag, struct KMS_Agent__ListKeyGroupsResponse *a, const char *type)
+{
+ size_t soap_flag_KeyGroups = 1;
+ size_t soap_flag_LastPage = 1;
+ size_t soap_flag_NextPageQueryParameters = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__ListKeyGroupsResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse, sizeof(struct KMS_Agent__ListKeyGroupsResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__ListKeyGroupsResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeyGroups && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__ArrayOfKeyGroups(soap, "KeyGroups", &a->KeyGroups, "KMS-Agent:ArrayOfKeyGroups"))
+ { soap_flag_KeyGroups--;
+ continue;
+ }
+ if (soap_flag_LastPage && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__boolean(soap, "LastPage", &a->LastPage, "xsd:boolean"))
+ { soap_flag_LastPage--;
+ continue;
+ }
+ if (soap_flag_NextPageQueryParameters && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__QueryParameters(soap, "NextPageQueryParameters", &a->NextPageQueryParameters, "KMS-Agent:QueryParameters"))
+ { soap_flag_NextPageQueryParameters--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__ListKeyGroupsResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse, 0, sizeof(struct KMS_Agent__ListKeyGroupsResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_LastPage > 0 || soap_flag_NextPageQueryParameters > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, const struct KMS_Agent__ListKeyGroupsResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse);
+ if (soap_out_KMS_Agent__ListKeyGroupsResponse(soap, tag?tag:"KMS-Agent:ListKeyGroupsResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroupsResponse * SOAP_FMAC4 soap_get_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, struct KMS_Agent__ListKeyGroupsResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__ListKeyGroupsResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__ListKeyGroupsResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__ListKeyGroupsResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ListKeyGroupsResponse);
+ if (size)
+ *size = sizeof(struct KMS_Agent__ListKeyGroupsResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ListKeyGroupsResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__ListKeyGroupsResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__ListKeyGroupsResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ListKeyGroupsResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__ListKeyGroupsResponse %p -> %p\n", q, p));
+ *(struct KMS_Agent__ListKeyGroupsResponse*)p = *(struct KMS_Agent__ListKeyGroupsResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DataUnit(struct soap *soap, struct KMS_Agent__DataUnit *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->DataUnitID);
+ soap_default_xsd__string(soap, &a->ExternalUniqueID);
+ soap_default_xsd__string(soap, &a->ExternalTag);
+ soap_default_xsd__string(soap, &a->Description);
+ soap_default_KMS_Agent__DataUnitState(soap, &a->DataUnitState);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__DataUnit(struct soap *soap, const struct KMS_Agent__DataUnit *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->DataUnitID);
+ soap_serialize_xsd__string(soap, &a->ExternalUniqueID);
+ soap_serialize_xsd__string(soap, &a->ExternalTag);
+ soap_serialize_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DataUnit(struct soap *soap, const char *tag, int id, const struct KMS_Agent__DataUnit *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "DataUnitID", -1, &a->DataUnitID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalUniqueID", -1, &a->ExternalUniqueID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "ExternalTag", -1, &a->ExternalTag, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "Description", -1, &a->Description, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Agent__DataUnitState(soap, "DataUnitState", -1, &a->DataUnitState, "KMS-Agent:DataUnitState"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__DataUnit * SOAP_FMAC4 soap_in_KMS_Agent__DataUnit(struct soap *soap, const char *tag, struct KMS_Agent__DataUnit *a, const char *type)
+{
+ size_t soap_flag_DataUnitID = 1;
+ size_t soap_flag_ExternalUniqueID = 1;
+ size_t soap_flag_ExternalTag = 1;
+ size_t soap_flag_Description = 1;
+ size_t soap_flag_DataUnitState = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__DataUnit *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit, sizeof(struct KMS_Agent__DataUnit), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__DataUnit(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_DataUnitID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "DataUnitID", &a->DataUnitID, "xsd:string"))
+ { soap_flag_DataUnitID--;
+ continue;
+ }
+ if (soap_flag_ExternalUniqueID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalUniqueID", &a->ExternalUniqueID, "xsd:string"))
+ { soap_flag_ExternalUniqueID--;
+ continue;
+ }
+ if (soap_flag_ExternalTag && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "ExternalTag", &a->ExternalTag, "xsd:string"))
+ { soap_flag_ExternalTag--;
+ continue;
+ }
+ if (soap_flag_Description && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "Description", &a->Description, "xsd:string"))
+ { soap_flag_Description--;
+ continue;
+ }
+ if (soap_flag_DataUnitState && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__DataUnitState(soap, "DataUnitState", &a->DataUnitState, "KMS-Agent:DataUnitState"))
+ { soap_flag_DataUnitState--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__DataUnit *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit, 0, sizeof(struct KMS_Agent__DataUnit), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_DataUnitState > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DataUnit(struct soap *soap, const struct KMS_Agent__DataUnit *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit);
+ if (soap_out_KMS_Agent__DataUnit(soap, tag?tag:"KMS-Agent:DataUnit", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__DataUnit * SOAP_FMAC4 soap_get_KMS_Agent__DataUnit(struct soap *soap, struct KMS_Agent__DataUnit *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__DataUnit(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__DataUnit * SOAP_FMAC2 soap_instantiate_KMS_Agent__DataUnit(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__DataUnit(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__DataUnit);
+ if (size)
+ *size = sizeof(struct KMS_Agent__DataUnit);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__DataUnit[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__DataUnit);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__DataUnit*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__DataUnit(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__DataUnit %p -> %p\n", q, p));
+ *(struct KMS_Agent__DataUnit*)p = *(struct KMS_Agent__DataUnit*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfKeys(struct soap *soap, struct KMS_Agent__ArrayOfKeys *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfKeys(struct soap *soap, struct KMS_Agent__ArrayOfKeys const*a)
+{
+ int i;
+ if (a->__ptr && !soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys))
+ for (i = 0; i < a->__size; i++)
+ { soap_embedded(soap, a->__ptr + i, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ soap_serialize_KMS_Agent__Key(soap, a->__ptr + i);
+ }
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfKeys(struct soap *soap, const char *tag, int id, const struct KMS_Agent__ArrayOfKeys *a, const char *type)
+{
+ int i, n = a->__size;
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ for (i = 0; i < n; i++)
+ {
+ soap_out_KMS_Agent__Key(soap, "item", -1, &a->__ptr[i], "KMS-Agent:Key");
+ }
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeys * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfKeys(struct soap *soap, const char *tag, struct KMS_Agent__ArrayOfKeys *a, const char *type)
+{ int i, j;
+ struct KMS_Agent__Key *p;
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_array(soap, "KMS-Agent:Key") && soap_match_tag(soap, soap->type, type))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct KMS_Agent__ArrayOfKeys *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys, sizeof(struct KMS_Agent__ArrayOfKeys), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__ArrayOfKeys(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__size = soap_getsize(soap->arraySize, soap->arrayOffset, &j);
+ if (a->__size >= 0)
+ { a->__ptr = (struct KMS_Agent__Key *)soap_malloc(soap, sizeof(struct KMS_Agent__Key) * a->__size);
+ for (i = 0; i < a->__size; i++)
+ soap_default_KMS_Agent__Key(soap, a->__ptr+i);
+ for (i = 0; i < a->__size; i++)
+ { soap_peek_element(soap);
+ if (soap->position)
+ { i = soap->positions[0]-j;
+ if (i < 0 || i >= a->__size)
+ { soap->error = SOAP_IOB;
+ return NULL;
+ }
+ }
+ if (!soap_in_KMS_Agent__Key(soap, NULL, a->__ptr + i, "KMS-Agent:Key"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ }
+ else
+ { if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (a->__size = 0; ; a->__size++)
+ { p = (struct KMS_Agent__Key *)soap_push_block(soap, NULL, sizeof(struct KMS_Agent__Key));
+ if (!p)
+ return NULL;
+ soap_default_KMS_Agent__Key(soap, p);
+ if (!soap_in_KMS_Agent__Key(soap, NULL, p, "KMS-Agent:Key"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ soap_pop_block(soap, NULL);
+ a->__ptr = (struct KMS_Agent__Key *)soap_malloc(soap, soap->blist->size);
+ soap_save_block(soap, NULL, (char*)a->__ptr, 1);
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__ArrayOfKeys *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys, 0, sizeof(struct KMS_Agent__ArrayOfKeys), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfKeys(struct soap *soap, const struct KMS_Agent__ArrayOfKeys *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys);
+ if (soap_out_KMS_Agent__ArrayOfKeys(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeys * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfKeys(struct soap *soap, struct KMS_Agent__ArrayOfKeys *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__ArrayOfKeys(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfKeys * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfKeys(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__ArrayOfKeys(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfKeys);
+ if (size)
+ *size = sizeof(struct KMS_Agent__ArrayOfKeys);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfKeys[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__ArrayOfKeys);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__ArrayOfKeys*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfKeys(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__ArrayOfKeys %p -> %p\n", q, p));
+ *(struct KMS_Agent__ArrayOfKeys*)p = *(struct KMS_Agent__ArrayOfKeys*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__Key(struct soap *soap, struct KMS_Agent__Key *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->KeyID);
+ soap_default_KMS_Agent__KeyState(soap, &a->KeyState);
+ soap_default_KMS_Agent__KeyType(soap, &a->KeyType);
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+ soap_default_xsd__hexBinary(soap, &a->Key);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__Key(struct soap *soap, const struct KMS_Agent__Key *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->KeyID);
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+ soap_embedded(soap, &a->Key, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ soap_serialize_xsd__hexBinary(soap, &a->Key);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__Key(struct soap *soap, const char *tag, int id, const struct KMS_Agent__Key *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__Key), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyID", -1, &a->KeyID, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Agent__KeyState(soap, "KeyState", -1, &a->KeyState, "KMS-Agent:KeyState"))
+ return soap->error;
+ if (soap_out_KMS_Agent__KeyType(soap, "KeyType", -1, &a->KeyType, "KMS-Agent:KeyType"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "Key", -1, &a->Key, "xsd:hexBinary"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__Key * SOAP_FMAC4 soap_in_KMS_Agent__Key(struct soap *soap, const char *tag, struct KMS_Agent__Key *a, const char *type)
+{
+ size_t soap_flag_KeyID = 1;
+ size_t soap_flag_KeyState = 1;
+ size_t soap_flag_KeyType = 1;
+ size_t soap_flag_KeyGroupID = 1;
+ size_t soap_flag_Key = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__Key *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__Key, sizeof(struct KMS_Agent__Key), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__Key(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeyID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyID", &a->KeyID, "xsd:string"))
+ { soap_flag_KeyID--;
+ continue;
+ }
+ if (soap_flag_KeyState && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__KeyState(soap, "KeyState", &a->KeyState, "KMS-Agent:KeyState"))
+ { soap_flag_KeyState--;
+ continue;
+ }
+ if (soap_flag_KeyType && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__KeyType(soap, "KeyType", &a->KeyType, "KMS-Agent:KeyType"))
+ { soap_flag_KeyType--;
+ continue;
+ }
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap_flag_Key && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "Key", &a->Key, "xsd:hexBinary"))
+ { soap_flag_Key--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__Key *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__Key, 0, sizeof(struct KMS_Agent__Key), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_KeyState > 0 || soap_flag_KeyType > 0 || soap_flag_Key > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__Key(struct soap *soap, const struct KMS_Agent__Key *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ if (soap_out_KMS_Agent__Key(soap, tag?tag:"KMS-Agent:Key", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__Key * SOAP_FMAC4 soap_get_KMS_Agent__Key(struct soap *soap, struct KMS_Agent__Key *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__Key(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__Key * SOAP_FMAC2 soap_instantiate_KMS_Agent__Key(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__Key(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__Key, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__Key);
+ if (size)
+ *size = sizeof(struct KMS_Agent__Key);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__Key[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__Key);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__Key*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__Key(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__Key %p -> %p\n", q, p));
+ *(struct KMS_Agent__Key*)p = *(struct KMS_Agent__Key*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, struct KMS_Agent__ArrayOfKeyGroups *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, struct KMS_Agent__ArrayOfKeyGroups const*a)
+{
+ int i;
+ if (a->__ptr && !soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups))
+ for (i = 0; i < a->__size; i++)
+ { soap_embedded(soap, a->__ptr + i, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup);
+ soap_serialize_KMS_Agent__KeyGroup(soap, a->__ptr + i);
+ }
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, const char *tag, int id, const struct KMS_Agent__ArrayOfKeyGroups *a, const char *type)
+{
+ int i, n = a->__size;
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ for (i = 0; i < n; i++)
+ {
+ soap_out_KMS_Agent__KeyGroup(soap, "item", -1, &a->__ptr[i], "KMS-Agent:KeyGroup");
+ }
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeyGroups * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, const char *tag, struct KMS_Agent__ArrayOfKeyGroups *a, const char *type)
+{ int i, j;
+ struct KMS_Agent__KeyGroup *p;
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_array(soap, "KMS-Agent:KeyGroup") && soap_match_tag(soap, soap->type, type))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct KMS_Agent__ArrayOfKeyGroups *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups, sizeof(struct KMS_Agent__ArrayOfKeyGroups), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__ArrayOfKeyGroups(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__size = soap_getsize(soap->arraySize, soap->arrayOffset, &j);
+ if (a->__size >= 0)
+ { a->__ptr = (struct KMS_Agent__KeyGroup *)soap_malloc(soap, sizeof(struct KMS_Agent__KeyGroup) * a->__size);
+ for (i = 0; i < a->__size; i++)
+ soap_default_KMS_Agent__KeyGroup(soap, a->__ptr+i);
+ for (i = 0; i < a->__size; i++)
+ { soap_peek_element(soap);
+ if (soap->position)
+ { i = soap->positions[0]-j;
+ if (i < 0 || i >= a->__size)
+ { soap->error = SOAP_IOB;
+ return NULL;
+ }
+ }
+ if (!soap_in_KMS_Agent__KeyGroup(soap, NULL, a->__ptr + i, "KMS-Agent:KeyGroup"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ }
+ else
+ { if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (a->__size = 0; ; a->__size++)
+ { p = (struct KMS_Agent__KeyGroup *)soap_push_block(soap, NULL, sizeof(struct KMS_Agent__KeyGroup));
+ if (!p)
+ return NULL;
+ soap_default_KMS_Agent__KeyGroup(soap, p);
+ if (!soap_in_KMS_Agent__KeyGroup(soap, NULL, p, "KMS-Agent:KeyGroup"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ soap_pop_block(soap, NULL);
+ a->__ptr = (struct KMS_Agent__KeyGroup *)soap_malloc(soap, soap->blist->size);
+ soap_save_block(soap, NULL, (char*)a->__ptr, 1);
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__ArrayOfKeyGroups *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups, 0, sizeof(struct KMS_Agent__ArrayOfKeyGroups), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, const struct KMS_Agent__ArrayOfKeyGroups *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups);
+ if (soap_out_KMS_Agent__ArrayOfKeyGroups(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeyGroups * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, struct KMS_Agent__ArrayOfKeyGroups *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__ArrayOfKeyGroups(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfKeyGroups * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__ArrayOfKeyGroups(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfKeyGroups);
+ if (size)
+ *size = sizeof(struct KMS_Agent__ArrayOfKeyGroups);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfKeyGroups[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__ArrayOfKeyGroups);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__ArrayOfKeyGroups*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfKeyGroups(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__ArrayOfKeyGroups %p -> %p\n", q, p));
+ *(struct KMS_Agent__ArrayOfKeyGroups*)p = *(struct KMS_Agent__ArrayOfKeyGroups*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__KeyGroup(struct soap *soap, struct KMS_Agent__KeyGroup *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->KeyGroupID);
+ soap_default_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__KeyGroup(struct soap *soap, const struct KMS_Agent__KeyGroup *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->KeyGroupID);
+ soap_serialize_xsd__string(soap, &a->Description);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__KeyGroup(struct soap *soap, const char *tag, int id, const struct KMS_Agent__KeyGroup *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KeyGroupID", -1, &a->KeyGroupID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "Description", -1, &a->Description, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__KeyGroup * SOAP_FMAC4 soap_in_KMS_Agent__KeyGroup(struct soap *soap, const char *tag, struct KMS_Agent__KeyGroup *a, const char *type)
+{
+ size_t soap_flag_KeyGroupID = 1;
+ size_t soap_flag_Description = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__KeyGroup *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup, sizeof(struct KMS_Agent__KeyGroup), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__KeyGroup(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KeyGroupID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KeyGroupID", &a->KeyGroupID, "xsd:string"))
+ { soap_flag_KeyGroupID--;
+ continue;
+ }
+ if (soap_flag_Description && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "Description", &a->Description, "xsd:string"))
+ { soap_flag_Description--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__KeyGroup *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup, 0, sizeof(struct KMS_Agent__KeyGroup), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__KeyGroup(struct soap *soap, const struct KMS_Agent__KeyGroup *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup);
+ if (soap_out_KMS_Agent__KeyGroup(soap, tag?tag:"KMS-Agent:KeyGroup", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__KeyGroup * SOAP_FMAC4 soap_get_KMS_Agent__KeyGroup(struct soap *soap, struct KMS_Agent__KeyGroup *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__KeyGroup(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__KeyGroup * SOAP_FMAC2 soap_instantiate_KMS_Agent__KeyGroup(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__KeyGroup(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__KeyGroup);
+ if (size)
+ *size = sizeof(struct KMS_Agent__KeyGroup);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__KeyGroup[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__KeyGroup);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__KeyGroup*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__KeyGroup(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__KeyGroup %p -> %p\n", q, p));
+ *(struct KMS_Agent__KeyGroup*)p = *(struct KMS_Agent__KeyGroup*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__QueryParameters(struct soap *soap, struct KMS_Agent__QueryParameters *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__int(soap, &a->NextPageSize);
+ soap_default_xsd__string(soap, &a->SortFieldName);
+ soap_default_KMS_Agent__SortOrder(soap, &a->SortOrder);
+ soap_default_KMS_Agent__ArrayOfFilterParameters(soap, &a->FilterParameters);
+ soap_default_xsd__string(soap, &a->PreviousPageLastIDValue);
+ soap_default_xsd__string(soap, &a->PreviousPageLastSortFieldValue);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__QueryParameters(struct soap *soap, const struct KMS_Agent__QueryParameters *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->SortFieldName);
+ soap_serialize_KMS_Agent__ArrayOfFilterParameters(soap, &a->FilterParameters);
+ soap_serialize_xsd__string(soap, &a->PreviousPageLastIDValue);
+ soap_serialize_xsd__string(soap, &a->PreviousPageLastSortFieldValue);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__QueryParameters(struct soap *soap, const char *tag, int id, const struct KMS_Agent__QueryParameters *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters), type))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "NextPageSize", -1, &a->NextPageSize, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "SortFieldName", -1, &a->SortFieldName, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Agent__SortOrder(soap, "SortOrder", -1, &a->SortOrder, "KMS-Agent:SortOrder"))
+ return soap->error;
+ if (soap_out_KMS_Agent__ArrayOfFilterParameters(soap, "FilterParameters", -1, &a->FilterParameters, "KMS-Agent:ArrayOfFilterParameters"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "PreviousPageLastIDValue", -1, &a->PreviousPageLastIDValue, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "PreviousPageLastSortFieldValue", -1, &a->PreviousPageLastSortFieldValue, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__QueryParameters * SOAP_FMAC4 soap_in_KMS_Agent__QueryParameters(struct soap *soap, const char *tag, struct KMS_Agent__QueryParameters *a, const char *type)
+{
+ size_t soap_flag_NextPageSize = 1;
+ size_t soap_flag_SortFieldName = 1;
+ size_t soap_flag_SortOrder = 1;
+ size_t soap_flag_FilterParameters = 1;
+ size_t soap_flag_PreviousPageLastIDValue = 1;
+ size_t soap_flag_PreviousPageLastSortFieldValue = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__QueryParameters *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters, sizeof(struct KMS_Agent__QueryParameters), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__QueryParameters(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_NextPageSize && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "NextPageSize", &a->NextPageSize, "xsd:int"))
+ { soap_flag_NextPageSize--;
+ continue;
+ }
+ if (soap_flag_SortFieldName && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "SortFieldName", &a->SortFieldName, "xsd:string"))
+ { soap_flag_SortFieldName--;
+ continue;
+ }
+ if (soap_flag_SortOrder && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__SortOrder(soap, "SortOrder", &a->SortOrder, "KMS-Agent:SortOrder"))
+ { soap_flag_SortOrder--;
+ continue;
+ }
+ if (soap_flag_FilterParameters && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__ArrayOfFilterParameters(soap, "FilterParameters", &a->FilterParameters, "KMS-Agent:ArrayOfFilterParameters"))
+ { soap_flag_FilterParameters--;
+ continue;
+ }
+ if (soap_flag_PreviousPageLastIDValue && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "PreviousPageLastIDValue", &a->PreviousPageLastIDValue, "xsd:string"))
+ { soap_flag_PreviousPageLastIDValue--;
+ continue;
+ }
+ if (soap_flag_PreviousPageLastSortFieldValue && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "PreviousPageLastSortFieldValue", &a->PreviousPageLastSortFieldValue, "xsd:string"))
+ { soap_flag_PreviousPageLastSortFieldValue--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__QueryParameters *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters, 0, sizeof(struct KMS_Agent__QueryParameters), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_NextPageSize > 0 || soap_flag_SortOrder > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__QueryParameters(struct soap *soap, const struct KMS_Agent__QueryParameters *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters);
+ if (soap_out_KMS_Agent__QueryParameters(soap, tag?tag:"KMS-Agent:QueryParameters", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__QueryParameters * SOAP_FMAC4 soap_get_KMS_Agent__QueryParameters(struct soap *soap, struct KMS_Agent__QueryParameters *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__QueryParameters(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__QueryParameters * SOAP_FMAC2 soap_instantiate_KMS_Agent__QueryParameters(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__QueryParameters(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__QueryParameters);
+ if (size)
+ *size = sizeof(struct KMS_Agent__QueryParameters);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__QueryParameters[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__QueryParameters);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__QueryParameters*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__QueryParameters(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__QueryParameters %p -> %p\n", q, p));
+ *(struct KMS_Agent__QueryParameters*)p = *(struct KMS_Agent__QueryParameters*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, struct KMS_Agent__ArrayOfFilterParameters *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, struct KMS_Agent__ArrayOfFilterParameters const*a)
+{
+ int i;
+ if (a->__ptr && !soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters))
+ for (i = 0; i < a->__size; i++)
+ { soap_embedded(soap, a->__ptr + i, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters);
+ soap_serialize_KMS_Agent__FilterParameters(soap, a->__ptr + i);
+ }
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, const char *tag, int id, const struct KMS_Agent__ArrayOfFilterParameters *a, const char *type)
+{
+ int i, n = a->__size;
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ for (i = 0; i < n; i++)
+ {
+ soap_out_KMS_Agent__FilterParameters(soap, "item", -1, &a->__ptr[i], "KMS-Agent:FilterParameters");
+ }
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfFilterParameters * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, const char *tag, struct KMS_Agent__ArrayOfFilterParameters *a, const char *type)
+{ int i, j;
+ struct KMS_Agent__FilterParameters *p;
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_array(soap, "KMS-Agent:FilterParameters") && soap_match_tag(soap, soap->type, type))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct KMS_Agent__ArrayOfFilterParameters *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters, sizeof(struct KMS_Agent__ArrayOfFilterParameters), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__ArrayOfFilterParameters(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__size = soap_getsize(soap->arraySize, soap->arrayOffset, &j);
+ if (a->__size >= 0)
+ { a->__ptr = (struct KMS_Agent__FilterParameters *)soap_malloc(soap, sizeof(struct KMS_Agent__FilterParameters) * a->__size);
+ for (i = 0; i < a->__size; i++)
+ soap_default_KMS_Agent__FilterParameters(soap, a->__ptr+i);
+ for (i = 0; i < a->__size; i++)
+ { soap_peek_element(soap);
+ if (soap->position)
+ { i = soap->positions[0]-j;
+ if (i < 0 || i >= a->__size)
+ { soap->error = SOAP_IOB;
+ return NULL;
+ }
+ }
+ if (!soap_in_KMS_Agent__FilterParameters(soap, NULL, a->__ptr + i, "KMS-Agent:FilterParameters"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ }
+ else
+ { if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (a->__size = 0; ; a->__size++)
+ { p = (struct KMS_Agent__FilterParameters *)soap_push_block(soap, NULL, sizeof(struct KMS_Agent__FilterParameters));
+ if (!p)
+ return NULL;
+ soap_default_KMS_Agent__FilterParameters(soap, p);
+ if (!soap_in_KMS_Agent__FilterParameters(soap, NULL, p, "KMS-Agent:FilterParameters"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ soap_pop_block(soap, NULL);
+ a->__ptr = (struct KMS_Agent__FilterParameters *)soap_malloc(soap, soap->blist->size);
+ soap_save_block(soap, NULL, (char*)a->__ptr, 1);
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__ArrayOfFilterParameters *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters, 0, sizeof(struct KMS_Agent__ArrayOfFilterParameters), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, const struct KMS_Agent__ArrayOfFilterParameters *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters);
+ if (soap_out_KMS_Agent__ArrayOfFilterParameters(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfFilterParameters * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, struct KMS_Agent__ArrayOfFilterParameters *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__ArrayOfFilterParameters(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfFilterParameters * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__ArrayOfFilterParameters(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfFilterParameters);
+ if (size)
+ *size = sizeof(struct KMS_Agent__ArrayOfFilterParameters);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfFilterParameters[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__ArrayOfFilterParameters);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__ArrayOfFilterParameters*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfFilterParameters(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__ArrayOfFilterParameters %p -> %p\n", q, p));
+ *(struct KMS_Agent__ArrayOfFilterParameters*)p = *(struct KMS_Agent__ArrayOfFilterParameters*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__FilterParameters(struct soap *soap, struct KMS_Agent__FilterParameters *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->FieldName);
+ soap_default_KMS_Agent__FilterOperator(soap, &a->FilterOperator);
+ soap_default_xsd__string(soap, &a->FieldValue);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__FilterParameters(struct soap *soap, const struct KMS_Agent__FilterParameters *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->FieldName);
+ soap_serialize_xsd__string(soap, &a->FieldValue);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__FilterParameters(struct soap *soap, const char *tag, int id, const struct KMS_Agent__FilterParameters *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "FieldName", -1, &a->FieldName, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Agent__FilterOperator(soap, "FilterOperator", -1, &a->FilterOperator, "KMS-Agent:FilterOperator"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "FieldValue", -1, &a->FieldValue, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__FilterParameters * SOAP_FMAC4 soap_in_KMS_Agent__FilterParameters(struct soap *soap, const char *tag, struct KMS_Agent__FilterParameters *a, const char *type)
+{
+ size_t soap_flag_FieldName = 1;
+ size_t soap_flag_FilterOperator = 1;
+ size_t soap_flag_FieldValue = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Agent__FilterParameters *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters, sizeof(struct KMS_Agent__FilterParameters), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__FilterParameters(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_FieldName && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "FieldName", &a->FieldName, "xsd:string"))
+ { soap_flag_FieldName--;
+ continue;
+ }
+ if (soap_flag_FilterOperator && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Agent__FilterOperator(soap, "FilterOperator", &a->FilterOperator, "KMS-Agent:FilterOperator"))
+ { soap_flag_FilterOperator--;
+ continue;
+ }
+ if (soap_flag_FieldValue && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "FieldValue", &a->FieldValue, "xsd:string"))
+ { soap_flag_FieldValue--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__FilterParameters *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters, 0, sizeof(struct KMS_Agent__FilterParameters), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_FilterOperator > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__FilterParameters(struct soap *soap, const struct KMS_Agent__FilterParameters *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters);
+ if (soap_out_KMS_Agent__FilterParameters(soap, tag?tag:"KMS-Agent:FilterParameters", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__FilterParameters * SOAP_FMAC4 soap_get_KMS_Agent__FilterParameters(struct soap *soap, struct KMS_Agent__FilterParameters *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__FilterParameters(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__FilterParameters * SOAP_FMAC2 soap_instantiate_KMS_Agent__FilterParameters(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__FilterParameters(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__FilterParameters);
+ if (size)
+ *size = sizeof(struct KMS_Agent__FilterParameters);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__FilterParameters[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__FilterParameters);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__FilterParameters*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__FilterParameters(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__FilterParameters %p -> %p\n", q, p));
+ *(struct KMS_Agent__FilterParameters*)p = *(struct KMS_Agent__FilterParameters*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfHexBinary(struct soap *soap, struct KMS_Agent__ArrayOfHexBinary *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfHexBinary(struct soap *soap, struct KMS_Agent__ArrayOfHexBinary const*a)
+{
+ int i;
+ if (a->__ptr && !soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary))
+ for (i = 0; i < a->__size; i++)
+ { soap_embedded(soap, a->__ptr + i, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ soap_serialize_xsd__hexBinary(soap, a->__ptr + i);
+ }
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfHexBinary(struct soap *soap, const char *tag, int id, const struct KMS_Agent__ArrayOfHexBinary *a, const char *type)
+{
+ int i, n = a->__size;
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ for (i = 0; i < n; i++)
+ {
+ soap_out_xsd__hexBinary(soap, "item", -1, &a->__ptr[i], "xsd:hexBinary");
+ }
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfHexBinary * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfHexBinary(struct soap *soap, const char *tag, struct KMS_Agent__ArrayOfHexBinary *a, const char *type)
+{ int i, j;
+ struct xsd__hexBinary *p;
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_array(soap, "xsd:hexBinary") && soap_match_tag(soap, soap->type, type))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct KMS_Agent__ArrayOfHexBinary *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary, sizeof(struct KMS_Agent__ArrayOfHexBinary), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Agent__ArrayOfHexBinary(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__size = soap_getsize(soap->arraySize, soap->arrayOffset, &j);
+ if (a->__size >= 0)
+ { a->__ptr = (struct xsd__hexBinary *)soap_malloc(soap, sizeof(struct xsd__hexBinary) * a->__size);
+ for (i = 0; i < a->__size; i++)
+ soap_default_xsd__hexBinary(soap, a->__ptr+i);
+ for (i = 0; i < a->__size; i++)
+ { soap_peek_element(soap);
+ if (soap->position)
+ { i = soap->positions[0]-j;
+ if (i < 0 || i >= a->__size)
+ { soap->error = SOAP_IOB;
+ return NULL;
+ }
+ }
+ if (!soap_in_xsd__hexBinary(soap, NULL, a->__ptr + i, "xsd:hexBinary"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ }
+ else
+ { if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (a->__size = 0; ; a->__size++)
+ { p = (struct xsd__hexBinary *)soap_push_block(soap, NULL, sizeof(struct xsd__hexBinary));
+ if (!p)
+ return NULL;
+ soap_default_xsd__hexBinary(soap, p);
+ if (!soap_in_xsd__hexBinary(soap, NULL, p, "xsd:hexBinary"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ soap_pop_block(soap, NULL);
+ a->__ptr = (struct xsd__hexBinary *)soap_malloc(soap, soap->blist->size);
+ soap_save_block(soap, NULL, (char*)a->__ptr, 1);
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__ArrayOfHexBinary *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary, 0, sizeof(struct KMS_Agent__ArrayOfHexBinary), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfHexBinary(struct soap *soap, const struct KMS_Agent__ArrayOfHexBinary *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary);
+ if (soap_out_KMS_Agent__ArrayOfHexBinary(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfHexBinary * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfHexBinary(struct soap *soap, struct KMS_Agent__ArrayOfHexBinary *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Agent__ArrayOfHexBinary(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfHexBinary * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfHexBinary(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Agent__ArrayOfHexBinary(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfHexBinary);
+ if (size)
+ *size = sizeof(struct KMS_Agent__ArrayOfHexBinary);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Agent__ArrayOfHexBinary[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Agent__ArrayOfHexBinary);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Agent__ArrayOfHexBinary*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfHexBinary(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Agent__ArrayOfHexBinary %p -> %p\n", q, p));
+ *(struct KMS_Agent__ArrayOfHexBinary*)p = *(struct KMS_Agent__ArrayOfHexBinary*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary const*a)
+{
+ if (a->__ptr)
+ soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap *soap, const char *tag, int id, const struct xsd__hexBinary *a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ if (soap_puthex(soap, a->__ptr, a->__size))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap *soap, const char *tag, struct xsd__hexBinary *a, const char *type)
+{
+ (void)type; /* appease -Wall -Werror */
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":hexBinary"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct xsd__hexBinary *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Agent_xsd__hexBinary, sizeof(struct xsd__hexBinary), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_xsd__hexBinary(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__ptr = soap_gethex(soap, &a->__size);
+ if ((!a->__ptr && soap->error) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct xsd__hexBinary *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Agent_xsd__hexBinary, 0, sizeof(struct xsd__hexBinary), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap *soap, const struct xsd__hexBinary *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ if (soap_out_xsd__hexBinary(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__hexBinary(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_xsd__hexBinary(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Agent_xsd__hexBinary, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary);
+ if (size)
+ *size = sizeof(struct xsd__hexBinary);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct xsd__hexBinary);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct xsd__hexBinary*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct xsd__hexBinary %p -> %p\n", q, p));
+ *(struct xsd__hexBinary*)p = *(struct xsd__hexBinary*)q;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason))
+ soap_serialize_SOAP_ENV__Reason(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Reason *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Reason(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Reason **)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Reason(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Reason);
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail))
+ soap_serialize_SOAP_ENV__Detail(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Detail *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Detail(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Detail **)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Detail(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Detail);
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code))
+ soap_serialize_SOAP_ENV__Code(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Code *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Code(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Code **)soap_malloc(soap, sizeof(struct SOAP_ENV__Code *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Code(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Code);
+ if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Agent__Key(struct soap *soap, struct KMS_Agent__Key *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_KMS_Agent__Key))
+ soap_serialize_KMS_Agent__Key(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Agent__Key(struct soap *soap, const char *tag, int id, struct KMS_Agent__Key *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_KMS_Agent__Key);
+ if (id < 0)
+ return soap->error;
+ return soap_out_KMS_Agent__Key(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct KMS_Agent__Key ** SOAP_FMAC4 soap_in_PointerToKMS_Agent__Key(struct soap *soap, const char *tag, struct KMS_Agent__Key **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct KMS_Agent__Key **)soap_malloc(soap, sizeof(struct KMS_Agent__Key *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_KMS_Agent__Key(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__Key **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_KMS_Agent__Key, sizeof(struct KMS_Agent__Key), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Agent__Key(struct soap *soap, struct KMS_Agent__Key *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__Key);
+ if (soap_out_PointerToKMS_Agent__Key(soap, tag?tag:"KMS-Agent:Key", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__Key ** SOAP_FMAC4 soap_get_PointerToKMS_Agent__Key(struct soap *soap, struct KMS_Agent__Key **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToKMS_Agent__Key(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Agent__KeyGroup(struct soap *soap, struct KMS_Agent__KeyGroup *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup))
+ soap_serialize_KMS_Agent__KeyGroup(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Agent__KeyGroup(struct soap *soap, const char *tag, int id, struct KMS_Agent__KeyGroup *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup);
+ if (id < 0)
+ return soap->error;
+ return soap_out_KMS_Agent__KeyGroup(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct KMS_Agent__KeyGroup ** SOAP_FMAC4 soap_in_PointerToKMS_Agent__KeyGroup(struct soap *soap, const char *tag, struct KMS_Agent__KeyGroup **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct KMS_Agent__KeyGroup **)soap_malloc(soap, sizeof(struct KMS_Agent__KeyGroup *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_KMS_Agent__KeyGroup(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__KeyGroup **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup, sizeof(struct KMS_Agent__KeyGroup), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Agent__KeyGroup(struct soap *soap, struct KMS_Agent__KeyGroup *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__KeyGroup);
+ if (soap_out_PointerToKMS_Agent__KeyGroup(soap, tag?tag:"KMS-Agent:KeyGroup", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__KeyGroup ** SOAP_FMAC4 soap_get_PointerToKMS_Agent__KeyGroup(struct soap *soap, struct KMS_Agent__KeyGroup **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToKMS_Agent__KeyGroup(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Agent__FilterParameters(struct soap *soap, struct KMS_Agent__FilterParameters *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters))
+ soap_serialize_KMS_Agent__FilterParameters(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Agent__FilterParameters(struct soap *soap, const char *tag, int id, struct KMS_Agent__FilterParameters *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters);
+ if (id < 0)
+ return soap->error;
+ return soap_out_KMS_Agent__FilterParameters(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct KMS_Agent__FilterParameters ** SOAP_FMAC4 soap_in_PointerToKMS_Agent__FilterParameters(struct soap *soap, const char *tag, struct KMS_Agent__FilterParameters **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct KMS_Agent__FilterParameters **)soap_malloc(soap, sizeof(struct KMS_Agent__FilterParameters *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_KMS_Agent__FilterParameters(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Agent__FilterParameters **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters, sizeof(struct KMS_Agent__FilterParameters), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Agent__FilterParameters(struct soap *soap, struct KMS_Agent__FilterParameters *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__FilterParameters);
+ if (soap_out_PointerToKMS_Agent__FilterParameters(soap, tag?tag:"KMS-Agent:FilterParameters", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Agent__FilterParameters ** SOAP_FMAC4 soap_get_PointerToKMS_Agent__FilterParameters(struct soap *soap, struct KMS_Agent__FilterParameters **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToKMS_Agent__FilterParameters(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToxsd__hexBinary(struct soap *soap, struct xsd__hexBinary *const*a)
+{
+ if (*a)
+ soap_serialize_xsd__hexBinary(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToxsd__hexBinary(struct soap *soap, const char *tag, int id, struct xsd__hexBinary *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, (struct soap_array*)&(*a)->__ptr, 1, type, SOAP_TYPE_KMS_Agent_xsd__hexBinary);
+ if (id < 0)
+ return soap->error;
+ return soap_out_xsd__hexBinary(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary ** SOAP_FMAC4 soap_in_PointerToxsd__hexBinary(struct soap *soap, const char *tag, struct xsd__hexBinary **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct xsd__hexBinary **)soap_malloc(soap, sizeof(struct xsd__hexBinary *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_xsd__hexBinary(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct xsd__hexBinary **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_xsd__hexBinary, sizeof(struct xsd__hexBinary), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToxsd__hexBinary(struct soap *soap, struct xsd__hexBinary *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerToxsd__hexBinary);
+ if (soap_out_PointerToxsd__hexBinary(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary ** SOAP_FMAC4 soap_get_PointerToxsd__hexBinary(struct soap *soap, struct xsd__hexBinary **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToxsd__hexBinary(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap *soap, unsigned char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_unsignedByte);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap *soap, const char *tag, int id, unsigned char *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Agent_unsignedByte);
+ if (id < 0)
+ return soap->error;
+ return soap_out_unsignedByte(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap *soap, const char *tag, unsigned char **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (unsigned char **)soap_malloc(soap, sizeof(unsigned char *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_unsignedByte(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (unsigned char **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Agent_unsignedByte, sizeof(unsigned char), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap *soap, unsigned char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_PointerTounsignedByte);
+ if (soap_out_PointerTounsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap *soap, unsigned char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerTounsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_xsd__duration);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Agent_xsd__duration, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__duration);
+ if (soap_out_xsd__duration(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__duration(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_xsd__dateTime);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Agent_xsd__dateTime, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__dateTime);
+ if (soap_out_xsd__dateTime(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__dateTime(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_xsd__string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Agent_xsd__string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_xsd__string);
+ if (soap_out_xsd__string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent__QName);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Agent__QName, 2, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent__QName);
+ if (soap_out__QName(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in__QName(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap *soap, char **a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_string
+ *a = SOAP_DEFAULT_string;
+#else
+ *a = (char *)0;
+#endif
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_Agent_string);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Agent_string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Agent_string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Agent_string);
+ if (soap_out_string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+} // namespace KMS_Agent
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_AgentC.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentClient.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentClient.cpp
new file mode 100644
index 0000000000..82276f7767
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentClient.cpp
@@ -0,0 +1,847 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_AgentClient.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/AgentService/KMS_Agent_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+#include "KMS_AgentH.h"
+
+namespace KMS_Agent {
+
+SOAP_SOURCE_STAMP("@(#) KMS_AgentClient.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__ListKeyGroups(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__QueryParameters QueryParameters, struct KMS_Agent__ListKeyGroupsResponse &result)
+{ struct KMS_Agent__ListKeyGroups soap_tmp_KMS_Agent__ListKeyGroups;
+ soap_tmp_KMS_Agent__ListKeyGroups.QueryParameters = QueryParameters;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__ListKeyGroups(soap, &soap_tmp_KMS_Agent__ListKeyGroups);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__ListKeyGroups(soap, &soap_tmp_KMS_Agent__ListKeyGroups, "KMS-Agent:ListKeyGroups", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__ListKeyGroups(soap, &soap_tmp_KMS_Agent__ListKeyGroups, "KMS-Agent:ListKeyGroups", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__ListKeyGroupsResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__ListKeyGroupsResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateDataUnit(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__CreateDataUnitResponse &result)
+{ struct KMS_Agent__CreateDataUnit soap_tmp_KMS_Agent__CreateDataUnit;
+ soap_tmp_KMS_Agent__CreateDataUnit.ExternalUniqueID = ExternalUniqueID;
+ soap_tmp_KMS_Agent__CreateDataUnit.ExternalTag = ExternalTag;
+ soap_tmp_KMS_Agent__CreateDataUnit.Description = Description;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__CreateDataUnit(soap, &soap_tmp_KMS_Agent__CreateDataUnit);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateDataUnit(soap, &soap_tmp_KMS_Agent__CreateDataUnit, "KMS-Agent:CreateDataUnit", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateDataUnit(soap, &soap_tmp_KMS_Agent__CreateDataUnit, "KMS-Agent:CreateDataUnit", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__CreateDataUnitResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__CreateDataUnitResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnit(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *DataUnitID, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__RetrieveDataUnitResponse &result)
+{ struct KMS_Agent__RetrieveDataUnit soap_tmp_KMS_Agent__RetrieveDataUnit;
+ soap_tmp_KMS_Agent__RetrieveDataUnit.DataUnitID = DataUnitID;
+ soap_tmp_KMS_Agent__RetrieveDataUnit.ExternalUniqueID = ExternalUniqueID;
+ soap_tmp_KMS_Agent__RetrieveDataUnit.ExternalTag = ExternalTag;
+ soap_tmp_KMS_Agent__RetrieveDataUnit.Description = Description;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveDataUnit(soap, &soap_tmp_KMS_Agent__RetrieveDataUnit);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnit(soap, &soap_tmp_KMS_Agent__RetrieveDataUnit, "KMS-Agent:RetrieveDataUnit", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnit(soap, &soap_tmp_KMS_Agent__RetrieveDataUnit, "KMS-Agent:RetrieveDataUnit", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveDataUnitResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveDataUnitResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse &result)
+{ struct KMS_Agent__RetrieveDataUnitByExternalUniqueID soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID;
+ soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID.ExternalUniqueID = ExternalUniqueID;
+ soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID.ExternalTag = ExternalTag;
+ soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID.Description = Description;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID, "KMS-Agent:RetrieveDataUnitByExternalUniqueID", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitByExternalUniqueID, "KMS-Agent:RetrieveDataUnitByExternalUniqueID", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, struct KMS_Agent__DisassociateDataUnitKeysResponse &result)
+{ struct KMS_Agent__DisassociateDataUnitKeys soap_tmp_KMS_Agent__DisassociateDataUnitKeys;
+ soap_tmp_KMS_Agent__DisassociateDataUnitKeys.DataUnit = DataUnit;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__DisassociateDataUnitKeys(soap, &soap_tmp_KMS_Agent__DisassociateDataUnitKeys);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__DisassociateDataUnitKeys(soap, &soap_tmp_KMS_Agent__DisassociateDataUnitKeys, "KMS-Agent:DisassociateDataUnitKeys", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__DisassociateDataUnitKeys(soap, &soap_tmp_KMS_Agent__DisassociateDataUnitKeys, "KMS-Agent:DisassociateDataUnitKeys", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__DisassociateDataUnitKeysResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__DisassociateDataUnitKeysResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__CreateKeyResponse &result)
+{ struct KMS_Agent__CreateKey soap_tmp_KMS_Agent__CreateKey;
+ soap_tmp_KMS_Agent__CreateKey.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__CreateKey.KeyGroupID = KeyGroupID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__CreateKey(soap, &soap_tmp_KMS_Agent__CreateKey);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateKey(soap, &soap_tmp_KMS_Agent__CreateKey, "KMS-Agent:CreateKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateKey(soap, &soap_tmp_KMS_Agent__CreateKey, "KMS-Agent:CreateKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__CreateKeyResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__CreateKeyResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateKey2(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__CreateKey2Response &result)
+{ struct KMS_Agent__CreateKey2 soap_tmp_KMS_Agent__CreateKey2;
+ soap_tmp_KMS_Agent__CreateKey2.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__CreateKey2.KeyGroupID = KeyGroupID;
+ soap_tmp_KMS_Agent__CreateKey2.AgentKWKID = AgentKWKID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__CreateKey2(soap, &soap_tmp_KMS_Agent__CreateKey2);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateKey2(soap, &soap_tmp_KMS_Agent__CreateKey2, "KMS-Agent:CreateKey2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateKey2(soap, &soap_tmp_KMS_Agent__CreateKey2, "KMS-Agent:CreateKey2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__CreateKey2Response(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__CreateKey2Response(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *KeyID, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__RetrieveKeyResponse &result)
+{ struct KMS_Agent__RetrieveKey soap_tmp_KMS_Agent__RetrieveKey;
+ soap_tmp_KMS_Agent__RetrieveKey.KeyID = KeyID;
+ soap_tmp_KMS_Agent__RetrieveKey.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__RetrieveKey.KeyGroupID = KeyGroupID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveKey(soap, &soap_tmp_KMS_Agent__RetrieveKey);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveKey(soap, &soap_tmp_KMS_Agent__RetrieveKey, "KMS-Agent:RetrieveKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveKey(soap, &soap_tmp_KMS_Agent__RetrieveKey, "KMS-Agent:RetrieveKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveKeyResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveKeyResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveKey2(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *KeyID, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__RetrieveKey2Response &result)
+{ struct KMS_Agent__RetrieveKey2 soap_tmp_KMS_Agent__RetrieveKey2;
+ soap_tmp_KMS_Agent__RetrieveKey2.KeyID = KeyID;
+ soap_tmp_KMS_Agent__RetrieveKey2.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__RetrieveKey2.KeyGroupID = KeyGroupID;
+ soap_tmp_KMS_Agent__RetrieveKey2.AgentKWKID = AgentKWKID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveKey2(soap, &soap_tmp_KMS_Agent__RetrieveKey2);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveKey2(soap, &soap_tmp_KMS_Agent__RetrieveKey2, "KMS-Agent:RetrieveKey2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveKey2(soap, &soap_tmp_KMS_Agent__RetrieveKey2, "KMS-Agent:RetrieveKey2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveKey2Response(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveKey2Response(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, long PageSize, long PageOffset, char *KeyID, struct KMS_Agent__RetrieveDataUnitKeysResponse &result)
+{ struct KMS_Agent__RetrieveDataUnitKeys soap_tmp_KMS_Agent__RetrieveDataUnitKeys;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys.PageSize = PageSize;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys.PageOffset = PageOffset;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys.KeyID = KeyID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveDataUnitKeys(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitKeys);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnitKeys(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitKeys, "KMS-Agent:RetrieveDataUnitKeys", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnitKeys(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitKeys, "KMS-Agent:RetrieveDataUnitKeys", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveDataUnitKeysResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveDataUnitKeysResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, long PageSize, long PageOffset, char *KeyID, char *AgentKWKID, struct KMS_Agent__RetrieveDataUnitKeys2Response &result)
+{ struct KMS_Agent__RetrieveDataUnitKeys2 soap_tmp_KMS_Agent__RetrieveDataUnitKeys2;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys2.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys2.PageSize = PageSize;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys2.PageOffset = PageOffset;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys2.KeyID = KeyID;
+ soap_tmp_KMS_Agent__RetrieveDataUnitKeys2.AgentKWKID = AgentKWKID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveDataUnitKeys2(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitKeys2);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnitKeys2(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitKeys2, "KMS-Agent:RetrieveDataUnitKeys2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveDataUnitKeys2(soap, &soap_tmp_KMS_Agent__RetrieveDataUnitKeys2, "KMS-Agent:RetrieveDataUnitKeys2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveDataUnitKeys2Response(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveDataUnitKeys2Response(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse &result)
+{ struct KMS_Agent__RetrieveProtectAndProcessKey soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey;
+ soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey.KeyGroupID = KeyGroupID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey(soap, &soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveProtectAndProcessKey(soap, &soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey, "KMS-Agent:RetrieveProtectAndProcessKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveProtectAndProcessKey(soap, &soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey, "KMS-Agent:RetrieveProtectAndProcessKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__RetrieveProtectAndProcessKey2Response &result)
+{ struct KMS_Agent__RetrieveProtectAndProcessKey2 soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2;
+ soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2.DataUnit = DataUnit;
+ soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2.KeyGroupID = KeyGroupID;
+ soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2.AgentKWKID = AgentKWKID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2(soap, &soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveProtectAndProcessKey2(soap, &soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2, "KMS-Agent:RetrieveProtectAndProcessKey2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RetrieveProtectAndProcessKey2(soap, &soap_tmp_KMS_Agent__RetrieveProtectAndProcessKey2, "KMS-Agent:RetrieveProtectAndProcessKey2", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateAuditLog(struct soap *soap, const char *soap_endpoint, const char *soap_action, enum KMS_Agent__AuditLogRetention Retention, enum KMS_Agent__AuditLogCondition Condition, bool IssueAlert, char *Message, struct KMS_Agent__CreateAuditLogResponse &result)
+{ struct KMS_Agent__CreateAuditLog soap_tmp_KMS_Agent__CreateAuditLog;
+ soap_tmp_KMS_Agent__CreateAuditLog.Retention = Retention;
+ soap_tmp_KMS_Agent__CreateAuditLog.Condition = Condition;
+ soap_tmp_KMS_Agent__CreateAuditLog.IssueAlert = IssueAlert;
+ soap_tmp_KMS_Agent__CreateAuditLog.Message = Message;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__CreateAuditLog(soap, &soap_tmp_KMS_Agent__CreateAuditLog);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateAuditLog(soap, &soap_tmp_KMS_Agent__CreateAuditLog, "KMS-Agent:CreateAuditLog", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__CreateAuditLog(soap, &soap_tmp_KMS_Agent__CreateAuditLog, "KMS-Agent:CreateAuditLog", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__CreateAuditLogResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__CreateAuditLogResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__GetAgentKWKPublicKeyResponse &result)
+{ struct KMS_Agent__GetAgentKWKPublicKey soap_tmp_KMS_Agent__GetAgentKWKPublicKey;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__GetAgentKWKPublicKey(soap, &soap_tmp_KMS_Agent__GetAgentKWKPublicKey);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__GetAgentKWKPublicKey(soap, &soap_tmp_KMS_Agent__GetAgentKWKPublicKey, "KMS-Agent:GetAgentKWKPublicKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__GetAgentKWKPublicKey(soap, &soap_tmp_KMS_Agent__GetAgentKWKPublicKey, "KMS-Agent:GetAgentKWKPublicKey", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RegisterAgentKWK(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct xsd__hexBinary AgentKWK, struct KMS_Agent__RegisterAgentKWKResponse &result)
+{ struct KMS_Agent__RegisterAgentKWK soap_tmp_KMS_Agent__RegisterAgentKWK;
+ soap_tmp_KMS_Agent__RegisterAgentKWK.AgentKWK = AgentKWK;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Agent__RegisterAgentKWK(soap, &soap_tmp_KMS_Agent__RegisterAgentKWK);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RegisterAgentKWK(soap, &soap_tmp_KMS_Agent__RegisterAgentKWK, "KMS-Agent:RegisterAgentKWK", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Agent__RegisterAgentKWK(soap, &soap_tmp_KMS_Agent__RegisterAgentKWK, "KMS-Agent:RegisterAgentKWK", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Agent__RegisterAgentKWKResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Agent__RegisterAgentKWKResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+} // namespace KMS_Agent
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_AgentClient.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentH.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentH.h
new file mode 100644
index 0000000000..a0d0444b7e
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentH.h
@@ -0,0 +1,1827 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_AgentH.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/AgentService/KMS_Agent_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_AgentH_H
+#define KMS_AgentH_H
+#include "KMS_AgentStub.h"
+
+namespace KMS_Agent {
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
+SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_byte
+#define SOAP_TYPE_KMS_Agent_byte (3)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*);
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*);
+
+#define soap_write_byte(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_byte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*);
+
+#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_int
+#define SOAP_TYPE_KMS_Agent_int (1)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*);
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*);
+
+#define soap_write_int(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*);
+
+#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__int
+#define SOAP_TYPE_KMS_Agent_xsd__int (11)
+#endif
+
+#define soap_default_xsd__int(soap, a) soap_default_long(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap*, const char*, long *, const char*);
+
+#define soap_write_xsd__int(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_xsd__int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_xsd__int(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_long
+#define SOAP_TYPE_KMS_Agent_long (10)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap*, long *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap*, const char*, long *, const char*);
+
+#define soap_write_long(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_long(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__long
+#define SOAP_TYPE_KMS_Agent_xsd__long (15)
+#endif
+
+#define soap_default_xsd__long(soap, a) soap_default_LONG64(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_xsd__long(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_xsd__long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_xsd__long(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_LONG64
+#define SOAP_TYPE_KMS_Agent_LONG64 (14)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap*, LONG64 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_LONG64(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_LONG64(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_LONG64(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_LONG64(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__float
+#define SOAP_TYPE_KMS_Agent_xsd__float (9)
+#endif
+
+#define soap_default_xsd__float(soap, a) soap_default_float(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_xsd__float(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_xsd__float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_xsd__float(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_float
+#define SOAP_TYPE_KMS_Agent_float (8)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap*, float *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_float(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_float(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_unsignedByte
+#define SOAP_TYPE_KMS_Agent_unsignedByte (20)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap*, unsigned char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap*, const char*, int, const unsigned char *, const char*);
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap*, const char*, unsigned char *, const char*);
+
+#define soap_write_unsignedByte(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_unsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap*, const unsigned char *, const char*, const char*);
+
+#define soap_read_unsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_unsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap*, unsigned char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_unsignedInt
+#define SOAP_TYPE_KMS_Agent_unsignedInt (19)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap*, unsigned int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap*, const char*, int, const unsigned int *, const char*);
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap*, const char*, unsigned int *, const char*);
+
+#define soap_write_unsignedInt(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_unsignedInt(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap*, const unsigned int *, const char*, const char*);
+
+#define soap_read_unsignedInt(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_unsignedInt(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap*, unsigned int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition (41)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__AuditLogCondition(struct soap*, enum KMS_Agent__AuditLogCondition *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__AuditLogCondition(struct soap*, const char*, int, const enum KMS_Agent__AuditLogCondition *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__AuditLogCondition2s(struct soap*, enum KMS_Agent__AuditLogCondition);
+SOAP_FMAC3 enum KMS_Agent__AuditLogCondition * SOAP_FMAC4 soap_in_KMS_Agent__AuditLogCondition(struct soap*, const char*, enum KMS_Agent__AuditLogCondition *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__AuditLogCondition(struct soap*, const char*, enum KMS_Agent__AuditLogCondition *);
+
+#define soap_write_KMS_Agent__AuditLogCondition(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__AuditLogCondition(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__AuditLogCondition(struct soap*, const enum KMS_Agent__AuditLogCondition *, const char*, const char*);
+
+#define soap_read_KMS_Agent__AuditLogCondition(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__AuditLogCondition(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__AuditLogCondition * SOAP_FMAC4 soap_get_KMS_Agent__AuditLogCondition(struct soap*, enum KMS_Agent__AuditLogCondition *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention (40)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__AuditLogRetention(struct soap*, enum KMS_Agent__AuditLogRetention *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__AuditLogRetention(struct soap*, const char*, int, const enum KMS_Agent__AuditLogRetention *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__AuditLogRetention2s(struct soap*, enum KMS_Agent__AuditLogRetention);
+SOAP_FMAC3 enum KMS_Agent__AuditLogRetention * SOAP_FMAC4 soap_in_KMS_Agent__AuditLogRetention(struct soap*, const char*, enum KMS_Agent__AuditLogRetention *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__AuditLogRetention(struct soap*, const char*, enum KMS_Agent__AuditLogRetention *);
+
+#define soap_write_KMS_Agent__AuditLogRetention(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__AuditLogRetention(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__AuditLogRetention(struct soap*, const enum KMS_Agent__AuditLogRetention *, const char*, const char*);
+
+#define soap_read_KMS_Agent__AuditLogRetention(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__AuditLogRetention(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__AuditLogRetention * SOAP_FMAC4 soap_get_KMS_Agent__AuditLogRetention(struct soap*, enum KMS_Agent__AuditLogRetention *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState (32)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DataUnitState(struct soap*, enum KMS_Agent__DataUnitState *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DataUnitState(struct soap*, const char*, int, const enum KMS_Agent__DataUnitState *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__DataUnitState2s(struct soap*, enum KMS_Agent__DataUnitState);
+SOAP_FMAC3 enum KMS_Agent__DataUnitState * SOAP_FMAC4 soap_in_KMS_Agent__DataUnitState(struct soap*, const char*, enum KMS_Agent__DataUnitState *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__DataUnitState(struct soap*, const char*, enum KMS_Agent__DataUnitState *);
+
+#define soap_write_KMS_Agent__DataUnitState(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__DataUnitState(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DataUnitState(struct soap*, const enum KMS_Agent__DataUnitState *, const char*, const char*);
+
+#define soap_read_KMS_Agent__DataUnitState(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__DataUnitState(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__DataUnitState * SOAP_FMAC4 soap_get_KMS_Agent__DataUnitState(struct soap*, enum KMS_Agent__DataUnitState *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState (31)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__KeyState(struct soap*, enum KMS_Agent__KeyState *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__KeyState(struct soap*, const char*, int, const enum KMS_Agent__KeyState *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__KeyState2s(struct soap*, enum KMS_Agent__KeyState);
+SOAP_FMAC3 enum KMS_Agent__KeyState * SOAP_FMAC4 soap_in_KMS_Agent__KeyState(struct soap*, const char*, enum KMS_Agent__KeyState *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__KeyState(struct soap*, const char*, enum KMS_Agent__KeyState *);
+
+#define soap_write_KMS_Agent__KeyState(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__KeyState(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__KeyState(struct soap*, const enum KMS_Agent__KeyState *, const char*, const char*);
+
+#define soap_read_KMS_Agent__KeyState(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__KeyState(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__KeyState * SOAP_FMAC4 soap_get_KMS_Agent__KeyState(struct soap*, enum KMS_Agent__KeyState *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType (30)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__KeyType(struct soap*, enum KMS_Agent__KeyType *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__KeyType(struct soap*, const char*, int, const enum KMS_Agent__KeyType *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__KeyType2s(struct soap*, enum KMS_Agent__KeyType);
+SOAP_FMAC3 enum KMS_Agent__KeyType * SOAP_FMAC4 soap_in_KMS_Agent__KeyType(struct soap*, const char*, enum KMS_Agent__KeyType *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__KeyType(struct soap*, const char*, enum KMS_Agent__KeyType *);
+
+#define soap_write_KMS_Agent__KeyType(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__KeyType(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__KeyType(struct soap*, const enum KMS_Agent__KeyType *, const char*, const char*);
+
+#define soap_read_KMS_Agent__KeyType(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__KeyType(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__KeyType * SOAP_FMAC4 soap_get_KMS_Agent__KeyType(struct soap*, enum KMS_Agent__KeyType *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator (25)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__FilterOperator(struct soap*, enum KMS_Agent__FilterOperator *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__FilterOperator(struct soap*, const char*, int, const enum KMS_Agent__FilterOperator *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__FilterOperator2s(struct soap*, enum KMS_Agent__FilterOperator);
+SOAP_FMAC3 enum KMS_Agent__FilterOperator * SOAP_FMAC4 soap_in_KMS_Agent__FilterOperator(struct soap*, const char*, enum KMS_Agent__FilterOperator *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__FilterOperator(struct soap*, const char*, enum KMS_Agent__FilterOperator *);
+
+#define soap_write_KMS_Agent__FilterOperator(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__FilterOperator(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__FilterOperator(struct soap*, const enum KMS_Agent__FilterOperator *, const char*, const char*);
+
+#define soap_read_KMS_Agent__FilterOperator(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__FilterOperator(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__FilterOperator * SOAP_FMAC4 soap_get_KMS_Agent__FilterOperator(struct soap*, enum KMS_Agent__FilterOperator *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder (24)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__SortOrder(struct soap*, enum KMS_Agent__SortOrder *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__SortOrder(struct soap*, const char*, int, const enum KMS_Agent__SortOrder *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_KMS_Agent__SortOrder2s(struct soap*, enum KMS_Agent__SortOrder);
+SOAP_FMAC3 enum KMS_Agent__SortOrder * SOAP_FMAC4 soap_in_KMS_Agent__SortOrder(struct soap*, const char*, enum KMS_Agent__SortOrder *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2KMS_Agent__SortOrder(struct soap*, const char*, enum KMS_Agent__SortOrder *);
+
+#define soap_write_KMS_Agent__SortOrder(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_KMS_Agent__SortOrder(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__SortOrder(struct soap*, const enum KMS_Agent__SortOrder *, const char*, const char*);
+
+#define soap_read_KMS_Agent__SortOrder(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__SortOrder(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 enum KMS_Agent__SortOrder * SOAP_FMAC4 soap_get_KMS_Agent__SortOrder(struct soap*, enum KMS_Agent__SortOrder *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__boolean
+#define SOAP_TYPE_KMS_Agent_xsd__boolean (13)
+#endif
+
+#define soap_default_xsd__boolean(soap, a) soap_default_bool(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap*, const char*, bool *);
+
+#define soap_write_xsd__boolean(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_xsd__boolean(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_xsd__boolean(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__boolean(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap*, bool *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_bool
+#define SOAP_TYPE_KMS_Agent_bool (12)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap*, bool *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap*, const char*, bool *);
+
+#define soap_write_bool(soap, data) ( soap_begin_send(soap) || KMS_Agent::soap_put_bool(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_bool(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_bool(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap*, bool *, const char*, const char*);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault (113)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*);
+
+#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_SOAP_ENV__Fault(soap, data), 0) || KMS_Agent::soap_put_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Fault(soap, n) soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Fault(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason (112)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*);
+
+#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_SOAP_ENV__Reason(soap, data), 0) || KMS_Agent::soap_put_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Reason(soap, n) soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Reason(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail (111)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*);
+
+#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_SOAP_ENV__Detail(soap, data), 0) || KMS_Agent::soap_put_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Detail(soap, n) soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Detail(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Code (109)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*);
+
+#define soap_write_SOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_SOAP_ENV__Code(soap, data), 0) || KMS_Agent::soap_put_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Code(soap, n) soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Code(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Header (108)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*);
+
+#define soap_write_SOAP_ENV__Header(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_SOAP_ENV__Header(soap, data), 0) || KMS_Agent::soap_put_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Header(soap, n) soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Header(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK (107)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RegisterAgentKWK(struct soap*, struct KMS_Agent__RegisterAgentKWK *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RegisterAgentKWK(struct soap*, const struct KMS_Agent__RegisterAgentKWK *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RegisterAgentKWK(struct soap*, const char*, int, const struct KMS_Agent__RegisterAgentKWK *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWK * SOAP_FMAC4 soap_in_KMS_Agent__RegisterAgentKWK(struct soap*, const char*, struct KMS_Agent__RegisterAgentKWK *, const char*);
+
+#define soap_write_KMS_Agent__RegisterAgentKWK(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RegisterAgentKWK(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RegisterAgentKWK(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RegisterAgentKWK(struct soap*, const struct KMS_Agent__RegisterAgentKWK *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RegisterAgentKWK(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RegisterAgentKWK(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWK * SOAP_FMAC4 soap_get_KMS_Agent__RegisterAgentKWK(struct soap*, struct KMS_Agent__RegisterAgentKWK *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RegisterAgentKWK(soap, n) soap_instantiate_KMS_Agent__RegisterAgentKWK(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RegisterAgentKWK(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RegisterAgentKWK * SOAP_FMAC2 soap_instantiate_KMS_Agent__RegisterAgentKWK(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RegisterAgentKWK(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse (104)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RegisterAgentKWKResponse(struct soap*, struct KMS_Agent__RegisterAgentKWKResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RegisterAgentKWKResponse(struct soap*, const struct KMS_Agent__RegisterAgentKWKResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RegisterAgentKWKResponse(struct soap*, const char*, int, const struct KMS_Agent__RegisterAgentKWKResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWKResponse * SOAP_FMAC4 soap_in_KMS_Agent__RegisterAgentKWKResponse(struct soap*, const char*, struct KMS_Agent__RegisterAgentKWKResponse *, const char*);
+
+#define soap_write_KMS_Agent__RegisterAgentKWKResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RegisterAgentKWKResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RegisterAgentKWKResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RegisterAgentKWKResponse(struct soap*, const struct KMS_Agent__RegisterAgentKWKResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RegisterAgentKWKResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RegisterAgentKWKResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RegisterAgentKWKResponse * SOAP_FMAC4 soap_get_KMS_Agent__RegisterAgentKWKResponse(struct soap*, struct KMS_Agent__RegisterAgentKWKResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RegisterAgentKWKResponse(soap, n) soap_instantiate_KMS_Agent__RegisterAgentKWKResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RegisterAgentKWKResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RegisterAgentKWKResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RegisterAgentKWKResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RegisterAgentKWKResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey (103)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__GetAgentKWKPublicKey(struct soap*, struct KMS_Agent__GetAgentKWKPublicKey *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__GetAgentKWKPublicKey(struct soap*, const struct KMS_Agent__GetAgentKWKPublicKey *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__GetAgentKWKPublicKey(struct soap*, const char*, int, const struct KMS_Agent__GetAgentKWKPublicKey *, const char*);
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKey * SOAP_FMAC4 soap_in_KMS_Agent__GetAgentKWKPublicKey(struct soap*, const char*, struct KMS_Agent__GetAgentKWKPublicKey *, const char*);
+
+#define soap_write_KMS_Agent__GetAgentKWKPublicKey(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__GetAgentKWKPublicKey(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__GetAgentKWKPublicKey(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__GetAgentKWKPublicKey(struct soap*, const struct KMS_Agent__GetAgentKWKPublicKey *, const char*, const char*);
+
+#define soap_read_KMS_Agent__GetAgentKWKPublicKey(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__GetAgentKWKPublicKey(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKey * SOAP_FMAC4 soap_get_KMS_Agent__GetAgentKWKPublicKey(struct soap*, struct KMS_Agent__GetAgentKWKPublicKey *, const char*, const char*);
+
+#define soap_new_KMS_Agent__GetAgentKWKPublicKey(soap, n) soap_instantiate_KMS_Agent__GetAgentKWKPublicKey(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__GetAgentKWKPublicKey(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__GetAgentKWKPublicKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__GetAgentKWKPublicKey(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__GetAgentKWKPublicKey(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse (100)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, struct KMS_Agent__GetAgentKWKPublicKeyResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, const struct KMS_Agent__GetAgentKWKPublicKeyResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, const char*, int, const struct KMS_Agent__GetAgentKWKPublicKeyResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, const char*, struct KMS_Agent__GetAgentKWKPublicKeyResponse *, const char*);
+
+#define soap_write_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, const struct KMS_Agent__GetAgentKWKPublicKeyResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__GetAgentKWKPublicKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, struct KMS_Agent__GetAgentKWKPublicKeyResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, n) soap_instantiate_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__GetAgentKWKPublicKeyResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__GetAgentKWKPublicKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__GetAgentKWKPublicKeyResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog (99)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateAuditLog(struct soap*, struct KMS_Agent__CreateAuditLog *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateAuditLog(struct soap*, const struct KMS_Agent__CreateAuditLog *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateAuditLog(struct soap*, const char*, int, const struct KMS_Agent__CreateAuditLog *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLog * SOAP_FMAC4 soap_in_KMS_Agent__CreateAuditLog(struct soap*, const char*, struct KMS_Agent__CreateAuditLog *, const char*);
+
+#define soap_write_KMS_Agent__CreateAuditLog(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateAuditLog(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateAuditLog(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateAuditLog(struct soap*, const struct KMS_Agent__CreateAuditLog *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateAuditLog(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateAuditLog(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLog * SOAP_FMAC4 soap_get_KMS_Agent__CreateAuditLog(struct soap*, struct KMS_Agent__CreateAuditLog *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateAuditLog(soap, n) soap_instantiate_KMS_Agent__CreateAuditLog(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateAuditLog(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateAuditLog * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateAuditLog(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateAuditLog(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse (96)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateAuditLogResponse(struct soap*, struct KMS_Agent__CreateAuditLogResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateAuditLogResponse(struct soap*, const struct KMS_Agent__CreateAuditLogResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateAuditLogResponse(struct soap*, const char*, int, const struct KMS_Agent__CreateAuditLogResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLogResponse * SOAP_FMAC4 soap_in_KMS_Agent__CreateAuditLogResponse(struct soap*, const char*, struct KMS_Agent__CreateAuditLogResponse *, const char*);
+
+#define soap_write_KMS_Agent__CreateAuditLogResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateAuditLogResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateAuditLogResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateAuditLogResponse(struct soap*, const struct KMS_Agent__CreateAuditLogResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateAuditLogResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateAuditLogResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateAuditLogResponse * SOAP_FMAC4 soap_get_KMS_Agent__CreateAuditLogResponse(struct soap*, struct KMS_Agent__CreateAuditLogResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateAuditLogResponse(soap, n) soap_instantiate_KMS_Agent__CreateAuditLogResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateAuditLogResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateAuditLogResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateAuditLogResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateAuditLogResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2 (95)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKey2 *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKey2 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, const char*, int, const struct KMS_Agent__RetrieveProtectAndProcessKey2 *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2 * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, const char*, struct KMS_Agent__RetrieveProtectAndProcessKey2 *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveProtectAndProcessKey2(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveProtectAndProcessKey2(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKey2 *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveProtectAndProcessKey2(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveProtectAndProcessKey2(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2 * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKey2 *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveProtectAndProcessKey2(soap, n) soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveProtectAndProcessKey2(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKey2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response (92)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKey2Response *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, const char*, int, const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2Response * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, const char*, struct KMS_Agent__RetrieveProtectAndProcessKey2Response *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKey2Response *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey2Response * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKey2Response *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, n) soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveProtectAndProcessKey2Response(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKey2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKey2Response(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey (91)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKey *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKey *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, const char*, int, const struct KMS_Agent__RetrieveProtectAndProcessKey *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, const char*, struct KMS_Agent__RetrieveProtectAndProcessKey *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveProtectAndProcessKey(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveProtectAndProcessKey(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveProtectAndProcessKey(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKey *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveProtectAndProcessKey(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveProtectAndProcessKey(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKey * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKey *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveProtectAndProcessKey(soap, n) soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveProtectAndProcessKey(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse (88)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, const char*, int, const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, const char*, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, const struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveProtectAndProcessKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, n) soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveProtectAndProcessKeyResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveProtectAndProcessKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveProtectAndProcessKeyResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2 (87)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, struct KMS_Agent__RetrieveDataUnitKeys2 *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeys2 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitKeys2 *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2 * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitKeys2 *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitKeys2(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitKeys2(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitKeys2(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeys2 *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitKeys2(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitKeys2(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2 * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, struct KMS_Agent__RetrieveDataUnitKeys2 *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitKeys2(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitKeys2(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeys2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeys2(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response (84)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, struct KMS_Agent__RetrieveDataUnitKeys2Response *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeys2Response *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitKeys2Response *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2Response * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitKeys2Response *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitKeys2Response(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitKeys2Response(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitKeys2Response(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeys2Response *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitKeys2Response(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitKeys2Response(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys2Response * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, struct KMS_Agent__RetrieveDataUnitKeys2Response *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitKeys2Response(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2Response(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitKeys2Response(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeys2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeys2Response(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys (83)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeys(struct soap*, struct KMS_Agent__RetrieveDataUnitKeys *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeys(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeys *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeys(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitKeys *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeys(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitKeys *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitKeys(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitKeys(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitKeys(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeys(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeys *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitKeys(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitKeys(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeys * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeys(struct soap*, struct KMS_Agent__RetrieveDataUnitKeys *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitKeys(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitKeys(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitKeys(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeys * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeys(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeys(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse (80)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, struct KMS_Agent__RetrieveDataUnitKeysResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeysResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitKeysResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeysResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitKeysResponse *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitKeysResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitKeysResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitKeysResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, const struct KMS_Agent__RetrieveDataUnitKeysResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitKeysResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitKeysResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitKeysResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, struct KMS_Agent__RetrieveDataUnitKeysResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitKeysResponse(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitKeysResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitKeysResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitKeysResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitKeysResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2 (79)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKey2(struct soap*, struct KMS_Agent__RetrieveKey2 *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKey2(struct soap*, const struct KMS_Agent__RetrieveKey2 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKey2(struct soap*, const char*, int, const struct KMS_Agent__RetrieveKey2 *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2 * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKey2(struct soap*, const char*, struct KMS_Agent__RetrieveKey2 *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveKey2(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveKey2(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveKey2(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKey2(struct soap*, const struct KMS_Agent__RetrieveKey2 *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveKey2(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveKey2(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2 * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKey2(struct soap*, struct KMS_Agent__RetrieveKey2 *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveKey2(soap, n) soap_instantiate_KMS_Agent__RetrieveKey2(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveKey2(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKey2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKey2(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKey2(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response (76)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKey2Response(struct soap*, struct KMS_Agent__RetrieveKey2Response *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKey2Response(struct soap*, const struct KMS_Agent__RetrieveKey2Response *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKey2Response(struct soap*, const char*, int, const struct KMS_Agent__RetrieveKey2Response *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2Response * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKey2Response(struct soap*, const char*, struct KMS_Agent__RetrieveKey2Response *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveKey2Response(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveKey2Response(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveKey2Response(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKey2Response(struct soap*, const struct KMS_Agent__RetrieveKey2Response *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveKey2Response(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveKey2Response(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey2Response * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKey2Response(struct soap*, struct KMS_Agent__RetrieveKey2Response *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveKey2Response(soap, n) soap_instantiate_KMS_Agent__RetrieveKey2Response(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveKey2Response(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKey2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKey2Response(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKey2Response(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey (75)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKey(struct soap*, struct KMS_Agent__RetrieveKey *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKey(struct soap*, const struct KMS_Agent__RetrieveKey *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKey(struct soap*, const char*, int, const struct KMS_Agent__RetrieveKey *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKey(struct soap*, const char*, struct KMS_Agent__RetrieveKey *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveKey(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveKey(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveKey(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKey(struct soap*, const struct KMS_Agent__RetrieveKey *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveKey(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveKey(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKey * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKey(struct soap*, struct KMS_Agent__RetrieveKey *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveKey(soap, n) soap_instantiate_KMS_Agent__RetrieveKey(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveKey(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKey(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKey(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse (72)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveKeyResponse(struct soap*, struct KMS_Agent__RetrieveKeyResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveKeyResponse(struct soap*, const struct KMS_Agent__RetrieveKeyResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveKeyResponse(struct soap*, const char*, int, const struct KMS_Agent__RetrieveKeyResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveKeyResponse(struct soap*, const char*, struct KMS_Agent__RetrieveKeyResponse *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveKeyResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveKeyResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveKeyResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveKeyResponse(struct soap*, const struct KMS_Agent__RetrieveKeyResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveKeyResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveKeyResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveKeyResponse(struct soap*, struct KMS_Agent__RetrieveKeyResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveKeyResponse(soap, n) soap_instantiate_KMS_Agent__RetrieveKeyResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveKeyResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveKeyResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveKeyResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2 (71)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKey2(struct soap*, struct KMS_Agent__CreateKey2 *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKey2(struct soap*, const struct KMS_Agent__CreateKey2 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKey2(struct soap*, const char*, int, const struct KMS_Agent__CreateKey2 *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateKey2 * SOAP_FMAC4 soap_in_KMS_Agent__CreateKey2(struct soap*, const char*, struct KMS_Agent__CreateKey2 *, const char*);
+
+#define soap_write_KMS_Agent__CreateKey2(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateKey2(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateKey2(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKey2(struct soap*, const struct KMS_Agent__CreateKey2 *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateKey2(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateKey2(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey2 * SOAP_FMAC4 soap_get_KMS_Agent__CreateKey2(struct soap*, struct KMS_Agent__CreateKey2 *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateKey2(soap, n) soap_instantiate_KMS_Agent__CreateKey2(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateKey2(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateKey2 * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKey2(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKey2(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response (68)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKey2Response(struct soap*, struct KMS_Agent__CreateKey2Response *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKey2Response(struct soap*, const struct KMS_Agent__CreateKey2Response *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKey2Response(struct soap*, const char*, int, const struct KMS_Agent__CreateKey2Response *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateKey2Response * SOAP_FMAC4 soap_in_KMS_Agent__CreateKey2Response(struct soap*, const char*, struct KMS_Agent__CreateKey2Response *, const char*);
+
+#define soap_write_KMS_Agent__CreateKey2Response(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateKey2Response(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateKey2Response(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKey2Response(struct soap*, const struct KMS_Agent__CreateKey2Response *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateKey2Response(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateKey2Response(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey2Response * SOAP_FMAC4 soap_get_KMS_Agent__CreateKey2Response(struct soap*, struct KMS_Agent__CreateKey2Response *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateKey2Response(soap, n) soap_instantiate_KMS_Agent__CreateKey2Response(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateKey2Response(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateKey2Response * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKey2Response(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKey2Response(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey (67)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKey(struct soap*, struct KMS_Agent__CreateKey *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKey(struct soap*, const struct KMS_Agent__CreateKey *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKey(struct soap*, const char*, int, const struct KMS_Agent__CreateKey *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateKey * SOAP_FMAC4 soap_in_KMS_Agent__CreateKey(struct soap*, const char*, struct KMS_Agent__CreateKey *, const char*);
+
+#define soap_write_KMS_Agent__CreateKey(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateKey(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateKey(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKey(struct soap*, const struct KMS_Agent__CreateKey *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateKey(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateKey(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateKey * SOAP_FMAC4 soap_get_KMS_Agent__CreateKey(struct soap*, struct KMS_Agent__CreateKey *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateKey(soap, n) soap_instantiate_KMS_Agent__CreateKey(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateKey(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateKey * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKey(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKey(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse (64)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateKeyResponse(struct soap*, struct KMS_Agent__CreateKeyResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateKeyResponse(struct soap*, const struct KMS_Agent__CreateKeyResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateKeyResponse(struct soap*, const char*, int, const struct KMS_Agent__CreateKeyResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateKeyResponse * SOAP_FMAC4 soap_in_KMS_Agent__CreateKeyResponse(struct soap*, const char*, struct KMS_Agent__CreateKeyResponse *, const char*);
+
+#define soap_write_KMS_Agent__CreateKeyResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateKeyResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateKeyResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateKeyResponse(struct soap*, const struct KMS_Agent__CreateKeyResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateKeyResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateKeyResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateKeyResponse * SOAP_FMAC4 soap_get_KMS_Agent__CreateKeyResponse(struct soap*, struct KMS_Agent__CreateKeyResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateKeyResponse(soap, n) soap_instantiate_KMS_Agent__CreateKeyResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateKeyResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateKeyResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateKeyResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateKeyResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys (63)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DisassociateDataUnitKeys(struct soap*, struct KMS_Agent__DisassociateDataUnitKeys *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__DisassociateDataUnitKeys(struct soap*, const struct KMS_Agent__DisassociateDataUnitKeys *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DisassociateDataUnitKeys(struct soap*, const char*, int, const struct KMS_Agent__DisassociateDataUnitKeys *, const char*);
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeys * SOAP_FMAC4 soap_in_KMS_Agent__DisassociateDataUnitKeys(struct soap*, const char*, struct KMS_Agent__DisassociateDataUnitKeys *, const char*);
+
+#define soap_write_KMS_Agent__DisassociateDataUnitKeys(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__DisassociateDataUnitKeys(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__DisassociateDataUnitKeys(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DisassociateDataUnitKeys(struct soap*, const struct KMS_Agent__DisassociateDataUnitKeys *, const char*, const char*);
+
+#define soap_read_KMS_Agent__DisassociateDataUnitKeys(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__DisassociateDataUnitKeys(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeys * SOAP_FMAC4 soap_get_KMS_Agent__DisassociateDataUnitKeys(struct soap*, struct KMS_Agent__DisassociateDataUnitKeys *, const char*, const char*);
+
+#define soap_new_KMS_Agent__DisassociateDataUnitKeys(soap, n) soap_instantiate_KMS_Agent__DisassociateDataUnitKeys(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__DisassociateDataUnitKeys(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__DisassociateDataUnitKeys * SOAP_FMAC2 soap_instantiate_KMS_Agent__DisassociateDataUnitKeys(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__DisassociateDataUnitKeys(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse (58)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, struct KMS_Agent__DisassociateDataUnitKeysResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, const struct KMS_Agent__DisassociateDataUnitKeysResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, const char*, int, const struct KMS_Agent__DisassociateDataUnitKeysResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeysResponse * SOAP_FMAC4 soap_in_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, const char*, struct KMS_Agent__DisassociateDataUnitKeysResponse *, const char*);
+
+#define soap_write_KMS_Agent__DisassociateDataUnitKeysResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__DisassociateDataUnitKeysResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__DisassociateDataUnitKeysResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, const struct KMS_Agent__DisassociateDataUnitKeysResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__DisassociateDataUnitKeysResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__DisassociateDataUnitKeysResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__DisassociateDataUnitKeysResponse * SOAP_FMAC4 soap_get_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, struct KMS_Agent__DisassociateDataUnitKeysResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__DisassociateDataUnitKeysResponse(soap, n) soap_instantiate_KMS_Agent__DisassociateDataUnitKeysResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__DisassociateDataUnitKeysResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__DisassociateDataUnitKeysResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__DisassociateDataUnitKeysResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID (57)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueID * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueID * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, struct KMS_Agent__RetrieveDataUnitByExternalUniqueID *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitByExternalUniqueID(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitByExternalUniqueID * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse (54)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, const struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit (53)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnit(struct soap*, struct KMS_Agent__RetrieveDataUnit *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnit(struct soap*, const struct KMS_Agent__RetrieveDataUnit *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnit(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnit *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnit * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnit(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnit *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnit(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnit(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnit(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnit(struct soap*, const struct KMS_Agent__RetrieveDataUnit *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnit(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnit(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnit * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnit(struct soap*, struct KMS_Agent__RetrieveDataUnit *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnit(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnit(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnit(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnit * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnit(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnit(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse (50)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__RetrieveDataUnitResponse(struct soap*, struct KMS_Agent__RetrieveDataUnitResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__RetrieveDataUnitResponse(struct soap*, const struct KMS_Agent__RetrieveDataUnitResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__RetrieveDataUnitResponse(struct soap*, const char*, int, const struct KMS_Agent__RetrieveDataUnitResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitResponse * SOAP_FMAC4 soap_in_KMS_Agent__RetrieveDataUnitResponse(struct soap*, const char*, struct KMS_Agent__RetrieveDataUnitResponse *, const char*);
+
+#define soap_write_KMS_Agent__RetrieveDataUnitResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__RetrieveDataUnitResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__RetrieveDataUnitResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__RetrieveDataUnitResponse(struct soap*, const struct KMS_Agent__RetrieveDataUnitResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__RetrieveDataUnitResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__RetrieveDataUnitResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__RetrieveDataUnitResponse * SOAP_FMAC4 soap_get_KMS_Agent__RetrieveDataUnitResponse(struct soap*, struct KMS_Agent__RetrieveDataUnitResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__RetrieveDataUnitResponse(soap, n) soap_instantiate_KMS_Agent__RetrieveDataUnitResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__RetrieveDataUnitResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__RetrieveDataUnitResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__RetrieveDataUnitResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__RetrieveDataUnitResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit (49)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateDataUnit(struct soap*, struct KMS_Agent__CreateDataUnit *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateDataUnit(struct soap*, const struct KMS_Agent__CreateDataUnit *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateDataUnit(struct soap*, const char*, int, const struct KMS_Agent__CreateDataUnit *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnit * SOAP_FMAC4 soap_in_KMS_Agent__CreateDataUnit(struct soap*, const char*, struct KMS_Agent__CreateDataUnit *, const char*);
+
+#define soap_write_KMS_Agent__CreateDataUnit(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateDataUnit(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateDataUnit(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateDataUnit(struct soap*, const struct KMS_Agent__CreateDataUnit *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateDataUnit(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateDataUnit(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnit * SOAP_FMAC4 soap_get_KMS_Agent__CreateDataUnit(struct soap*, struct KMS_Agent__CreateDataUnit *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateDataUnit(soap, n) soap_instantiate_KMS_Agent__CreateDataUnit(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateDataUnit(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateDataUnit * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateDataUnit(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateDataUnit(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse (46)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__CreateDataUnitResponse(struct soap*, struct KMS_Agent__CreateDataUnitResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__CreateDataUnitResponse(struct soap*, const struct KMS_Agent__CreateDataUnitResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__CreateDataUnitResponse(struct soap*, const char*, int, const struct KMS_Agent__CreateDataUnitResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnitResponse * SOAP_FMAC4 soap_in_KMS_Agent__CreateDataUnitResponse(struct soap*, const char*, struct KMS_Agent__CreateDataUnitResponse *, const char*);
+
+#define soap_write_KMS_Agent__CreateDataUnitResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__CreateDataUnitResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__CreateDataUnitResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__CreateDataUnitResponse(struct soap*, const struct KMS_Agent__CreateDataUnitResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__CreateDataUnitResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__CreateDataUnitResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__CreateDataUnitResponse * SOAP_FMAC4 soap_get_KMS_Agent__CreateDataUnitResponse(struct soap*, struct KMS_Agent__CreateDataUnitResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__CreateDataUnitResponse(soap, n) soap_instantiate_KMS_Agent__CreateDataUnitResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__CreateDataUnitResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__CreateDataUnitResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__CreateDataUnitResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__CreateDataUnitResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups (45)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ListKeyGroups(struct soap*, struct KMS_Agent__ListKeyGroups *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ListKeyGroups(struct soap*, const struct KMS_Agent__ListKeyGroups *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ListKeyGroups(struct soap*, const char*, int, const struct KMS_Agent__ListKeyGroups *, const char*);
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroups * SOAP_FMAC4 soap_in_KMS_Agent__ListKeyGroups(struct soap*, const char*, struct KMS_Agent__ListKeyGroups *, const char*);
+
+#define soap_write_KMS_Agent__ListKeyGroups(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__ListKeyGroups(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__ListKeyGroups(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ListKeyGroups(struct soap*, const struct KMS_Agent__ListKeyGroups *, const char*, const char*);
+
+#define soap_read_KMS_Agent__ListKeyGroups(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__ListKeyGroups(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroups * SOAP_FMAC4 soap_get_KMS_Agent__ListKeyGroups(struct soap*, struct KMS_Agent__ListKeyGroups *, const char*, const char*);
+
+#define soap_new_KMS_Agent__ListKeyGroups(soap, n) soap_instantiate_KMS_Agent__ListKeyGroups(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__ListKeyGroups(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__ListKeyGroups * SOAP_FMAC2 soap_instantiate_KMS_Agent__ListKeyGroups(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ListKeyGroups(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse (42)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ListKeyGroupsResponse(struct soap*, struct KMS_Agent__ListKeyGroupsResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ListKeyGroupsResponse(struct soap*, const struct KMS_Agent__ListKeyGroupsResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ListKeyGroupsResponse(struct soap*, const char*, int, const struct KMS_Agent__ListKeyGroupsResponse *, const char*);
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroupsResponse * SOAP_FMAC4 soap_in_KMS_Agent__ListKeyGroupsResponse(struct soap*, const char*, struct KMS_Agent__ListKeyGroupsResponse *, const char*);
+
+#define soap_write_KMS_Agent__ListKeyGroupsResponse(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__ListKeyGroupsResponse(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__ListKeyGroupsResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ListKeyGroupsResponse(struct soap*, const struct KMS_Agent__ListKeyGroupsResponse *, const char*, const char*);
+
+#define soap_read_KMS_Agent__ListKeyGroupsResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__ListKeyGroupsResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__ListKeyGroupsResponse * SOAP_FMAC4 soap_get_KMS_Agent__ListKeyGroupsResponse(struct soap*, struct KMS_Agent__ListKeyGroupsResponse *, const char*, const char*);
+
+#define soap_new_KMS_Agent__ListKeyGroupsResponse(soap, n) soap_instantiate_KMS_Agent__ListKeyGroupsResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__ListKeyGroupsResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__ListKeyGroupsResponse * SOAP_FMAC2 soap_instantiate_KMS_Agent__ListKeyGroupsResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ListKeyGroupsResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit (39)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__DataUnit(struct soap*, struct KMS_Agent__DataUnit *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__DataUnit(struct soap*, const struct KMS_Agent__DataUnit *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__DataUnit(struct soap*, const char*, int, const struct KMS_Agent__DataUnit *, const char*);
+SOAP_FMAC3 struct KMS_Agent__DataUnit * SOAP_FMAC4 soap_in_KMS_Agent__DataUnit(struct soap*, const char*, struct KMS_Agent__DataUnit *, const char*);
+
+#define soap_write_KMS_Agent__DataUnit(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__DataUnit(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__DataUnit(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__DataUnit(struct soap*, const struct KMS_Agent__DataUnit *, const char*, const char*);
+
+#define soap_read_KMS_Agent__DataUnit(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__DataUnit(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__DataUnit * SOAP_FMAC4 soap_get_KMS_Agent__DataUnit(struct soap*, struct KMS_Agent__DataUnit *, const char*, const char*);
+
+#define soap_new_KMS_Agent__DataUnit(soap, n) soap_instantiate_KMS_Agent__DataUnit(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__DataUnit(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__DataUnit * SOAP_FMAC2 soap_instantiate_KMS_Agent__DataUnit(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__DataUnit(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys (37)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfKeys(struct soap*, struct KMS_Agent__ArrayOfKeys *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfKeys(struct soap*, struct KMS_Agent__ArrayOfKeys const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfKeys(struct soap*, const char*, int, const struct KMS_Agent__ArrayOfKeys *, const char*);
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeys * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfKeys(struct soap*, const char*, struct KMS_Agent__ArrayOfKeys *, const char*);
+
+#define soap_write_KMS_Agent__ArrayOfKeys(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__ArrayOfKeys(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__ArrayOfKeys(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfKeys(struct soap*, const struct KMS_Agent__ArrayOfKeys *, const char*, const char*);
+
+#define soap_read_KMS_Agent__ArrayOfKeys(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__ArrayOfKeys(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeys * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfKeys(struct soap*, struct KMS_Agent__ArrayOfKeys *, const char*, const char*);
+
+#define soap_new_KMS_Agent__ArrayOfKeys(soap, n) soap_instantiate_KMS_Agent__ArrayOfKeys(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__ArrayOfKeys(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfKeys * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfKeys(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfKeys(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__Key
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__Key (36)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__Key(struct soap*, struct KMS_Agent__Key *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__Key(struct soap*, const struct KMS_Agent__Key *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__Key(struct soap*, const char*, int, const struct KMS_Agent__Key *, const char*);
+SOAP_FMAC3 struct KMS_Agent__Key * SOAP_FMAC4 soap_in_KMS_Agent__Key(struct soap*, const char*, struct KMS_Agent__Key *, const char*);
+
+#define soap_write_KMS_Agent__Key(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__Key(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__Key(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__Key(struct soap*, const struct KMS_Agent__Key *, const char*, const char*);
+
+#define soap_read_KMS_Agent__Key(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__Key(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__Key * SOAP_FMAC4 soap_get_KMS_Agent__Key(struct soap*, struct KMS_Agent__Key *, const char*, const char*);
+
+#define soap_new_KMS_Agent__Key(soap, n) soap_instantiate_KMS_Agent__Key(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__Key(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__Key * SOAP_FMAC2 soap_instantiate_KMS_Agent__Key(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__Key(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups (34)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfKeyGroups(struct soap*, struct KMS_Agent__ArrayOfKeyGroups *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfKeyGroups(struct soap*, struct KMS_Agent__ArrayOfKeyGroups const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfKeyGroups(struct soap*, const char*, int, const struct KMS_Agent__ArrayOfKeyGroups *, const char*);
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeyGroups * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfKeyGroups(struct soap*, const char*, struct KMS_Agent__ArrayOfKeyGroups *, const char*);
+
+#define soap_write_KMS_Agent__ArrayOfKeyGroups(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__ArrayOfKeyGroups(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__ArrayOfKeyGroups(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfKeyGroups(struct soap*, const struct KMS_Agent__ArrayOfKeyGroups *, const char*, const char*);
+
+#define soap_read_KMS_Agent__ArrayOfKeyGroups(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__ArrayOfKeyGroups(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfKeyGroups * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfKeyGroups(struct soap*, struct KMS_Agent__ArrayOfKeyGroups *, const char*, const char*);
+
+#define soap_new_KMS_Agent__ArrayOfKeyGroups(soap, n) soap_instantiate_KMS_Agent__ArrayOfKeyGroups(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__ArrayOfKeyGroups(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfKeyGroups * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfKeyGroups(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfKeyGroups(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup (33)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__KeyGroup(struct soap*, struct KMS_Agent__KeyGroup *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__KeyGroup(struct soap*, const struct KMS_Agent__KeyGroup *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__KeyGroup(struct soap*, const char*, int, const struct KMS_Agent__KeyGroup *, const char*);
+SOAP_FMAC3 struct KMS_Agent__KeyGroup * SOAP_FMAC4 soap_in_KMS_Agent__KeyGroup(struct soap*, const char*, struct KMS_Agent__KeyGroup *, const char*);
+
+#define soap_write_KMS_Agent__KeyGroup(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__KeyGroup(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__KeyGroup(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__KeyGroup(struct soap*, const struct KMS_Agent__KeyGroup *, const char*, const char*);
+
+#define soap_read_KMS_Agent__KeyGroup(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__KeyGroup(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__KeyGroup * SOAP_FMAC4 soap_get_KMS_Agent__KeyGroup(struct soap*, struct KMS_Agent__KeyGroup *, const char*, const char*);
+
+#define soap_new_KMS_Agent__KeyGroup(soap, n) soap_instantiate_KMS_Agent__KeyGroup(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__KeyGroup(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__KeyGroup * SOAP_FMAC2 soap_instantiate_KMS_Agent__KeyGroup(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__KeyGroup(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters (29)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__QueryParameters(struct soap*, struct KMS_Agent__QueryParameters *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__QueryParameters(struct soap*, const struct KMS_Agent__QueryParameters *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__QueryParameters(struct soap*, const char*, int, const struct KMS_Agent__QueryParameters *, const char*);
+SOAP_FMAC3 struct KMS_Agent__QueryParameters * SOAP_FMAC4 soap_in_KMS_Agent__QueryParameters(struct soap*, const char*, struct KMS_Agent__QueryParameters *, const char*);
+
+#define soap_write_KMS_Agent__QueryParameters(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__QueryParameters(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__QueryParameters(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__QueryParameters(struct soap*, const struct KMS_Agent__QueryParameters *, const char*, const char*);
+
+#define soap_read_KMS_Agent__QueryParameters(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__QueryParameters(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__QueryParameters * SOAP_FMAC4 soap_get_KMS_Agent__QueryParameters(struct soap*, struct KMS_Agent__QueryParameters *, const char*, const char*);
+
+#define soap_new_KMS_Agent__QueryParameters(soap, n) soap_instantiate_KMS_Agent__QueryParameters(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__QueryParameters(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__QueryParameters * SOAP_FMAC2 soap_instantiate_KMS_Agent__QueryParameters(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__QueryParameters(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters (27)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfFilterParameters(struct soap*, struct KMS_Agent__ArrayOfFilterParameters *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfFilterParameters(struct soap*, struct KMS_Agent__ArrayOfFilterParameters const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfFilterParameters(struct soap*, const char*, int, const struct KMS_Agent__ArrayOfFilterParameters *, const char*);
+SOAP_FMAC3 struct KMS_Agent__ArrayOfFilterParameters * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfFilterParameters(struct soap*, const char*, struct KMS_Agent__ArrayOfFilterParameters *, const char*);
+
+#define soap_write_KMS_Agent__ArrayOfFilterParameters(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__ArrayOfFilterParameters(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__ArrayOfFilterParameters(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfFilterParameters(struct soap*, const struct KMS_Agent__ArrayOfFilterParameters *, const char*, const char*);
+
+#define soap_read_KMS_Agent__ArrayOfFilterParameters(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__ArrayOfFilterParameters(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfFilterParameters * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfFilterParameters(struct soap*, struct KMS_Agent__ArrayOfFilterParameters *, const char*, const char*);
+
+#define soap_new_KMS_Agent__ArrayOfFilterParameters(soap, n) soap_instantiate_KMS_Agent__ArrayOfFilterParameters(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__ArrayOfFilterParameters(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfFilterParameters * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfFilterParameters(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfFilterParameters(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters (26)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__FilterParameters(struct soap*, struct KMS_Agent__FilterParameters *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__FilterParameters(struct soap*, const struct KMS_Agent__FilterParameters *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__FilterParameters(struct soap*, const char*, int, const struct KMS_Agent__FilterParameters *, const char*);
+SOAP_FMAC3 struct KMS_Agent__FilterParameters * SOAP_FMAC4 soap_in_KMS_Agent__FilterParameters(struct soap*, const char*, struct KMS_Agent__FilterParameters *, const char*);
+
+#define soap_write_KMS_Agent__FilterParameters(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__FilterParameters(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__FilterParameters(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__FilterParameters(struct soap*, const struct KMS_Agent__FilterParameters *, const char*, const char*);
+
+#define soap_read_KMS_Agent__FilterParameters(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__FilterParameters(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__FilterParameters * SOAP_FMAC4 soap_get_KMS_Agent__FilterParameters(struct soap*, struct KMS_Agent__FilterParameters *, const char*, const char*);
+
+#define soap_new_KMS_Agent__FilterParameters(soap, n) soap_instantiate_KMS_Agent__FilterParameters(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__FilterParameters(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__FilterParameters * SOAP_FMAC2 soap_instantiate_KMS_Agent__FilterParameters(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__FilterParameters(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary (22)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Agent__ArrayOfHexBinary(struct soap*, struct KMS_Agent__ArrayOfHexBinary *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Agent__ArrayOfHexBinary(struct soap*, struct KMS_Agent__ArrayOfHexBinary const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Agent__ArrayOfHexBinary(struct soap*, const char*, int, const struct KMS_Agent__ArrayOfHexBinary *, const char*);
+SOAP_FMAC3 struct KMS_Agent__ArrayOfHexBinary * SOAP_FMAC4 soap_in_KMS_Agent__ArrayOfHexBinary(struct soap*, const char*, struct KMS_Agent__ArrayOfHexBinary *, const char*);
+
+#define soap_write_KMS_Agent__ArrayOfHexBinary(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_KMS_Agent__ArrayOfHexBinary(soap, data), 0) || KMS_Agent::soap_put_KMS_Agent__ArrayOfHexBinary(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Agent__ArrayOfHexBinary(struct soap*, const struct KMS_Agent__ArrayOfHexBinary *, const char*, const char*);
+
+#define soap_read_KMS_Agent__ArrayOfHexBinary(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_KMS_Agent__ArrayOfHexBinary(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__ArrayOfHexBinary * SOAP_FMAC4 soap_get_KMS_Agent__ArrayOfHexBinary(struct soap*, struct KMS_Agent__ArrayOfHexBinary *, const char*, const char*);
+
+#define soap_new_KMS_Agent__ArrayOfHexBinary(soap, n) soap_instantiate_KMS_Agent__ArrayOfHexBinary(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Agent__ArrayOfHexBinary(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Agent__ArrayOfHexBinary * SOAP_FMAC2 soap_instantiate_KMS_Agent__ArrayOfHexBinary(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Agent__ArrayOfHexBinary(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__hexBinary
+#define SOAP_TYPE_KMS_Agent_xsd__hexBinary (18)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap*, struct xsd__hexBinary *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap*, struct xsd__hexBinary const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap*, const char*, int, const struct xsd__hexBinary *, const char*);
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap*, const char*, struct xsd__hexBinary *, const char*);
+
+#define soap_write_xsd__hexBinary(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_xsd__hexBinary(soap, data), 0) || KMS_Agent::soap_put_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap*, const struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_read_xsd__hexBinary(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap*, struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_new_xsd__hexBinary(soap, n) soap_instantiate_xsd__hexBinary(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_xsd__hexBinary(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Reason (115)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToSOAP_ENV__Reason(soap, data), 0) || KMS_Agent::soap_put_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Detail (114)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToSOAP_ENV__Detail(soap, data), 0) || KMS_Agent::soap_put_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Code
+#define SOAP_TYPE_KMS_Agent_PointerToSOAP_ENV__Code (110)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToSOAP_ENV__Code(soap, data), 0) || KMS_Agent::soap_put_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__Key
+#define SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__Key (38)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Agent__Key(struct soap*, struct KMS_Agent__Key *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Agent__Key(struct soap*, const char *, int, struct KMS_Agent__Key *const*, const char *);
+SOAP_FMAC3 struct KMS_Agent__Key ** SOAP_FMAC4 soap_in_PointerToKMS_Agent__Key(struct soap*, const char*, struct KMS_Agent__Key **, const char*);
+
+#define soap_write_PointerToKMS_Agent__Key(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToKMS_Agent__Key(soap, data), 0) || KMS_Agent::soap_put_PointerToKMS_Agent__Key(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Agent__Key(struct soap*, struct KMS_Agent__Key *const*, const char*, const char*);
+
+#define soap_read_PointerToKMS_Agent__Key(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToKMS_Agent__Key(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__Key ** SOAP_FMAC4 soap_get_PointerToKMS_Agent__Key(struct soap*, struct KMS_Agent__Key **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__KeyGroup
+#define SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__KeyGroup (35)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Agent__KeyGroup(struct soap*, struct KMS_Agent__KeyGroup *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Agent__KeyGroup(struct soap*, const char *, int, struct KMS_Agent__KeyGroup *const*, const char *);
+SOAP_FMAC3 struct KMS_Agent__KeyGroup ** SOAP_FMAC4 soap_in_PointerToKMS_Agent__KeyGroup(struct soap*, const char*, struct KMS_Agent__KeyGroup **, const char*);
+
+#define soap_write_PointerToKMS_Agent__KeyGroup(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToKMS_Agent__KeyGroup(soap, data), 0) || KMS_Agent::soap_put_PointerToKMS_Agent__KeyGroup(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Agent__KeyGroup(struct soap*, struct KMS_Agent__KeyGroup *const*, const char*, const char*);
+
+#define soap_read_PointerToKMS_Agent__KeyGroup(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToKMS_Agent__KeyGroup(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__KeyGroup ** SOAP_FMAC4 soap_get_PointerToKMS_Agent__KeyGroup(struct soap*, struct KMS_Agent__KeyGroup **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__FilterParameters
+#define SOAP_TYPE_KMS_Agent_PointerToKMS_Agent__FilterParameters (28)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Agent__FilterParameters(struct soap*, struct KMS_Agent__FilterParameters *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Agent__FilterParameters(struct soap*, const char *, int, struct KMS_Agent__FilterParameters *const*, const char *);
+SOAP_FMAC3 struct KMS_Agent__FilterParameters ** SOAP_FMAC4 soap_in_PointerToKMS_Agent__FilterParameters(struct soap*, const char*, struct KMS_Agent__FilterParameters **, const char*);
+
+#define soap_write_PointerToKMS_Agent__FilterParameters(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToKMS_Agent__FilterParameters(soap, data), 0) || KMS_Agent::soap_put_PointerToKMS_Agent__FilterParameters(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Agent__FilterParameters(struct soap*, struct KMS_Agent__FilterParameters *const*, const char*, const char*);
+
+#define soap_read_PointerToKMS_Agent__FilterParameters(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToKMS_Agent__FilterParameters(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Agent__FilterParameters ** SOAP_FMAC4 soap_get_PointerToKMS_Agent__FilterParameters(struct soap*, struct KMS_Agent__FilterParameters **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerToxsd__hexBinary
+#define SOAP_TYPE_KMS_Agent_PointerToxsd__hexBinary (23)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToxsd__hexBinary(struct soap*, struct xsd__hexBinary *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToxsd__hexBinary(struct soap*, const char *, int, struct xsd__hexBinary *const*, const char *);
+SOAP_FMAC3 struct xsd__hexBinary ** SOAP_FMAC4 soap_in_PointerToxsd__hexBinary(struct soap*, const char*, struct xsd__hexBinary **, const char*);
+
+#define soap_write_PointerToxsd__hexBinary(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerToxsd__hexBinary(soap, data), 0) || KMS_Agent::soap_put_PointerToxsd__hexBinary(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToxsd__hexBinary(struct soap*, struct xsd__hexBinary *const*, const char*, const char*);
+
+#define soap_read_PointerToxsd__hexBinary(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerToxsd__hexBinary(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct xsd__hexBinary ** SOAP_FMAC4 soap_get_PointerToxsd__hexBinary(struct soap*, struct xsd__hexBinary **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_PointerTounsignedByte
+#define SOAP_TYPE_KMS_Agent_PointerTounsignedByte (21)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap*, unsigned char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap*, const char *, int, unsigned char *const*, const char *);
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap*, const char*, unsigned char **, const char*);
+
+#define soap_write_PointerTounsignedByte(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_PointerTounsignedByte(soap, data), 0) || KMS_Agent::soap_put_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap*, unsigned char *const*, const char*, const char*);
+
+#define soap_read_PointerTounsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap*, unsigned char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__duration
+#define SOAP_TYPE_KMS_Agent_xsd__duration (17)
+#endif
+
+#define soap_default_xsd__duration(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__duration(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__duration(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_xsd__duration(soap, data), 0) || KMS_Agent::soap_put_xsd__duration(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__duration(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__duration(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__dateTime
+#define SOAP_TYPE_KMS_Agent_xsd__dateTime (16)
+#endif
+
+#define soap_default_xsd__dateTime(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__dateTime(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__dateTime(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_xsd__dateTime(soap, data), 0) || KMS_Agent::soap_put_xsd__dateTime(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__dateTime(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__dateTime(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__string
+#define SOAP_TYPE_KMS_Agent_xsd__string (7)
+#endif
+
+#define soap_default_xsd__string(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__string(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__string(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_xsd__string(soap, data), 0) || KMS_Agent::soap_put_xsd__string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__string(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_xsd__string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent__QName
+#define SOAP_TYPE_KMS_Agent__QName (5)
+#endif
+
+#define soap_default__QName(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize__QName(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*);
+
+#define soap_write__QName(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize__QName(soap, data), 0) || KMS_Agent::soap_put__QName(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Agent_string
+#define SOAP_TYPE_KMS_Agent_string (4)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_string(soap, data) ( soap_begin_send(soap) || (KMS_Agent::soap_serialize_string(soap, data), 0) || KMS_Agent::soap_put_string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !KMS_Agent::soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*);
+
+} // namespace KMS_Agent
+
+
+#endif
+
+/* End of KMS_AgentH.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentStub.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentStub.h
new file mode 100644
index 0000000000..a0edbe621a
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_AgentStub.h
@@ -0,0 +1,834 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_AgentStub.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/AgentService/KMS_Agent_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_AgentStub_H
+#define KMS_AgentStub_H
+#ifndef WITH_NONAMESPACES
+#define WITH_NONAMESPACES
+#endif
+#ifndef WITH_NOGLOBAL
+#define WITH_NOGLOBAL
+#endif
+#include "stdsoap2.h"
+
+namespace KMS_Agent {
+
+/******************************************************************************\
+ * *
+ * Enumerations *
+ * *
+\******************************************************************************/
+
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__SortOrder (24)
+/* KMS-Agent:SortOrder */
+enum KMS_Agent__SortOrder {SORT_ORDER_ASCENDING = 0, SORT_ORDER_DESCENDING = 1};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__FilterOperator (25)
+/* KMS-Agent:FilterOperator */
+enum KMS_Agent__FilterOperator {FILTER_OPERATOR_EQUAL = 0, FILTER_OPERATOR_NOT_EQUAL = 1, FILTER_OPERATOR_GREATER_THAN = 2, FILTER_OPERATOR_LESS_THAN = 3, FILTER_OPERATOR_GREATER_THAN_OR_EQUAL = 4, FILTER_OPERATOR_LESS_THAN_OR_EQUAL = 5, FILTER_OPERATOR_STARTS_WITH = 6};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__KeyType (30)
+/* KMS-Agent:KeyType */
+enum KMS_Agent__KeyType {KEY_TYPE_AES_256 = 0};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__KeyState (31)
+/* KMS-Agent:KeyState */
+enum KMS_Agent__KeyState {KEY_STATE_GENERATED = 0, KEY_STATE_READY = 1, KEY_STATE_PROTECT_AND_PROCESS = 2, KEY_STATE_PROCESS_ONLY = 3, KEY_STATE_DEACTIVATED = 4, KEY_STATE_COMPROMISED = 5, KEY_STATE_DESTROYED_INCOMPLETE = 6, KEY_STATE_DESTROYED_COMPLETE = 7, KEY_STATE_DESTROYED_COMPROMISED_INCOMPLETE = 8, KEY_STATE_DESTROYED_COMPROMISED_COMPLETE = 9};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnitState (32)
+/* KMS-Agent:DataUnitState */
+enum KMS_Agent__DataUnitState {DATA_UNIT_STATE_NO_KEY = 0, DATA_UNIT_STATE_READABLE_NORMAL = 1, DATA_UNIT_STATE_READABLE_NEEDS_REKEY = 2, DATA_UNIT_STATE_SHREDDED = 3};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogRetention (40)
+/* KMS-Agent:AuditLogRetention */
+enum KMS_Agent__AuditLogRetention {AUDIT_LOG_LONG_TERM_RETENTION = 0, AUDIT_LOG_MEDIUM_TERM_RETENTION = 1, AUDIT_LOG_SHORT_TERM_RETENTION = 2, AUDIT_LOG_ZERO_RETENTION = 3};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__AuditLogCondition (41)
+/* KMS-Agent:AuditLogCondition */
+enum KMS_Agent__AuditLogCondition {AUDIT_LOG_SUCCESS_CONDITION = 0, AUDIT_LOG_ERROR_CONDITION = 1, AUDIT_LOG_WARNING_CONDITION = 2};
+#endif
+
+/******************************************************************************\
+ * *
+ * Types with Custom Serializers *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Classes and Structs *
+ * *
+\******************************************************************************/
+
+
+#if 0 /* volatile type: do not declare here, declared elsewhere */
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__hexBinary
+#define SOAP_TYPE_KMS_Agent_xsd__hexBinary (18)
+/* hexBinary schema type: */
+struct xsd__hexBinary
+{
+public:
+ unsigned char *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfHexBinary (22)
+/* Sequence of KMS-Agent:ArrayOfHexBinary schema type: */
+struct KMS_Agent__ArrayOfHexBinary
+{
+public:
+ struct xsd__hexBinary *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__FilterParameters (26)
+/* KMS-Agent:FilterParameters */
+struct KMS_Agent__FilterParameters
+{
+public:
+ char *FieldName; /* optional element of type xsd:string */
+ enum KMS_Agent__FilterOperator FilterOperator; /* required element of type KMS-Agent:FilterOperator */
+ char *FieldValue; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfFilterParameters (27)
+/* Sequence of KMS-Agent:ArrayOfFilterParameters schema type: */
+struct KMS_Agent__ArrayOfFilterParameters
+{
+public:
+ struct KMS_Agent__FilterParameters *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__QueryParameters (29)
+/* KMS-Agent:QueryParameters */
+struct KMS_Agent__QueryParameters
+{
+public:
+ long NextPageSize; /* required element of type xsd:int */
+ char *SortFieldName; /* optional element of type xsd:string */
+ enum KMS_Agent__SortOrder SortOrder; /* required element of type KMS-Agent:SortOrder */
+ struct KMS_Agent__ArrayOfFilterParameters FilterParameters; /* optional element of type KMS-Agent:ArrayOfFilterParameters */
+ char *PreviousPageLastIDValue; /* optional element of type xsd:string */
+ char *PreviousPageLastSortFieldValue; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__KeyGroup (33)
+/* KMS-Agent:KeyGroup */
+struct KMS_Agent__KeyGroup
+{
+public:
+ char *KeyGroupID; /* optional element of type xsd:string */
+ char *Description; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeyGroups (34)
+/* Sequence of KMS-Agent:ArrayOfKeyGroups schema type: */
+struct KMS_Agent__ArrayOfKeyGroups
+{
+public:
+ struct KMS_Agent__KeyGroup *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__Key
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__Key (36)
+/* KMS-Agent:Key */
+struct KMS_Agent__Key
+{
+public:
+ char *KeyID; /* optional element of type xsd:string */
+ enum KMS_Agent__KeyState KeyState; /* required element of type KMS-Agent:KeyState */
+ enum KMS_Agent__KeyType KeyType; /* required element of type KMS-Agent:KeyType */
+ char *KeyGroupID; /* optional element of type xsd:string */
+ struct xsd__hexBinary Key; /* required element of type xsd:hexBinary */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ArrayOfKeys (37)
+/* Sequence of KMS-Agent:ArrayOfKeys schema type: */
+struct KMS_Agent__ArrayOfKeys
+{
+public:
+ struct KMS_Agent__Key *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DataUnit (39)
+/* KMS-Agent:DataUnit */
+struct KMS_Agent__DataUnit
+{
+public:
+ char *DataUnitID; /* optional element of type xsd:string */
+ char *ExternalUniqueID; /* optional element of type xsd:string */
+ char *ExternalTag; /* optional element of type xsd:string */
+ char *Description; /* optional element of type xsd:string */
+ enum KMS_Agent__DataUnitState DataUnitState; /* required element of type KMS-Agent:DataUnitState */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroupsResponse (42)
+/* KMS-Agent:ListKeyGroupsResponse */
+struct KMS_Agent__ListKeyGroupsResponse
+{
+public:
+ struct KMS_Agent__ArrayOfKeyGroups KeyGroups; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type KMS-Agent:ArrayOfKeyGroups */
+ bool LastPage; /* required element of type xsd:boolean */
+ struct KMS_Agent__QueryParameters NextPageQueryParameters; /* required element of type KMS-Agent:QueryParameters */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__ListKeyGroups (45)
+/* KMS-Agent:ListKeyGroups */
+struct KMS_Agent__ListKeyGroups
+{
+public:
+ struct KMS_Agent__QueryParameters QueryParameters; /* required element of type KMS-Agent:QueryParameters */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnitResponse (46)
+/* KMS-Agent:CreateDataUnitResponse */
+struct KMS_Agent__CreateDataUnitResponse
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:DataUnit */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateDataUnit (49)
+/* KMS-Agent:CreateDataUnit */
+struct KMS_Agent__CreateDataUnit
+{
+public:
+ char *ExternalUniqueID; /* optional element of type xsd:string */
+ char *ExternalTag; /* optional element of type xsd:string */
+ char *Description; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitResponse (50)
+/* KMS-Agent:RetrieveDataUnitResponse */
+struct KMS_Agent__RetrieveDataUnitResponse
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:DataUnit */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnit (53)
+/* KMS-Agent:RetrieveDataUnit */
+struct KMS_Agent__RetrieveDataUnit
+{
+public:
+ char *DataUnitID; /* optional element of type xsd:string */
+ char *ExternalUniqueID; /* optional element of type xsd:string */
+ char *ExternalTag; /* optional element of type xsd:string */
+ char *Description; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse (54)
+/* KMS-Agent:RetrieveDataUnitByExternalUniqueIDResponse */
+struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:DataUnit */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitByExternalUniqueID (57)
+/* KMS-Agent:RetrieveDataUnitByExternalUniqueID */
+struct KMS_Agent__RetrieveDataUnitByExternalUniqueID
+{
+public:
+ char *ExternalUniqueID; /* optional element of type xsd:string */
+ char *ExternalTag; /* optional element of type xsd:string */
+ char *Description; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeysResponse (58)
+/* KMS-Agent:DisassociateDataUnitKeysResponse */
+struct KMS_Agent__DisassociateDataUnitKeysResponse
+{
+public:
+ void *_; /* transient */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__DisassociateDataUnitKeys (63)
+/* KMS-Agent:DisassociateDataUnitKeys */
+struct KMS_Agent__DisassociateDataUnitKeys
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKeyResponse (64)
+/* KMS-Agent:CreateKeyResponse */
+struct KMS_Agent__CreateKeyResponse
+{
+public:
+ struct KMS_Agent__Key Key; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:Key */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey (67)
+/* KMS-Agent:CreateKey */
+struct KMS_Agent__CreateKey
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ char *KeyGroupID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2Response (68)
+/* KMS-Agent:CreateKey2Response */
+struct KMS_Agent__CreateKey2Response
+{
+public:
+ struct KMS_Agent__Key Key; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:Key */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateKey2 (71)
+/* KMS-Agent:CreateKey2 */
+struct KMS_Agent__CreateKey2
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ char *KeyGroupID; /* optional element of type xsd:string */
+ char *AgentKWKID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKeyResponse (72)
+/* KMS-Agent:RetrieveKeyResponse */
+struct KMS_Agent__RetrieveKeyResponse
+{
+public:
+ struct KMS_Agent__Key Key; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:Key */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey (75)
+/* KMS-Agent:RetrieveKey */
+struct KMS_Agent__RetrieveKey
+{
+public:
+ char *KeyID; /* optional element of type xsd:string */
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ char *KeyGroupID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2Response (76)
+/* KMS-Agent:RetrieveKey2Response */
+struct KMS_Agent__RetrieveKey2Response
+{
+public:
+ struct KMS_Agent__Key Key; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:Key */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveKey2 (79)
+/* KMS-Agent:RetrieveKey2 */
+struct KMS_Agent__RetrieveKey2
+{
+public:
+ char *KeyID; /* optional element of type xsd:string */
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ char *KeyGroupID; /* optional element of type xsd:string */
+ char *AgentKWKID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeysResponse (80)
+/* KMS-Agent:RetrieveDataUnitKeysResponse */
+struct KMS_Agent__RetrieveDataUnitKeysResponse
+{
+public:
+ LONG64 KeysRemaining; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type xsd:long */
+ struct KMS_Agent__ArrayOfKeys Keys; /* optional element of type KMS-Agent:ArrayOfKeys */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys (83)
+/* KMS-Agent:RetrieveDataUnitKeys */
+struct KMS_Agent__RetrieveDataUnitKeys
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ long PageSize; /* required element of type xsd:int */
+ long PageOffset; /* required element of type xsd:int */
+ char *KeyID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2Response (84)
+/* KMS-Agent:RetrieveDataUnitKeys2Response */
+struct KMS_Agent__RetrieveDataUnitKeys2Response
+{
+public:
+ LONG64 KeysRemaining; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type xsd:long */
+ struct KMS_Agent__ArrayOfKeys Keys; /* optional element of type KMS-Agent:ArrayOfKeys */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveDataUnitKeys2 (87)
+/* KMS-Agent:RetrieveDataUnitKeys2 */
+struct KMS_Agent__RetrieveDataUnitKeys2
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ long PageSize; /* required element of type xsd:int */
+ long PageOffset; /* required element of type xsd:int */
+ char *KeyID; /* optional element of type xsd:string */
+ char *AgentKWKID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKeyResponse (88)
+/* KMS-Agent:RetrieveProtectAndProcessKeyResponse */
+struct KMS_Agent__RetrieveProtectAndProcessKeyResponse
+{
+public:
+ struct KMS_Agent__Key Key; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:Key */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey (91)
+/* KMS-Agent:RetrieveProtectAndProcessKey */
+struct KMS_Agent__RetrieveProtectAndProcessKey
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ char *KeyGroupID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2Response (92)
+/* KMS-Agent:RetrieveProtectAndProcessKey2Response */
+struct KMS_Agent__RetrieveProtectAndProcessKey2Response
+{
+public:
+ struct KMS_Agent__Key Key; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type KMS-Agent:Key */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RetrieveProtectAndProcessKey2 (95)
+/* KMS-Agent:RetrieveProtectAndProcessKey2 */
+struct KMS_Agent__RetrieveProtectAndProcessKey2
+{
+public:
+ struct KMS_Agent__DataUnit DataUnit; /* required element of type KMS-Agent:DataUnit */
+ char *KeyGroupID; /* optional element of type xsd:string */
+ char *AgentKWKID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLogResponse (96)
+/* KMS-Agent:CreateAuditLogResponse */
+struct KMS_Agent__CreateAuditLogResponse
+{
+public:
+ void *_; /* transient */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__CreateAuditLog (99)
+/* KMS-Agent:CreateAuditLog */
+struct KMS_Agent__CreateAuditLog
+{
+public:
+ enum KMS_Agent__AuditLogRetention Retention; /* required element of type KMS-Agent:AuditLogRetention */
+ enum KMS_Agent__AuditLogCondition Condition; /* required element of type KMS-Agent:AuditLogCondition */
+ bool IssueAlert; /* required element of type xsd:boolean */
+ char *Message; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKeyResponse (100)
+/* KMS-Agent:GetAgentKWKPublicKeyResponse */
+struct KMS_Agent__GetAgentKWKPublicKeyResponse
+{
+public:
+ struct xsd__hexBinary KWKPublicKey; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type xsd:hexBinary */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__GetAgentKWKPublicKey (103)
+/* KMS-Agent:GetAgentKWKPublicKey */
+struct KMS_Agent__GetAgentKWKPublicKey
+{
+#ifdef WITH_NOEMPTYSTRUCT
+private:
+ char dummy; /* dummy member to enable compilation */
+#endif
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWKResponse (104)
+/* KMS-Agent:RegisterAgentKWKResponse */
+struct KMS_Agent__RegisterAgentKWKResponse
+{
+public:
+ char *AgentKWKID; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK
+#define SOAP_TYPE_KMS_Agent_KMS_Agent__RegisterAgentKWK (107)
+/* KMS-Agent:RegisterAgentKWK */
+struct KMS_Agent__RegisterAgentKWK
+{
+public:
+ struct xsd__hexBinary AgentKWK; /* required element of type xsd:hexBinary */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Header (108)
+/* SOAP Header: */
+struct SOAP_ENV__Header
+{
+#ifdef WITH_NOEMPTYSTRUCT
+private:
+ char dummy; /* dummy member to enable compilation */
+#endif
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Code (109)
+/* SOAP Fault Code: */
+struct SOAP_ENV__Code
+{
+public:
+ char *SOAP_ENV__Value; /* optional element of type xsd:QName */
+ struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Detail (111)
+/* SOAP-ENV:Detail */
+struct SOAP_ENV__Detail
+{
+public:
+ int __type; /* any type of element <fault> (defined below) */
+ void *fault; /* transient */
+ char *__any;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Reason (112)
+/* SOAP-ENV:Reason */
+struct SOAP_ENV__Reason
+{
+public:
+ char *SOAP_ENV__Text; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_Agent_SOAP_ENV__Fault (113)
+/* SOAP Fault: */
+struct SOAP_ENV__Fault
+{
+public:
+ char *faultcode; /* optional element of type xsd:QName */
+ char *faultstring; /* optional element of type xsd:string */
+ char *faultactor; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */
+ struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */
+ struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */
+ char *SOAP_ENV__Node; /* optional element of type xsd:string */
+ char *SOAP_ENV__Role; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */
+};
+#endif
+
+/******************************************************************************\
+ * *
+ * Typedefs *
+ * *
+\******************************************************************************/
+
+#ifndef SOAP_TYPE_KMS_Agent__QName
+#define SOAP_TYPE_KMS_Agent__QName (5)
+typedef char *_QName;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent__XML
+#define SOAP_TYPE_KMS_Agent__XML (6)
+typedef char *_XML;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__string
+#define SOAP_TYPE_KMS_Agent_xsd__string (7)
+typedef char *xsd__string;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__float
+#define SOAP_TYPE_KMS_Agent_xsd__float (9)
+typedef float xsd__float;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__int
+#define SOAP_TYPE_KMS_Agent_xsd__int (11)
+typedef long xsd__int;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__boolean
+#define SOAP_TYPE_KMS_Agent_xsd__boolean (13)
+typedef bool xsd__boolean;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__long
+#define SOAP_TYPE_KMS_Agent_xsd__long (15)
+typedef LONG64 xsd__long;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__dateTime
+#define SOAP_TYPE_KMS_Agent_xsd__dateTime (16)
+typedef char *xsd__dateTime;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Agent_xsd__duration
+#define SOAP_TYPE_KMS_Agent_xsd__duration (17)
+typedef char *xsd__duration;
+#endif
+
+
+/******************************************************************************\
+ * *
+ * Externals *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Server-Side Operations *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__ListKeyGroups(struct soap*, struct KMS_Agent__QueryParameters QueryParameters, struct KMS_Agent__ListKeyGroupsResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__CreateDataUnit(struct soap*, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__CreateDataUnitResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveDataUnit(struct soap*, char *DataUnitID, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__RetrieveDataUnitResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__DisassociateDataUnitKeys(struct soap*, struct KMS_Agent__DataUnit DataUnit, struct KMS_Agent__DisassociateDataUnitKeysResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__CreateKey(struct soap*, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__CreateKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__CreateKey2(struct soap*, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__CreateKey2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveKey(struct soap*, char *KeyID, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__RetrieveKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveKey2(struct soap*, char *KeyID, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__RetrieveKey2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveDataUnitKeys(struct soap*, struct KMS_Agent__DataUnit DataUnit, long PageSize, long PageOffset, char *KeyID, struct KMS_Agent__RetrieveDataUnitKeysResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveDataUnitKeys2(struct soap*, struct KMS_Agent__DataUnit DataUnit, long PageSize, long PageOffset, char *KeyID, char *AgentKWKID, struct KMS_Agent__RetrieveDataUnitKeys2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveProtectAndProcessKey(struct soap*, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__RetrieveProtectAndProcessKey2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__CreateAuditLog(struct soap*, enum KMS_Agent__AuditLogRetention Retention, enum KMS_Agent__AuditLogCondition Condition, bool IssueAlert, char *Message, struct KMS_Agent__CreateAuditLogResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__GetAgentKWKPublicKey(struct soap*, struct KMS_Agent__GetAgentKWKPublicKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent__RegisterAgentKWK(struct soap*, struct xsd__hexBinary AgentKWK, struct KMS_Agent__RegisterAgentKWKResponse &result);
+
+/******************************************************************************\
+ * *
+ * Server-Side Skeletons to Invoke Service Operations *
+ * *
+\******************************************************************************/
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent_serve(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Agent_serve_request(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__ListKeyGroups(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__CreateDataUnit(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveDataUnit(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__DisassociateDataUnitKeys(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__CreateKey(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__CreateKey2(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveKey(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveKey2(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveDataUnitKeys(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveDataUnitKeys2(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveProtectAndProcessKey(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__CreateAuditLog(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__GetAgentKWKPublicKey(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Agent__RegisterAgentKWK(struct soap*);
+
+/******************************************************************************\
+ * *
+ * Client-Side Call Stubs *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__ListKeyGroups(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__QueryParameters QueryParameters, struct KMS_Agent__ListKeyGroupsResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateDataUnit(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__CreateDataUnitResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnit(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *DataUnitID, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__RetrieveDataUnitResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnitByExternalUniqueID(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *ExternalUniqueID, char *ExternalTag, char *Description, struct KMS_Agent__RetrieveDataUnitByExternalUniqueIDResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__DisassociateDataUnitKeys(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, struct KMS_Agent__DisassociateDataUnitKeysResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__CreateKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateKey2(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__CreateKey2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *KeyID, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__RetrieveKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveKey2(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *KeyID, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__RetrieveKey2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnitKeys(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, long PageSize, long PageOffset, char *KeyID, struct KMS_Agent__RetrieveDataUnitKeysResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveDataUnitKeys2(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, long PageSize, long PageOffset, char *KeyID, char *AgentKWKID, struct KMS_Agent__RetrieveDataUnitKeys2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveProtectAndProcessKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, struct KMS_Agent__RetrieveProtectAndProcessKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RetrieveProtectAndProcessKey2(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__DataUnit DataUnit, char *KeyGroupID, char *AgentKWKID, struct KMS_Agent__RetrieveProtectAndProcessKey2Response &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__CreateAuditLog(struct soap *soap, const char *soap_endpoint, const char *soap_action, enum KMS_Agent__AuditLogRetention Retention, enum KMS_Agent__AuditLogCondition Condition, bool IssueAlert, char *Message, struct KMS_Agent__CreateAuditLogResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__GetAgentKWKPublicKey(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct KMS_Agent__GetAgentKWKPublicKeyResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Agent__RegisterAgentKWK(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct xsd__hexBinary AgentKWK, struct KMS_Agent__RegisterAgentKWKResponse &result);
+
+} // namespace KMS_Agent
+
+
+#endif
+
+/* End of KMS_AgentStub.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CA.nsmap b/usr/src/lib/libkmsagent/common/SOAP/KMS_CA.nsmap
new file mode 100644
index 0000000000..f7adb33d6c
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CA.nsmap
@@ -0,0 +1,36 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include "KMS_CAH.h"
+SOAP_NMAC struct Namespace KMS_CA_namespaces[] =
+{
+ {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope"},
+ {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding"},
+ {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},
+ {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},
+ {"KMS-CA", "http://www.sun.com/KMS/KMS-CA"},
+ {NULL, NULL}
+};
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CAC.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAC.cpp
new file mode 100644
index 0000000000..3be119b657
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAC.cpp
@@ -0,0 +1,2648 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CAC.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CAService/KMS_CA_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+
+#include "KMS_CAH.h"
+
+namespace KMS_CA {
+
+SOAP_SOURCE_STAMP("@(#) KMS_CAC.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap)
+{
+ if (soap->header)
+ soap_serialize_SOAP_ENV__Header(soap, soap->header);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap)
+{
+ if (soap->header)
+ { soap->part = SOAP_IN_HEADER;
+ if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, NULL))
+ return soap->error;
+ soap->part = SOAP_END_HEADER;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap)
+{
+ soap->part = SOAP_IN_HEADER;
+ soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", NULL, NULL);
+ soap->part = SOAP_END_HEADER;
+ return soap->header == NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap)
+{
+ if (!soap->header)
+ { if ((soap->header = soap_new_SOAP_ENV__Header(soap, -1)))
+ soap_default_SOAP_ENV__Header(soap, soap->header);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap)
+{
+ if (!soap->fault)
+ { soap->fault = soap_new_SOAP_ENV__Fault(soap, -1);
+ if (!soap->fault)
+ return;
+ soap_default_SOAP_ENV__Fault(soap, soap->fault);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Code)
+ { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason)
+ { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap, -1);
+ soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->fault)
+ soap_serialize_SOAP_ENV__Fault(soap, soap->fault);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap)
+{
+ if (soap->fault)
+ return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", NULL);
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap)
+{
+ return (soap->fault = soap_get_SOAP_ENV__Fault(soap, NULL, "SOAP-ENV:Fault", NULL)) == NULL;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value;
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ { if (!soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
+ { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value;
+ }
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text;
+ return (const char**)&soap->fault->faultstring;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 1)
+ { if (!soap->fault->detail)
+ { soap->fault->detail = (struct SOAP_ENV__Detail*)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail));
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->detail);
+ }
+ return (const char**)&soap->fault->detail->__any;
+ }
+ if (!soap->fault->SOAP_ENV__Detail)
+ { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1);
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->SOAP_ENV__Detail);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Detail->__any;
+}
+
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap)
+{
+ int t;
+ if (soap->version == 1)
+ { for (;;)
+ { if (!soap_getelement(soap, &t))
+ if (soap->error || soap_ignore_element(soap))
+ break;
+ }
+ }
+ if (soap->error == SOAP_NO_TAG || soap->error == SOAP_EOF)
+ soap->error = SOAP_OK;
+ return soap->error;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type)
+{
+ if (soap_peek_element(soap))
+ return NULL;
+ if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id)))
+ *type = soap_lookup_type(soap, soap->href);
+ switch (*type)
+ {
+ case SOAP_TYPE_KMS_CA_byte:
+ return soap_in_byte(soap, NULL, NULL, "xsd:byte");
+ case SOAP_TYPE_KMS_CA_int:
+ return soap_in_int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_CA_xsd__int:
+ return soap_in_xsd__int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_CA_long:
+ return soap_in_long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_CA_xsd__long:
+ return soap_in_xsd__long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_CA_LONG64:
+ return soap_in_LONG64(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_CA_xsd__float:
+ return soap_in_xsd__float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_CA_float:
+ return soap_in_float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_CA_unsignedByte:
+ return soap_in_unsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_CA_unsignedInt:
+ return soap_in_unsignedInt(soap, NULL, NULL, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_CA_xsd__boolean:
+ return soap_in_xsd__boolean(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_CA_bool:
+ return soap_in_bool(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock:
+ return soap_in_KMS_CA__RetrieveLocalClock(soap, NULL, NULL, "KMS-CA:RetrieveLocalClock");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse:
+ return soap_in_KMS_CA__RetrieveLocalClockResponse(soap, NULL, NULL, "KMS-CA:RetrieveLocalClockResponse");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate:
+ return soap_in_KMS_CA__RetrieveRootCACertificate(soap, NULL, NULL, "KMS-CA:RetrieveRootCACertificate");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse:
+ return soap_in_KMS_CA__RetrieveRootCACertificateResponse(soap, NULL, NULL, "KMS-CA:RetrieveRootCACertificateResponse");
+ case SOAP_TYPE_KMS_CA_xsd__hexBinary:
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_CA_PointerTounsignedByte:
+ return soap_in_PointerTounsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_CA_xsd__duration:
+ { char **s;
+ s = soap_in_xsd__duration(soap, NULL, NULL, "xsd:duration");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_CA_xsd__dateTime:
+ { char **s;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, "xsd:dateTime");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_CA_xsd__string:
+ { char **s;
+ s = soap_in_xsd__string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_CA__QName:
+ { char **s;
+ s = soap_in__QName(soap, NULL, NULL, "xsd:QName");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_CA_string:
+ { char **s;
+ s = soap_in_string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ default:
+ { const char *t = soap->type;
+ if (!*t)
+ t = soap->tag;
+ if (!soap_match_tag(soap, t, "xsd:byte"))
+ { *type = SOAP_TYPE_KMS_CA_byte;
+ return soap_in_byte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_CA_int;
+ return soap_in_int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_CA_xsd__int;
+ return soap_in_xsd__int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_CA_long;
+ return soap_in_long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_CA_xsd__long;
+ return soap_in_xsd__long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_CA_LONG64;
+ return soap_in_LONG64(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_CA_xsd__float;
+ return soap_in_xsd__float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_CA_float;
+ return soap_in_float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedByte"))
+ { *type = SOAP_TYPE_KMS_CA_unsignedByte;
+ return soap_in_unsignedByte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedInt"))
+ { *type = SOAP_TYPE_KMS_CA_unsignedInt;
+ return soap_in_unsignedInt(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_CA_xsd__boolean;
+ return soap_in_xsd__boolean(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_CA_bool;
+ return soap_in_bool(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-CA:RetrieveLocalClock"))
+ { *type = SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock;
+ return soap_in_KMS_CA__RetrieveLocalClock(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-CA:RetrieveLocalClockResponse"))
+ { *type = SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse;
+ return soap_in_KMS_CA__RetrieveLocalClockResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-CA:RetrieveRootCACertificate"))
+ { *type = SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate;
+ return soap_in_KMS_CA__RetrieveRootCACertificate(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-CA:RetrieveRootCACertificateResponse"))
+ { *type = SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse;
+ return soap_in_KMS_CA__RetrieveRootCACertificateResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:hexBinary"))
+ { *type = SOAP_TYPE_KMS_CA_xsd__hexBinary;
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:duration"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_CA_xsd__duration;
+ s = soap_in_xsd__duration(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:dateTime"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_CA_xsd__dateTime;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_CA_xsd__string;
+ s = soap_in_xsd__string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:QName"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_CA__QName;
+ s = soap_in__QName(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_CA_string;
+ s = soap_in_string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ t = soap->tag;
+ }
+ }
+ soap->error = SOAP_TAG_MISMATCH;
+ return NULL;
+}
+#endif
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap)
+{
+ if (!soap_peek_element(soap))
+ { int t;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body));
+ if (soap->mustUnderstand && !soap->other)
+ return soap->error = SOAP_MUSTUNDERSTAND;
+ if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag));
+ return soap->error = SOAP_TAG_MISMATCH;
+ }
+ if (!*soap->id || !soap_getelement(soap, &t))
+ { soap->peeked = 0;
+ if (soap->fignore)
+ soap->error = soap->fignore(soap, soap->tag);
+ else
+ soap->error = SOAP_OK;
+ DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag));
+ if (!soap->error && soap->body)
+ { soap->level++;
+ while (!soap_ignore_element(soap))
+ ;
+ if (soap->error == SOAP_NO_TAG)
+ soap->error = soap_element_end_in(soap, NULL);
+ }
+ }
+ }
+ return soap->error;
+}
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap)
+{
+ int i;
+ struct soap_plist *pp;
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)))
+ for (i = 0; i < SOAP_PTRHASH; i++)
+ for (pp = soap->pht[i]; pp; pp = pp->next)
+ if (pp->mark1 == 2 || pp->mark2 == 2)
+ if (soap_putelement(soap, pp->ptr, "id", pp->id, pp->type))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, const char *tag, int id, int type)
+{
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_CA_byte:
+ return soap_out_byte(soap, tag, id, (const char *)ptr, "xsd:byte");
+ case SOAP_TYPE_KMS_CA_int:
+ return soap_out_int(soap, tag, id, (const int *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_CA_xsd__int:
+ return soap_out_xsd__int(soap, tag, id, (const long *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_CA_long:
+ return soap_out_long(soap, tag, id, (const long *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_CA_xsd__long:
+ return soap_out_xsd__long(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_CA_LONG64:
+ return soap_out_LONG64(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_CA_xsd__float:
+ return soap_out_xsd__float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_CA_float:
+ return soap_out_float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_CA_unsignedByte:
+ return soap_out_unsignedByte(soap, tag, id, (const unsigned char *)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_CA_unsignedInt:
+ return soap_out_unsignedInt(soap, tag, id, (const unsigned int *)ptr, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_CA_xsd__boolean:
+ return soap_out_xsd__boolean(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_CA_bool:
+ return soap_out_bool(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock:
+ return soap_out_KMS_CA__RetrieveLocalClock(soap, tag, id, (const struct KMS_CA__RetrieveLocalClock *)ptr, "KMS-CA:RetrieveLocalClock");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse:
+ return soap_out_KMS_CA__RetrieveLocalClockResponse(soap, tag, id, (const struct KMS_CA__RetrieveLocalClockResponse *)ptr, "KMS-CA:RetrieveLocalClockResponse");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate:
+ return soap_out_KMS_CA__RetrieveRootCACertificate(soap, tag, id, (const struct KMS_CA__RetrieveRootCACertificate *)ptr, "KMS-CA:RetrieveRootCACertificate");
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse:
+ return soap_out_KMS_CA__RetrieveRootCACertificateResponse(soap, tag, id, (const struct KMS_CA__RetrieveRootCACertificateResponse *)ptr, "KMS-CA:RetrieveRootCACertificateResponse");
+ case SOAP_TYPE_KMS_CA_xsd__hexBinary:
+ return soap_out_xsd__hexBinary(soap, tag, id, (const struct xsd__hexBinary *)ptr, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_CA_PointerTounsignedByte:
+ return soap_out_PointerTounsignedByte(soap, tag, id, (unsigned char *const*)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_CA_xsd__duration:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:duration");
+ case SOAP_TYPE_KMS_CA_xsd__dateTime:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:dateTime");
+ case SOAP_TYPE_KMS_CA_xsd__string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ case SOAP_TYPE_KMS_CA__QName:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:QName");
+ case SOAP_TYPE_KMS_CA_string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ }
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, int type)
+{
+ (void)soap; (void)ptr; (void)type; /* appease -Wall -Werror */
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock:
+ soap_serialize_KMS_CA__RetrieveLocalClock(soap, (const struct KMS_CA__RetrieveLocalClock *)ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse:
+ soap_serialize_KMS_CA__RetrieveLocalClockResponse(soap, (const struct KMS_CA__RetrieveLocalClockResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate:
+ soap_serialize_KMS_CA__RetrieveRootCACertificate(soap, (const struct KMS_CA__RetrieveRootCACertificate *)ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse:
+ soap_serialize_KMS_CA__RetrieveRootCACertificateResponse(soap, (const struct KMS_CA__RetrieveRootCACertificateResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_xsd__hexBinary:
+ soap_serialize_xsd__hexBinary(soap, (const struct xsd__hexBinary *)ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_PointerTounsignedByte:
+ soap_serialize_PointerTounsignedByte(soap, (unsigned char *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_xsd__duration:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_xsd__dateTime:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_xsd__string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_CA__QName:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ }
+}
+#endif
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n)
+{
+ switch (t)
+ {
+ case SOAP_TYPE_KMS_CA_xsd__hexBinary:
+ return (void*)soap_instantiate_xsd__hexBinary(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse:
+ return (void*)soap_instantiate_KMS_CA__RetrieveRootCACertificateResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate:
+ return (void*)soap_instantiate_KMS_CA__RetrieveRootCACertificate(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse:
+ return (void*)soap_instantiate_KMS_CA__RetrieveLocalClockResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock:
+ return (void*)soap_instantiate_KMS_CA__RetrieveLocalClock(soap, -1, type, arrayType, n);
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Header:
+ return (void*)soap_instantiate_SOAP_ENV__Header(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Code:
+ return (void*)soap_instantiate_SOAP_ENV__Code(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Detail:
+ return (void*)soap_instantiate_SOAP_ENV__Detail(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Reason:
+ return (void*)soap_instantiate_SOAP_ENV__Reason(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Fault:
+ return (void*)soap_instantiate_SOAP_ENV__Fault(soap, -1, type, arrayType, n);
+#endif
+ }
+ return NULL;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p)
+{ switch (p->type)
+ {
+ case SOAP_TYPE_KMS_CA_xsd__hexBinary:
+ if (p->size < 0)
+ SOAP_DELETE((struct xsd__hexBinary*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct xsd__hexBinary*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_CA__RetrieveRootCACertificateResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_CA__RetrieveRootCACertificateResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_CA__RetrieveRootCACertificate*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_CA__RetrieveRootCACertificate*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_CA__RetrieveLocalClockResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_CA__RetrieveLocalClockResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_CA__RetrieveLocalClock*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_CA__RetrieveLocalClock*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Header:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Code:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Detail:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Reason:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_CA_SOAP_ENV__Fault:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr);
+ break;
+ default: return SOAP_ERR;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType)
+{ return soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_byte
+ *a = SOAP_DEFAULT_byte;
+#else
+ *a = (char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type)
+{
+ return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_byte);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap *soap, const char *tag, char *a, const char *type)
+{ char *p;
+ p = soap_inbyte(soap, tag, a, type, SOAP_TYPE_KMS_CA_byte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap *soap, const char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_byte);
+ if (soap_out_byte(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap *soap, char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_byte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_int
+ *a = SOAP_DEFAULT_int;
+#else
+ *a = (int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type)
+{
+ return soap_outint(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_int);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap *soap, const char *tag, int *a, const char *type)
+{ int *p;
+ p = soap_inint(soap, tag, a, type, SOAP_TYPE_KMS_CA_int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap *soap, const int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_int);
+ if (soap_out_int(soap, tag?tag:"int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap *soap, int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_xsd__int);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_CA_xsd__int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__int);
+ if (soap_out_xsd__int(soap, tag?tag:"xsd:int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap *soap, long *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_long
+ *a = SOAP_DEFAULT_long;
+#else
+ *a = (long)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_long);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_CA_long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_long);
+ if (soap_out_long(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_xsd__long);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_CA_xsd__long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__long);
+ if (soap_out_xsd__long(soap, tag?tag:"xsd:long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap *soap, LONG64 *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_LONG64
+ *a = SOAP_DEFAULT_LONG64;
+#else
+ *a = (LONG64)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_LONG64);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_CA_LONG64);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_LONG64);
+ if (soap_out_LONG64(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_LONG64(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_xsd__float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_CA_xsd__float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__float);
+ if (soap_out_xsd__float(soap, tag?tag:"xsd:float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap *soap, float *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_float
+ *a = SOAP_DEFAULT_float;
+#else
+ *a = (float)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_CA_float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_float);
+ if (soap_out_float(soap, tag?tag:"float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap *soap, unsigned char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedByte
+ *a = SOAP_DEFAULT_unsignedByte;
+#else
+ *a = (unsigned char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *a, const char *type)
+{
+ return soap_outunsignedByte(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_unsignedByte);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap *soap, const char *tag, unsigned char *a, const char *type)
+{ unsigned char *p;
+ p = soap_inunsignedByte(soap, tag, a, type, SOAP_TYPE_KMS_CA_unsignedByte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap *soap, const unsigned char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_unsignedByte);
+ if (soap_out_unsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap *soap, unsigned char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap *soap, unsigned int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedInt
+ *a = SOAP_DEFAULT_unsignedInt;
+#else
+ *a = (unsigned int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *a, const char *type)
+{
+ return soap_outunsignedInt(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_unsignedInt);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap *soap, const char *tag, unsigned int *a, const char *type)
+{ unsigned int *p;
+ p = soap_inunsignedInt(soap, tag, a, type, SOAP_TYPE_KMS_CA_unsignedInt);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap *soap, const unsigned int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_unsignedInt);
+ if (soap_out_unsignedInt(soap, tag?tag:"unsignedInt", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap *soap, unsigned int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedInt(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap *soap, bool n)
+{ return soap_bool2s(soap, n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_xsd__boolean), type) || soap_send(soap, soap_xsd__boolean2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap *soap, const char *s, bool *a)
+{
+ return soap_s2bool(soap, s, a);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_xsd__boolean, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2xsd__boolean(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_xsd__boolean, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__boolean);
+ if (soap_out_xsd__boolean(soap, tag?tag:"xsd:boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__boolean(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap *soap, bool *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_bool
+ *a = SOAP_DEFAULT_bool;
+#else
+ *a = (bool)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_bool[] =
+{ { (long)false, "false" },
+ { (long)true, "true" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap *soap, bool n)
+{
+ (void)soap; /* appease -Wall -Werror */
+return soap_code_str(soap_codes_bool, n!=0);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_bool), type) || soap_send(soap, soap_bool2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap *soap, const char *s, bool *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_bool, s);
+ if (map)
+ *a = (bool)(map->code != 0);
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || n < 0 || n > 1)
+ return soap->error = SOAP_TYPE;
+ *a = (bool)(n != 0);
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_bool, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2bool(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_bool, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_bool);
+ if (soap_out_bool(soap, tag?tag:"boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_bool(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->faultcode);
+ soap_default_string(soap, &a->faultstring);
+ soap_default_string(soap, &a->faultactor);
+ a->detail = NULL;
+ a->SOAP_ENV__Code = NULL;
+ a->SOAP_ENV__Reason = NULL;
+ soap_default_string(soap, &a->SOAP_ENV__Node);
+ soap_default_string(soap, &a->SOAP_ENV__Role);
+ a->SOAP_ENV__Detail = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->faultcode);
+ soap_serialize_string(soap, &a->faultstring);
+ soap_serialize_string(soap, &a->faultactor);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->detail);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Code);
+ soap_serialize_PointerToSOAP_ENV__Reason(soap, &a->SOAP_ENV__Reason);
+ soap_serialize_string(soap, &a->SOAP_ENV__Node);
+ soap_serialize_string(soap, &a->SOAP_ENV__Role);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->SOAP_ENV__Detail);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type)
+{
+ const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Fault), type))
+ return soap->error;
+ if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, ""))
+ return soap->error;
+ if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "xsd:string"))
+ return soap->error;
+ if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "xsd:string"))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", -1, &a->SOAP_ENV__Code, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", -1, &a->SOAP_ENV__Reason, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Node", -1, &a->SOAP_ENV__Node, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Role", -1, &a->SOAP_ENV__Role, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", -1, &a->SOAP_ENV__Detail, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap *soap, const char *tag, struct SOAP_ENV__Fault *a, const char *type)
+{
+ size_t soap_flag_faultcode = 1;
+ size_t soap_flag_faultstring = 1;
+ size_t soap_flag_faultactor = 1;
+ size_t soap_flag_detail = 1;
+ size_t soap_flag_SOAP_ENV__Code = 1;
+ size_t soap_flag_SOAP_ENV__Reason = 1;
+ size_t soap_flag_SOAP_ENV__Node = 1;
+ size_t soap_flag_SOAP_ENV__Role = 1;
+ size_t soap_flag_SOAP_ENV__Detail = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Fault(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_faultcode && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "faultcode", &a->faultcode, ""))
+ { soap_flag_faultcode--;
+ continue;
+ }
+ if (soap_flag_faultstring && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultstring", &a->faultstring, "xsd:string"))
+ { soap_flag_faultstring--;
+ continue;
+ }
+ if (soap_flag_faultactor && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultactor", &a->faultactor, "xsd:string"))
+ { soap_flag_faultactor--;
+ continue;
+ }
+ if (soap_flag_detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "detail", &a->detail, ""))
+ { soap_flag_detail--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Code && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", &a->SOAP_ENV__Code, ""))
+ { soap_flag_SOAP_ENV__Code--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Reason && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", &a->SOAP_ENV__Reason, ""))
+ { soap_flag_SOAP_ENV__Reason--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Node && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Node", &a->SOAP_ENV__Node, "xsd:string"))
+ { soap_flag_SOAP_ENV__Node--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Role && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Role", &a->SOAP_ENV__Role, "xsd:string"))
+ { soap_flag_SOAP_ENV__Role--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", &a->SOAP_ENV__Detail, ""))
+ { soap_flag_SOAP_ENV__Detail--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_SOAP_ENV__Fault, 0, sizeof(struct SOAP_ENV__Fault), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_SOAP_ENV__Fault);
+ if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Fault(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_SOAP_ENV__Fault, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Fault);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Fault);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Fault*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason), type))
+ return soap->error;
+ if (soap->lang)
+ soap_set_attr(soap, "xml:lang", soap->lang, 1);
+ if (soap_out_string(soap, "SOAP-ENV:Text", -1, &a->SOAP_ENV__Text, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Text = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Reason(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Text && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Text", &a->SOAP_ENV__Text, "xsd:string"))
+ { soap_flag_SOAP_ENV__Text--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason, 0, sizeof(struct SOAP_ENV__Reason), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason);
+ if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Reason);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Reason);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Reason*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ a->__type = 0;
+ a->fault = NULL;
+ a->__any = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_markelement(soap, a->fault, a->__type);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail), type))
+ return soap->error;
+ if (soap_putelement(soap, a->fault, "fault", -1, a->__type))
+ return soap->error;
+ soap_outliteral(soap, "-any", &a->__any, NULL);
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail *a, const char *type)
+{
+ size_t soap_flag_fault = 1;
+ size_t soap_flag___any = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Detail(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_fault && soap->error == SOAP_TAG_MISMATCH)
+ if ((a->fault = soap_getelement(soap, &a->__type)))
+ { soap_flag_fault = 0;
+ continue;
+ }
+ if (soap_flag___any && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_inliteral(soap, "-any", &a->__any))
+ { soap_flag___any--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail, 0, sizeof(struct SOAP_ENV__Detail), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail);
+ if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Detail);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Detail);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Detail*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->SOAP_ENV__Value);
+ a->SOAP_ENV__Subcode = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->SOAP_ENV__Value);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Subcode);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type)
+{
+ const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Code), type))
+ return soap->error;
+ if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Value = 1;
+ size_t soap_flag_SOAP_ENV__Subcode = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Code(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Value && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "SOAP-ENV:Value", &a->SOAP_ENV__Value, ""))
+ { soap_flag_SOAP_ENV__Value--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Subcode && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", &a->SOAP_ENV__Subcode, ""))
+ { soap_flag_SOAP_ENV__Subcode--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_SOAP_ENV__Code, 0, sizeof(struct SOAP_ENV__Code), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_SOAP_ENV__Code);
+ if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_SOAP_ENV__Code, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Code);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Code);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Code*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Header), type))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap *soap, const char *tag, struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Header(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_SOAP_ENV__Header, 0, sizeof(struct SOAP_ENV__Header), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_SOAP_ENV__Header);
+ if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Header(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_SOAP_ENV__Header, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Header);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Header);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Header*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveLocalClock(struct soap *soap, struct KMS_CA__RetrieveLocalClock *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->EntityID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveLocalClock(struct soap *soap, const struct KMS_CA__RetrieveLocalClock *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->EntityID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveLocalClock(struct soap *soap, const char *tag, int id, const struct KMS_CA__RetrieveLocalClock *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "EntityID", -1, &a->EntityID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClock * SOAP_FMAC4 soap_in_KMS_CA__RetrieveLocalClock(struct soap *soap, const char *tag, struct KMS_CA__RetrieveLocalClock *a, const char *type)
+{
+ size_t soap_flag_EntityID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_CA__RetrieveLocalClock *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock, sizeof(struct KMS_CA__RetrieveLocalClock), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_CA__RetrieveLocalClock(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_EntityID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "EntityID", &a->EntityID, "xsd:string"))
+ { soap_flag_EntityID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_CA__RetrieveLocalClock *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock, 0, sizeof(struct KMS_CA__RetrieveLocalClock), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveLocalClock(struct soap *soap, const struct KMS_CA__RetrieveLocalClock *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock);
+ if (soap_out_KMS_CA__RetrieveLocalClock(soap, tag?tag:"KMS-CA:RetrieveLocalClock", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClock * SOAP_FMAC4 soap_get_KMS_CA__RetrieveLocalClock(struct soap *soap, struct KMS_CA__RetrieveLocalClock *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_CA__RetrieveLocalClock(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_CA__RetrieveLocalClock * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveLocalClock(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_CA__RetrieveLocalClock(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveLocalClock);
+ if (size)
+ *size = sizeof(struct KMS_CA__RetrieveLocalClock);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveLocalClock[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_CA__RetrieveLocalClock);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_CA__RetrieveLocalClock*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveLocalClock(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_CA__RetrieveLocalClock %p -> %p\n", q, p));
+ *(struct KMS_CA__RetrieveLocalClock*)p = *(struct KMS_CA__RetrieveLocalClock*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, struct KMS_CA__RetrieveLocalClockResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__dateTime(soap, &a->CurrentTime);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, const struct KMS_CA__RetrieveLocalClockResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__dateTime(soap, &a->CurrentTime);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, const char *tag, int id, const struct KMS_CA__RetrieveLocalClockResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse), type))
+ return soap->error;
+ if (soap_out_xsd__dateTime(soap, "CurrentTime", -1, &a->CurrentTime, "xsd:dateTime"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClockResponse * SOAP_FMAC4 soap_in_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, const char *tag, struct KMS_CA__RetrieveLocalClockResponse *a, const char *type)
+{
+ size_t soap_flag_CurrentTime = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_CA__RetrieveLocalClockResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse, sizeof(struct KMS_CA__RetrieveLocalClockResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_CA__RetrieveLocalClockResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_CurrentTime && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__dateTime(soap, "CurrentTime", &a->CurrentTime, "xsd:dateTime"))
+ { soap_flag_CurrentTime--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_CA__RetrieveLocalClockResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse, 0, sizeof(struct KMS_CA__RetrieveLocalClockResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, const struct KMS_CA__RetrieveLocalClockResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse);
+ if (soap_out_KMS_CA__RetrieveLocalClockResponse(soap, tag?tag:"KMS-CA:RetrieveLocalClockResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClockResponse * SOAP_FMAC4 soap_get_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, struct KMS_CA__RetrieveLocalClockResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_CA__RetrieveLocalClockResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_CA__RetrieveLocalClockResponse * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_CA__RetrieveLocalClockResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveLocalClockResponse);
+ if (size)
+ *size = sizeof(struct KMS_CA__RetrieveLocalClockResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveLocalClockResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_CA__RetrieveLocalClockResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_CA__RetrieveLocalClockResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveLocalClockResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_CA__RetrieveLocalClockResponse %p -> %p\n", q, p));
+ *(struct KMS_CA__RetrieveLocalClockResponse*)p = *(struct KMS_CA__RetrieveLocalClockResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveRootCACertificate(struct soap *soap, struct KMS_CA__RetrieveRootCACertificate *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->EntityID);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveRootCACertificate(struct soap *soap, const struct KMS_CA__RetrieveRootCACertificate *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->EntityID);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveRootCACertificate(struct soap *soap, const char *tag, int id, const struct KMS_CA__RetrieveRootCACertificate *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "EntityID", -1, &a->EntityID, "xsd:string"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificate * SOAP_FMAC4 soap_in_KMS_CA__RetrieveRootCACertificate(struct soap *soap, const char *tag, struct KMS_CA__RetrieveRootCACertificate *a, const char *type)
+{
+ size_t soap_flag_EntityID = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_CA__RetrieveRootCACertificate *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate, sizeof(struct KMS_CA__RetrieveRootCACertificate), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_CA__RetrieveRootCACertificate(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_EntityID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "EntityID", &a->EntityID, "xsd:string"))
+ { soap_flag_EntityID--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_CA__RetrieveRootCACertificate *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate, 0, sizeof(struct KMS_CA__RetrieveRootCACertificate), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveRootCACertificate(struct soap *soap, const struct KMS_CA__RetrieveRootCACertificate *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate);
+ if (soap_out_KMS_CA__RetrieveRootCACertificate(soap, tag?tag:"KMS-CA:RetrieveRootCACertificate", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificate * SOAP_FMAC4 soap_get_KMS_CA__RetrieveRootCACertificate(struct soap *soap, struct KMS_CA__RetrieveRootCACertificate *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_CA__RetrieveRootCACertificate(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_CA__RetrieveRootCACertificate * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveRootCACertificate(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_CA__RetrieveRootCACertificate(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveRootCACertificate);
+ if (size)
+ *size = sizeof(struct KMS_CA__RetrieveRootCACertificate);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveRootCACertificate[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_CA__RetrieveRootCACertificate);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_CA__RetrieveRootCACertificate*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveRootCACertificate(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_CA__RetrieveRootCACertificate %p -> %p\n", q, p));
+ *(struct KMS_CA__RetrieveRootCACertificate*)p = *(struct KMS_CA__RetrieveRootCACertificate*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, struct KMS_CA__RetrieveRootCACertificateResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__hexBinary(soap, &a->RootCACertificate);
+ soap_default_xsd__int(soap, &a->AuthenticationHashIterationCount);
+ soap_default_xsd__hexBinary(soap, &a->ClientAuthenticationChallenge);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, const struct KMS_CA__RetrieveRootCACertificateResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__hexBinary(soap, &a->RootCACertificate);
+ soap_serialize_xsd__hexBinary(soap, &a->ClientAuthenticationChallenge);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, const char *tag, int id, const struct KMS_CA__RetrieveRootCACertificateResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse), type))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "RootCACertificate", -1, &a->RootCACertificate, "xsd:hexBinary"))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "AuthenticationHashIterationCount", -1, &a->AuthenticationHashIterationCount, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "ClientAuthenticationChallenge", -1, &a->ClientAuthenticationChallenge, "xsd:hexBinary"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificateResponse * SOAP_FMAC4 soap_in_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, const char *tag, struct KMS_CA__RetrieveRootCACertificateResponse *a, const char *type)
+{
+ size_t soap_flag_RootCACertificate = 1;
+ size_t soap_flag_AuthenticationHashIterationCount = 1;
+ size_t soap_flag_ClientAuthenticationChallenge = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_CA__RetrieveRootCACertificateResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse, sizeof(struct KMS_CA__RetrieveRootCACertificateResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_CA__RetrieveRootCACertificateResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_RootCACertificate && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "RootCACertificate", &a->RootCACertificate, "xsd:hexBinary"))
+ { soap_flag_RootCACertificate--;
+ continue;
+ }
+ if (soap_flag_AuthenticationHashIterationCount && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "AuthenticationHashIterationCount", &a->AuthenticationHashIterationCount, "xsd:int"))
+ { soap_flag_AuthenticationHashIterationCount--;
+ continue;
+ }
+ if (soap_flag_ClientAuthenticationChallenge && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "ClientAuthenticationChallenge", &a->ClientAuthenticationChallenge, "xsd:hexBinary"))
+ { soap_flag_ClientAuthenticationChallenge--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_CA__RetrieveRootCACertificateResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse, 0, sizeof(struct KMS_CA__RetrieveRootCACertificateResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_RootCACertificate > 0 || soap_flag_AuthenticationHashIterationCount > 0 || soap_flag_ClientAuthenticationChallenge > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, const struct KMS_CA__RetrieveRootCACertificateResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse);
+ if (soap_out_KMS_CA__RetrieveRootCACertificateResponse(soap, tag?tag:"KMS-CA:RetrieveRootCACertificateResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificateResponse * SOAP_FMAC4 soap_get_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, struct KMS_CA__RetrieveRootCACertificateResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_CA__RetrieveRootCACertificateResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_CA__RetrieveRootCACertificateResponse * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_CA__RetrieveRootCACertificateResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveRootCACertificateResponse);
+ if (size)
+ *size = sizeof(struct KMS_CA__RetrieveRootCACertificateResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_CA__RetrieveRootCACertificateResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_CA__RetrieveRootCACertificateResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_CA__RetrieveRootCACertificateResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveRootCACertificateResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_CA__RetrieveRootCACertificateResponse %p -> %p\n", q, p));
+ *(struct KMS_CA__RetrieveRootCACertificateResponse*)p = *(struct KMS_CA__RetrieveRootCACertificateResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary const*a)
+{
+ if (a->__ptr)
+ soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_CA_xsd__hexBinary);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap *soap, const char *tag, int id, const struct xsd__hexBinary *a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_CA_xsd__hexBinary);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ if (soap_puthex(soap, a->__ptr, a->__size))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap *soap, const char *tag, struct xsd__hexBinary *a, const char *type)
+{
+ (void)type; /* appease -Wall -Werror */
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":hexBinary"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct xsd__hexBinary *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_CA_xsd__hexBinary, sizeof(struct xsd__hexBinary), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_xsd__hexBinary(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__ptr = soap_gethex(soap, &a->__size);
+ if ((!a->__ptr && soap->error) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct xsd__hexBinary *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_CA_xsd__hexBinary, 0, sizeof(struct xsd__hexBinary), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap *soap, const struct xsd__hexBinary *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_CA_xsd__hexBinary);
+ if (soap_out_xsd__hexBinary(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__hexBinary(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_xsd__hexBinary(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_CA_xsd__hexBinary, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary);
+ if (size)
+ *size = sizeof(struct xsd__hexBinary);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct xsd__hexBinary);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct xsd__hexBinary*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct xsd__hexBinary %p -> %p\n", q, p));
+ *(struct xsd__hexBinary*)p = *(struct xsd__hexBinary*)q;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason))
+ soap_serialize_SOAP_ENV__Reason(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Reason *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Reason(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Reason **)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Reason(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_CA_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Reason);
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail))
+ soap_serialize_SOAP_ENV__Detail(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Detail *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Detail(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Detail **)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Detail(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_CA_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Detail);
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_CA_SOAP_ENV__Code))
+ soap_serialize_SOAP_ENV__Code(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Code *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_CA_SOAP_ENV__Code);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Code(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Code **)soap_malloc(soap, sizeof(struct SOAP_ENV__Code *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Code(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_CA_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Code);
+ if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap *soap, unsigned char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_CA_unsignedByte);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap *soap, const char *tag, int id, unsigned char *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_CA_unsignedByte);
+ if (id < 0)
+ return soap->error;
+ return soap_out_unsignedByte(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap *soap, const char *tag, unsigned char **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (unsigned char **)soap_malloc(soap, sizeof(unsigned char *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_unsignedByte(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (unsigned char **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_CA_unsignedByte, sizeof(unsigned char), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap *soap, unsigned char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_PointerTounsignedByte);
+ if (soap_out_PointerTounsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap *soap, unsigned char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerTounsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_xsd__duration);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_CA_xsd__duration, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__duration);
+ if (soap_out_xsd__duration(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__duration(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_xsd__dateTime);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_CA_xsd__dateTime, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__dateTime);
+ if (soap_out_xsd__dateTime(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__dateTime(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_xsd__string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_CA_xsd__string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_xsd__string);
+ if (soap_out_xsd__string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_CA__QName);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_CA__QName, 2, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA__QName);
+ if (soap_out__QName(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in__QName(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap *soap, char **a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_string
+ *a = SOAP_DEFAULT_string;
+#else
+ *a = (char *)0;
+#endif
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_CA_string);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_CA_string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_CA_string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_CA_string);
+ if (soap_out_string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+} // namespace KMS_CA
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_CAC.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CAClient.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAClient.cpp
new file mode 100644
index 0000000000..b5ea12986d
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAClient.cpp
@@ -0,0 +1,148 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CAClient.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CAService/KMS_CA_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+#include "KMS_CAH.h"
+
+namespace KMS_CA {
+
+SOAP_SOURCE_STAMP("@(#) KMS_CAClient.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_CA__RetrieveRootCACertificate(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *EntityID, struct KMS_CA__RetrieveRootCACertificateResponse &result)
+{ struct KMS_CA__RetrieveRootCACertificate soap_tmp_KMS_CA__RetrieveRootCACertificate;
+ soap_tmp_KMS_CA__RetrieveRootCACertificate.EntityID = EntityID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_CA__RetrieveRootCACertificate(soap, &soap_tmp_KMS_CA__RetrieveRootCACertificate);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_CA__RetrieveRootCACertificate(soap, &soap_tmp_KMS_CA__RetrieveRootCACertificate, "KMS-CA:RetrieveRootCACertificate", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_CA__RetrieveRootCACertificate(soap, &soap_tmp_KMS_CA__RetrieveRootCACertificate, "KMS-CA:RetrieveRootCACertificate", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_CA__RetrieveRootCACertificateResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_CA__RetrieveRootCACertificateResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_CA__RetrieveLocalClock(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *EntityID, struct KMS_CA__RetrieveLocalClockResponse &result)
+{ struct KMS_CA__RetrieveLocalClock soap_tmp_KMS_CA__RetrieveLocalClock;
+ soap_tmp_KMS_CA__RetrieveLocalClock.EntityID = EntityID;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_CA__RetrieveLocalClock(soap, &soap_tmp_KMS_CA__RetrieveLocalClock);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_CA__RetrieveLocalClock(soap, &soap_tmp_KMS_CA__RetrieveLocalClock, "KMS-CA:RetrieveLocalClock", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_CA__RetrieveLocalClock(soap, &soap_tmp_KMS_CA__RetrieveLocalClock, "KMS-CA:RetrieveLocalClock", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_CA__RetrieveLocalClockResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_CA__RetrieveLocalClockResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+} // namespace KMS_CA
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_CAClient.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CAH.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAH.h
new file mode 100644
index 0000000000..80835bb84b
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAH.h
@@ -0,0 +1,702 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CAH.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CAService/KMS_CA_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_CAH_H
+#define KMS_CAH_H
+#include "KMS_CAStub.h"
+
+namespace KMS_CA {
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
+SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_byte
+#define SOAP_TYPE_KMS_CA_byte (3)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*);
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*);
+
+#define soap_write_byte(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_byte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*);
+
+#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_int
+#define SOAP_TYPE_KMS_CA_int (1)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*);
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*);
+
+#define soap_write_int(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*);
+
+#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__int
+#define SOAP_TYPE_KMS_CA_xsd__int (11)
+#endif
+
+#define soap_default_xsd__int(soap, a) soap_default_long(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap*, const char*, long *, const char*);
+
+#define soap_write_xsd__int(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_xsd__int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_xsd__int(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_long
+#define SOAP_TYPE_KMS_CA_long (10)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap*, long *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap*, const char*, long *, const char*);
+
+#define soap_write_long(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_long(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__long
+#define SOAP_TYPE_KMS_CA_xsd__long (15)
+#endif
+
+#define soap_default_xsd__long(soap, a) soap_default_LONG64(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_xsd__long(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_xsd__long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_xsd__long(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_LONG64
+#define SOAP_TYPE_KMS_CA_LONG64 (14)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap*, LONG64 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_LONG64(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_LONG64(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_LONG64(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_LONG64(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__float
+#define SOAP_TYPE_KMS_CA_xsd__float (9)
+#endif
+
+#define soap_default_xsd__float(soap, a) soap_default_float(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_xsd__float(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_xsd__float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_xsd__float(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_float
+#define SOAP_TYPE_KMS_CA_float (8)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap*, float *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_float(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_float(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_unsignedByte
+#define SOAP_TYPE_KMS_CA_unsignedByte (20)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap*, unsigned char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap*, const char*, int, const unsigned char *, const char*);
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap*, const char*, unsigned char *, const char*);
+
+#define soap_write_unsignedByte(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_unsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap*, const unsigned char *, const char*, const char*);
+
+#define soap_read_unsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_unsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap*, unsigned char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_unsignedInt
+#define SOAP_TYPE_KMS_CA_unsignedInt (19)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap*, unsigned int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap*, const char*, int, const unsigned int *, const char*);
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap*, const char*, unsigned int *, const char*);
+
+#define soap_write_unsignedInt(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_unsignedInt(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap*, const unsigned int *, const char*, const char*);
+
+#define soap_read_unsignedInt(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_unsignedInt(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap*, unsigned int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__boolean
+#define SOAP_TYPE_KMS_CA_xsd__boolean (13)
+#endif
+
+#define soap_default_xsd__boolean(soap, a) soap_default_bool(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap*, const char*, bool *);
+
+#define soap_write_xsd__boolean(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_xsd__boolean(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_xsd__boolean(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__boolean(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap*, bool *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_bool
+#define SOAP_TYPE_KMS_CA_bool (12)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap*, bool *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap*, const char*, bool *);
+
+#define soap_write_bool(soap, data) ( soap_begin_send(soap) || KMS_CA::soap_put_bool(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_bool(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_bool(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap*, bool *, const char*, const char*);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Fault (37)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*);
+
+#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_SOAP_ENV__Fault(soap, data), 0) || KMS_CA::soap_put_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Fault(soap, n) soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Fault(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Reason (36)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*);
+
+#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_SOAP_ENV__Reason(soap, data), 0) || KMS_CA::soap_put_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Reason(soap, n) soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Reason(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Detail (33)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*);
+
+#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_SOAP_ENV__Detail(soap, data), 0) || KMS_CA::soap_put_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Detail(soap, n) soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Detail(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Code (31)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*);
+
+#define soap_write_SOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_SOAP_ENV__Code(soap, data), 0) || KMS_CA::soap_put_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Code(soap, n) soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Code(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Header (30)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*);
+
+#define soap_write_SOAP_ENV__Header(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_SOAP_ENV__Header(soap, data), 0) || KMS_CA::soap_put_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Header(soap, n) soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Header(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock (29)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveLocalClock(struct soap*, struct KMS_CA__RetrieveLocalClock *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveLocalClock(struct soap*, const struct KMS_CA__RetrieveLocalClock *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveLocalClock(struct soap*, const char*, int, const struct KMS_CA__RetrieveLocalClock *, const char*);
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClock * SOAP_FMAC4 soap_in_KMS_CA__RetrieveLocalClock(struct soap*, const char*, struct KMS_CA__RetrieveLocalClock *, const char*);
+
+#define soap_write_KMS_CA__RetrieveLocalClock(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_KMS_CA__RetrieveLocalClock(soap, data), 0) || KMS_CA::soap_put_KMS_CA__RetrieveLocalClock(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveLocalClock(struct soap*, const struct KMS_CA__RetrieveLocalClock *, const char*, const char*);
+
+#define soap_read_KMS_CA__RetrieveLocalClock(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_KMS_CA__RetrieveLocalClock(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClock * SOAP_FMAC4 soap_get_KMS_CA__RetrieveLocalClock(struct soap*, struct KMS_CA__RetrieveLocalClock *, const char*, const char*);
+
+#define soap_new_KMS_CA__RetrieveLocalClock(soap, n) soap_instantiate_KMS_CA__RetrieveLocalClock(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_CA__RetrieveLocalClock(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_CA__RetrieveLocalClock * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveLocalClock(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveLocalClock(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse (26)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveLocalClockResponse(struct soap*, struct KMS_CA__RetrieveLocalClockResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveLocalClockResponse(struct soap*, const struct KMS_CA__RetrieveLocalClockResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveLocalClockResponse(struct soap*, const char*, int, const struct KMS_CA__RetrieveLocalClockResponse *, const char*);
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClockResponse * SOAP_FMAC4 soap_in_KMS_CA__RetrieveLocalClockResponse(struct soap*, const char*, struct KMS_CA__RetrieveLocalClockResponse *, const char*);
+
+#define soap_write_KMS_CA__RetrieveLocalClockResponse(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_KMS_CA__RetrieveLocalClockResponse(soap, data), 0) || KMS_CA::soap_put_KMS_CA__RetrieveLocalClockResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveLocalClockResponse(struct soap*, const struct KMS_CA__RetrieveLocalClockResponse *, const char*, const char*);
+
+#define soap_read_KMS_CA__RetrieveLocalClockResponse(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_KMS_CA__RetrieveLocalClockResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_CA__RetrieveLocalClockResponse * SOAP_FMAC4 soap_get_KMS_CA__RetrieveLocalClockResponse(struct soap*, struct KMS_CA__RetrieveLocalClockResponse *, const char*, const char*);
+
+#define soap_new_KMS_CA__RetrieveLocalClockResponse(soap, n) soap_instantiate_KMS_CA__RetrieveLocalClockResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_CA__RetrieveLocalClockResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_CA__RetrieveLocalClockResponse * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveLocalClockResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveLocalClockResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate (25)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveRootCACertificate(struct soap*, struct KMS_CA__RetrieveRootCACertificate *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveRootCACertificate(struct soap*, const struct KMS_CA__RetrieveRootCACertificate *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveRootCACertificate(struct soap*, const char*, int, const struct KMS_CA__RetrieveRootCACertificate *, const char*);
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificate * SOAP_FMAC4 soap_in_KMS_CA__RetrieveRootCACertificate(struct soap*, const char*, struct KMS_CA__RetrieveRootCACertificate *, const char*);
+
+#define soap_write_KMS_CA__RetrieveRootCACertificate(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_KMS_CA__RetrieveRootCACertificate(soap, data), 0) || KMS_CA::soap_put_KMS_CA__RetrieveRootCACertificate(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveRootCACertificate(struct soap*, const struct KMS_CA__RetrieveRootCACertificate *, const char*, const char*);
+
+#define soap_read_KMS_CA__RetrieveRootCACertificate(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_KMS_CA__RetrieveRootCACertificate(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificate * SOAP_FMAC4 soap_get_KMS_CA__RetrieveRootCACertificate(struct soap*, struct KMS_CA__RetrieveRootCACertificate *, const char*, const char*);
+
+#define soap_new_KMS_CA__RetrieveRootCACertificate(soap, n) soap_instantiate_KMS_CA__RetrieveRootCACertificate(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_CA__RetrieveRootCACertificate(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_CA__RetrieveRootCACertificate * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveRootCACertificate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveRootCACertificate(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse (22)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, struct KMS_CA__RetrieveRootCACertificateResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, const struct KMS_CA__RetrieveRootCACertificateResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, const char*, int, const struct KMS_CA__RetrieveRootCACertificateResponse *, const char*);
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificateResponse * SOAP_FMAC4 soap_in_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, const char*, struct KMS_CA__RetrieveRootCACertificateResponse *, const char*);
+
+#define soap_write_KMS_CA__RetrieveRootCACertificateResponse(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_KMS_CA__RetrieveRootCACertificateResponse(soap, data), 0) || KMS_CA::soap_put_KMS_CA__RetrieveRootCACertificateResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, const struct KMS_CA__RetrieveRootCACertificateResponse *, const char*, const char*);
+
+#define soap_read_KMS_CA__RetrieveRootCACertificateResponse(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_KMS_CA__RetrieveRootCACertificateResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_CA__RetrieveRootCACertificateResponse * SOAP_FMAC4 soap_get_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, struct KMS_CA__RetrieveRootCACertificateResponse *, const char*, const char*);
+
+#define soap_new_KMS_CA__RetrieveRootCACertificateResponse(soap, n) soap_instantiate_KMS_CA__RetrieveRootCACertificateResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_CA__RetrieveRootCACertificateResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_CA__RetrieveRootCACertificateResponse * SOAP_FMAC2 soap_instantiate_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_CA__RetrieveRootCACertificateResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__hexBinary
+#define SOAP_TYPE_KMS_CA_xsd__hexBinary (18)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap*, struct xsd__hexBinary *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap*, struct xsd__hexBinary const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap*, const char*, int, const struct xsd__hexBinary *, const char*);
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap*, const char*, struct xsd__hexBinary *, const char*);
+
+#define soap_write_xsd__hexBinary(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_xsd__hexBinary(soap, data), 0) || KMS_CA::soap_put_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap*, const struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_read_xsd__hexBinary(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap*, struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_new_xsd__hexBinary(soap, n) soap_instantiate_xsd__hexBinary(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_xsd__hexBinary(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Reason
+#define SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Reason (39)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_PointerToSOAP_ENV__Reason(soap, data), 0) || KMS_CA::soap_put_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Detail
+#define SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Detail (38)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_PointerToSOAP_ENV__Detail(soap, data), 0) || KMS_CA::soap_put_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Code
+#define SOAP_TYPE_KMS_CA_PointerToSOAP_ENV__Code (32)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_PointerToSOAP_ENV__Code(soap, data), 0) || KMS_CA::soap_put_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_PointerTounsignedByte
+#define SOAP_TYPE_KMS_CA_PointerTounsignedByte (21)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap*, unsigned char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap*, const char *, int, unsigned char *const*, const char *);
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap*, const char*, unsigned char **, const char*);
+
+#define soap_write_PointerTounsignedByte(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_PointerTounsignedByte(soap, data), 0) || KMS_CA::soap_put_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap*, unsigned char *const*, const char*, const char*);
+
+#define soap_read_PointerTounsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap*, unsigned char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__duration
+#define SOAP_TYPE_KMS_CA_xsd__duration (17)
+#endif
+
+#define soap_default_xsd__duration(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__duration(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__duration(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_xsd__duration(soap, data), 0) || KMS_CA::soap_put_xsd__duration(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__duration(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__duration(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__dateTime
+#define SOAP_TYPE_KMS_CA_xsd__dateTime (16)
+#endif
+
+#define soap_default_xsd__dateTime(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__dateTime(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__dateTime(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_xsd__dateTime(soap, data), 0) || KMS_CA::soap_put_xsd__dateTime(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__dateTime(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__dateTime(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__string
+#define SOAP_TYPE_KMS_CA_xsd__string (7)
+#endif
+
+#define soap_default_xsd__string(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__string(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__string(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_xsd__string(soap, data), 0) || KMS_CA::soap_put_xsd__string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__string(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_xsd__string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA__QName
+#define SOAP_TYPE_KMS_CA__QName (5)
+#endif
+
+#define soap_default__QName(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize__QName(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*);
+
+#define soap_write__QName(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize__QName(soap, data), 0) || KMS_CA::soap_put__QName(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_CA_string
+#define SOAP_TYPE_KMS_CA_string (4)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_string(soap, data) ( soap_begin_send(soap) || (KMS_CA::soap_serialize_string(soap, data), 0) || KMS_CA::soap_put_string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !KMS_CA::soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*);
+
+} // namespace KMS_CA
+
+
+#endif
+
+/* End of KMS_CAH.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CAStub.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAStub.h
new file mode 100644
index 0000000000..2eef609acc
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CAStub.h
@@ -0,0 +1,286 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CAStub.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CAService/KMS_CA_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_CAStub_H
+#define KMS_CAStub_H
+#ifndef WITH_NONAMESPACES
+#define WITH_NONAMESPACES
+#endif
+#ifndef WITH_NOGLOBAL
+#define WITH_NOGLOBAL
+#endif
+#include "stdsoap2.h"
+
+namespace KMS_CA {
+
+/******************************************************************************\
+ * *
+ * Enumerations *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Types with Custom Serializers *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Classes and Structs *
+ * *
+\******************************************************************************/
+
+
+#if 0 /* volatile type: do not declare here, declared elsewhere */
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__hexBinary
+#define SOAP_TYPE_KMS_CA_xsd__hexBinary (18)
+/* hexBinary schema type: */
+struct xsd__hexBinary
+{
+public:
+ unsigned char *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificateResponse (22)
+/* KMS-CA:RetrieveRootCACertificateResponse */
+struct KMS_CA__RetrieveRootCACertificateResponse
+{
+public:
+ struct xsd__hexBinary RootCACertificate; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type xsd:hexBinary */
+ long AuthenticationHashIterationCount; /* required element of type xsd:int */
+ struct xsd__hexBinary ClientAuthenticationChallenge; /* required element of type xsd:hexBinary */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveRootCACertificate (25)
+/* KMS-CA:RetrieveRootCACertificate */
+struct KMS_CA__RetrieveRootCACertificate
+{
+public:
+ char *EntityID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClockResponse (26)
+/* KMS-CA:RetrieveLocalClockResponse */
+struct KMS_CA__RetrieveLocalClockResponse
+{
+public:
+ char *CurrentTime; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:dateTime */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock
+#define SOAP_TYPE_KMS_CA_KMS_CA__RetrieveLocalClock (29)
+/* KMS-CA:RetrieveLocalClock */
+struct KMS_CA__RetrieveLocalClock
+{
+public:
+ char *EntityID; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Header (30)
+/* SOAP Header: */
+struct SOAP_ENV__Header
+{
+#ifdef WITH_NOEMPTYSTRUCT
+private:
+ char dummy; /* dummy member to enable compilation */
+#endif
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Code (31)
+/* SOAP Fault Code: */
+struct SOAP_ENV__Code
+{
+public:
+ char *SOAP_ENV__Value; /* optional element of type xsd:QName */
+ struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Detail (33)
+/* SOAP-ENV:Detail */
+struct SOAP_ENV__Detail
+{
+public:
+ int __type; /* any type of element <fault> (defined below) */
+ void *fault; /* transient */
+ char *__any;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Reason (36)
+/* SOAP-ENV:Reason */
+struct SOAP_ENV__Reason
+{
+public:
+ char *SOAP_ENV__Text; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_CA_SOAP_ENV__Fault (37)
+/* SOAP Fault: */
+struct SOAP_ENV__Fault
+{
+public:
+ char *faultcode; /* optional element of type xsd:QName */
+ char *faultstring; /* optional element of type xsd:string */
+ char *faultactor; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */
+ struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */
+ struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */
+ char *SOAP_ENV__Node; /* optional element of type xsd:string */
+ char *SOAP_ENV__Role; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */
+};
+#endif
+
+/******************************************************************************\
+ * *
+ * Typedefs *
+ * *
+\******************************************************************************/
+
+#ifndef SOAP_TYPE_KMS_CA__QName
+#define SOAP_TYPE_KMS_CA__QName (5)
+typedef char *_QName;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA__XML
+#define SOAP_TYPE_KMS_CA__XML (6)
+typedef char *_XML;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__string
+#define SOAP_TYPE_KMS_CA_xsd__string (7)
+typedef char *xsd__string;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__float
+#define SOAP_TYPE_KMS_CA_xsd__float (9)
+typedef float xsd__float;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__int
+#define SOAP_TYPE_KMS_CA_xsd__int (11)
+typedef long xsd__int;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__boolean
+#define SOAP_TYPE_KMS_CA_xsd__boolean (13)
+typedef bool xsd__boolean;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__long
+#define SOAP_TYPE_KMS_CA_xsd__long (15)
+typedef LONG64 xsd__long;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__dateTime
+#define SOAP_TYPE_KMS_CA_xsd__dateTime (16)
+typedef char *xsd__dateTime;
+#endif
+
+#ifndef SOAP_TYPE_KMS_CA_xsd__duration
+#define SOAP_TYPE_KMS_CA_xsd__duration (17)
+typedef char *xsd__duration;
+#endif
+
+
+/******************************************************************************\
+ * *
+ * Externals *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Server-Side Operations *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_CA__RetrieveRootCACertificate(struct soap*, char *EntityID, struct KMS_CA__RetrieveRootCACertificateResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_CA__RetrieveLocalClock(struct soap*, char *EntityID, struct KMS_CA__RetrieveLocalClockResponse &result);
+
+/******************************************************************************\
+ * *
+ * Server-Side Skeletons to Invoke Service Operations *
+ * *
+\******************************************************************************/
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_CA_serve(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_CA_serve_request(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_CA__RetrieveRootCACertificate(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_CA__RetrieveLocalClock(struct soap*);
+
+/******************************************************************************\
+ * *
+ * Client-Side Call Stubs *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_CA__RetrieveRootCACertificate(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *EntityID, struct KMS_CA__RetrieveRootCACertificateResponse &result);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_CA__RetrieveLocalClock(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *EntityID, struct KMS_CA__RetrieveLocalClockResponse &result);
+
+} // namespace KMS_CA
+
+
+#endif
+
+/* End of KMS_CAStub.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_Certificate.nsmap b/usr/src/lib/libkmsagent/common/SOAP/KMS_Certificate.nsmap
new file mode 100644
index 0000000000..0cca992fff
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_Certificate.nsmap
@@ -0,0 +1,36 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include "KMS_CertificateH.h"
+SOAP_NMAC struct Namespace KMS_Certificate_namespaces[] =
+{
+ {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope"},
+ {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding"},
+ {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},
+ {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},
+ {"KMS-Certificate", "http://www.sun.com/KMS/KMS-Certificate"},
+ {NULL, NULL}
+};
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateC.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateC.cpp
new file mode 100644
index 0000000000..44d466ca4f
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateC.cpp
@@ -0,0 +1,2425 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CertificateC.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CertificateService/KMS_Certificate_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+
+#include "KMS_CertificateH.h"
+
+namespace KMS_Certificate {
+
+SOAP_SOURCE_STAMP("@(#) KMS_CertificateC.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap)
+{
+ if (soap->header)
+ soap_serialize_SOAP_ENV__Header(soap, soap->header);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap)
+{
+ if (soap->header)
+ { soap->part = SOAP_IN_HEADER;
+ if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, NULL))
+ return soap->error;
+ soap->part = SOAP_END_HEADER;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap)
+{
+ soap->part = SOAP_IN_HEADER;
+ soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", NULL, NULL);
+ soap->part = SOAP_END_HEADER;
+ return soap->header == NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap)
+{
+ if (!soap->header)
+ { if ((soap->header = soap_new_SOAP_ENV__Header(soap, -1)))
+ soap_default_SOAP_ENV__Header(soap, soap->header);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap)
+{
+ if (!soap->fault)
+ { soap->fault = soap_new_SOAP_ENV__Fault(soap, -1);
+ if (!soap->fault)
+ return;
+ soap_default_SOAP_ENV__Fault(soap, soap->fault);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Code)
+ { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason)
+ { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap, -1);
+ soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->fault)
+ soap_serialize_SOAP_ENV__Fault(soap, soap->fault);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap)
+{
+ if (soap->fault)
+ return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", NULL);
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap)
+{
+ return (soap->fault = soap_get_SOAP_ENV__Fault(soap, NULL, "SOAP-ENV:Fault", NULL)) == NULL;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value;
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ { if (!soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
+ { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value;
+ }
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text;
+ return (const char**)&soap->fault->faultstring;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 1)
+ { if (!soap->fault->detail)
+ { soap->fault->detail = (struct SOAP_ENV__Detail*)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail));
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->detail);
+ }
+ return (const char**)&soap->fault->detail->__any;
+ }
+ if (!soap->fault->SOAP_ENV__Detail)
+ { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1);
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->SOAP_ENV__Detail);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Detail->__any;
+}
+
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap)
+{
+ int t;
+ if (soap->version == 1)
+ { for (;;)
+ { if (!soap_getelement(soap, &t))
+ if (soap->error || soap_ignore_element(soap))
+ break;
+ }
+ }
+ if (soap->error == SOAP_NO_TAG || soap->error == SOAP_EOF)
+ soap->error = SOAP_OK;
+ return soap->error;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type)
+{
+ if (soap_peek_element(soap))
+ return NULL;
+ if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id)))
+ *type = soap_lookup_type(soap, soap->href);
+ switch (*type)
+ {
+ case SOAP_TYPE_KMS_Certificate_byte:
+ return soap_in_byte(soap, NULL, NULL, "xsd:byte");
+ case SOAP_TYPE_KMS_Certificate_int:
+ return soap_in_int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_Certificate_xsd__int:
+ return soap_in_xsd__int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_Certificate_long:
+ return soap_in_long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Certificate_xsd__long:
+ return soap_in_xsd__long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Certificate_LONG64:
+ return soap_in_LONG64(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Certificate_xsd__float:
+ return soap_in_xsd__float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_Certificate_float:
+ return soap_in_float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_Certificate_unsignedByte:
+ return soap_in_unsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Certificate_unsignedInt:
+ return soap_in_unsignedInt(soap, NULL, NULL, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_Certificate_xsd__boolean:
+ return soap_in_xsd__boolean(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_Certificate_bool:
+ return soap_in_bool(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate:
+ return soap_in_KMS_Certificate__RetrieveEntityCertificate(soap, NULL, NULL, "KMS-Certificate:RetrieveEntityCertificate");
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse:
+ return soap_in_KMS_Certificate__RetrieveEntityCertificateResponse(soap, NULL, NULL, "KMS-Certificate:RetrieveEntityCertificateResponse");
+ case SOAP_TYPE_KMS_Certificate_xsd__hexBinary:
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Certificate_PointerTounsignedByte:
+ return soap_in_PointerTounsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Certificate_xsd__duration:
+ { char **s;
+ s = soap_in_xsd__duration(soap, NULL, NULL, "xsd:duration");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Certificate_xsd__dateTime:
+ { char **s;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, "xsd:dateTime");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Certificate_xsd__string:
+ { char **s;
+ s = soap_in_xsd__string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Certificate__QName:
+ { char **s;
+ s = soap_in__QName(soap, NULL, NULL, "xsd:QName");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Certificate_string:
+ { char **s;
+ s = soap_in_string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ default:
+ { const char *t = soap->type;
+ if (!*t)
+ t = soap->tag;
+ if (!soap_match_tag(soap, t, "xsd:byte"))
+ { *type = SOAP_TYPE_KMS_Certificate_byte;
+ return soap_in_byte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_Certificate_int;
+ return soap_in_int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_Certificate_xsd__int;
+ return soap_in_xsd__int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Certificate_long;
+ return soap_in_long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Certificate_xsd__long;
+ return soap_in_xsd__long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Certificate_LONG64;
+ return soap_in_LONG64(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_Certificate_xsd__float;
+ return soap_in_xsd__float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_Certificate_float;
+ return soap_in_float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedByte"))
+ { *type = SOAP_TYPE_KMS_Certificate_unsignedByte;
+ return soap_in_unsignedByte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedInt"))
+ { *type = SOAP_TYPE_KMS_Certificate_unsignedInt;
+ return soap_in_unsignedInt(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_Certificate_xsd__boolean;
+ return soap_in_xsd__boolean(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_Certificate_bool;
+ return soap_in_bool(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Certificate:RetrieveEntityCertificate"))
+ { *type = SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate;
+ return soap_in_KMS_Certificate__RetrieveEntityCertificate(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Certificate:RetrieveEntityCertificateResponse"))
+ { *type = SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse;
+ return soap_in_KMS_Certificate__RetrieveEntityCertificateResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:hexBinary"))
+ { *type = SOAP_TYPE_KMS_Certificate_xsd__hexBinary;
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:duration"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Certificate_xsd__duration;
+ s = soap_in_xsd__duration(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:dateTime"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Certificate_xsd__dateTime;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Certificate_xsd__string;
+ s = soap_in_xsd__string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:QName"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Certificate__QName;
+ s = soap_in__QName(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Certificate_string;
+ s = soap_in_string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ t = soap->tag;
+ }
+ }
+ soap->error = SOAP_TAG_MISMATCH;
+ return NULL;
+}
+#endif
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap)
+{
+ if (!soap_peek_element(soap))
+ { int t;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body));
+ if (soap->mustUnderstand && !soap->other)
+ return soap->error = SOAP_MUSTUNDERSTAND;
+ if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag));
+ return soap->error = SOAP_TAG_MISMATCH;
+ }
+ if (!*soap->id || !soap_getelement(soap, &t))
+ { soap->peeked = 0;
+ if (soap->fignore)
+ soap->error = soap->fignore(soap, soap->tag);
+ else
+ soap->error = SOAP_OK;
+ DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag));
+ if (!soap->error && soap->body)
+ { soap->level++;
+ while (!soap_ignore_element(soap))
+ ;
+ if (soap->error == SOAP_NO_TAG)
+ soap->error = soap_element_end_in(soap, NULL);
+ }
+ }
+ }
+ return soap->error;
+}
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap)
+{
+ int i;
+ struct soap_plist *pp;
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)))
+ for (i = 0; i < SOAP_PTRHASH; i++)
+ for (pp = soap->pht[i]; pp; pp = pp->next)
+ if (pp->mark1 == 2 || pp->mark2 == 2)
+ if (soap_putelement(soap, pp->ptr, "id", pp->id, pp->type))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, const char *tag, int id, int type)
+{
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_Certificate_byte:
+ return soap_out_byte(soap, tag, id, (const char *)ptr, "xsd:byte");
+ case SOAP_TYPE_KMS_Certificate_int:
+ return soap_out_int(soap, tag, id, (const int *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_Certificate_xsd__int:
+ return soap_out_xsd__int(soap, tag, id, (const long *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_Certificate_long:
+ return soap_out_long(soap, tag, id, (const long *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Certificate_xsd__long:
+ return soap_out_xsd__long(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Certificate_LONG64:
+ return soap_out_LONG64(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Certificate_xsd__float:
+ return soap_out_xsd__float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_Certificate_float:
+ return soap_out_float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_Certificate_unsignedByte:
+ return soap_out_unsignedByte(soap, tag, id, (const unsigned char *)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Certificate_unsignedInt:
+ return soap_out_unsignedInt(soap, tag, id, (const unsigned int *)ptr, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_Certificate_xsd__boolean:
+ return soap_out_xsd__boolean(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_Certificate_bool:
+ return soap_out_bool(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate:
+ return soap_out_KMS_Certificate__RetrieveEntityCertificate(soap, tag, id, (const struct KMS_Certificate__RetrieveEntityCertificate *)ptr, "KMS-Certificate:RetrieveEntityCertificate");
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse:
+ return soap_out_KMS_Certificate__RetrieveEntityCertificateResponse(soap, tag, id, (const struct KMS_Certificate__RetrieveEntityCertificateResponse *)ptr, "KMS-Certificate:RetrieveEntityCertificateResponse");
+ case SOAP_TYPE_KMS_Certificate_xsd__hexBinary:
+ return soap_out_xsd__hexBinary(soap, tag, id, (const struct xsd__hexBinary *)ptr, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Certificate_PointerTounsignedByte:
+ return soap_out_PointerTounsignedByte(soap, tag, id, (unsigned char *const*)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Certificate_xsd__duration:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:duration");
+ case SOAP_TYPE_KMS_Certificate_xsd__dateTime:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:dateTime");
+ case SOAP_TYPE_KMS_Certificate_xsd__string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ case SOAP_TYPE_KMS_Certificate__QName:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:QName");
+ case SOAP_TYPE_KMS_Certificate_string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ }
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, int type)
+{
+ (void)soap; (void)ptr; (void)type; /* appease -Wall -Werror */
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate:
+ soap_serialize_KMS_Certificate__RetrieveEntityCertificate(soap, (const struct KMS_Certificate__RetrieveEntityCertificate *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse:
+ soap_serialize_KMS_Certificate__RetrieveEntityCertificateResponse(soap, (const struct KMS_Certificate__RetrieveEntityCertificateResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_xsd__hexBinary:
+ soap_serialize_xsd__hexBinary(soap, (const struct xsd__hexBinary *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_PointerTounsignedByte:
+ soap_serialize_PointerTounsignedByte(soap, (unsigned char *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_xsd__duration:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_xsd__dateTime:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_xsd__string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate__QName:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ }
+}
+#endif
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n)
+{
+ switch (t)
+ {
+ case SOAP_TYPE_KMS_Certificate_xsd__hexBinary:
+ return (void*)soap_instantiate_xsd__hexBinary(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse:
+ return (void*)soap_instantiate_KMS_Certificate__RetrieveEntityCertificateResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate:
+ return (void*)soap_instantiate_KMS_Certificate__RetrieveEntityCertificate(soap, -1, type, arrayType, n);
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header:
+ return (void*)soap_instantiate_SOAP_ENV__Header(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code:
+ return (void*)soap_instantiate_SOAP_ENV__Code(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail:
+ return (void*)soap_instantiate_SOAP_ENV__Detail(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason:
+ return (void*)soap_instantiate_SOAP_ENV__Reason(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault:
+ return (void*)soap_instantiate_SOAP_ENV__Fault(soap, -1, type, arrayType, n);
+#endif
+ }
+ return NULL;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p)
+{ switch (p->type)
+ {
+ case SOAP_TYPE_KMS_Certificate_xsd__hexBinary:
+ if (p->size < 0)
+ SOAP_DELETE((struct xsd__hexBinary*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct xsd__hexBinary*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Certificate__RetrieveEntityCertificateResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Certificate__RetrieveEntityCertificateResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Certificate__RetrieveEntityCertificate*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Certificate__RetrieveEntityCertificate*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr);
+ break;
+ default: return SOAP_ERR;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType)
+{ return soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_byte
+ *a = SOAP_DEFAULT_byte;
+#else
+ *a = (char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type)
+{
+ return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_byte);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap *soap, const char *tag, char *a, const char *type)
+{ char *p;
+ p = soap_inbyte(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_byte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap *soap, const char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_byte);
+ if (soap_out_byte(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap *soap, char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_byte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_int
+ *a = SOAP_DEFAULT_int;
+#else
+ *a = (int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type)
+{
+ return soap_outint(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_int);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap *soap, const char *tag, int *a, const char *type)
+{ int *p;
+ p = soap_inint(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap *soap, const int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_int);
+ if (soap_out_int(soap, tag?tag:"int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap *soap, int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_xsd__int);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_xsd__int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__int);
+ if (soap_out_xsd__int(soap, tag?tag:"xsd:int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap *soap, long *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_long
+ *a = SOAP_DEFAULT_long;
+#else
+ *a = (long)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_long);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_long);
+ if (soap_out_long(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_xsd__long);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_xsd__long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__long);
+ if (soap_out_xsd__long(soap, tag?tag:"xsd:long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap *soap, LONG64 *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_LONG64
+ *a = SOAP_DEFAULT_LONG64;
+#else
+ *a = (LONG64)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_LONG64);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_LONG64);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_LONG64);
+ if (soap_out_LONG64(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_LONG64(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_xsd__float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_xsd__float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__float);
+ if (soap_out_xsd__float(soap, tag?tag:"xsd:float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap *soap, float *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_float
+ *a = SOAP_DEFAULT_float;
+#else
+ *a = (float)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_float);
+ if (soap_out_float(soap, tag?tag:"float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap *soap, unsigned char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedByte
+ *a = SOAP_DEFAULT_unsignedByte;
+#else
+ *a = (unsigned char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *a, const char *type)
+{
+ return soap_outunsignedByte(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_unsignedByte);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap *soap, const char *tag, unsigned char *a, const char *type)
+{ unsigned char *p;
+ p = soap_inunsignedByte(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_unsignedByte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap *soap, const unsigned char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_unsignedByte);
+ if (soap_out_unsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap *soap, unsigned char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap *soap, unsigned int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedInt
+ *a = SOAP_DEFAULT_unsignedInt;
+#else
+ *a = (unsigned int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *a, const char *type)
+{
+ return soap_outunsignedInt(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_unsignedInt);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap *soap, const char *tag, unsigned int *a, const char *type)
+{ unsigned int *p;
+ p = soap_inunsignedInt(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_unsignedInt);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap *soap, const unsigned int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_unsignedInt);
+ if (soap_out_unsignedInt(soap, tag?tag:"unsignedInt", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap *soap, unsigned int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedInt(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap *soap, bool n)
+{ return soap_bool2s(soap, n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_xsd__boolean), type) || soap_send(soap, soap_xsd__boolean2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap *soap, const char *s, bool *a)
+{
+ return soap_s2bool(soap, s, a);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_xsd__boolean, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2xsd__boolean(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_xsd__boolean, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__boolean);
+ if (soap_out_xsd__boolean(soap, tag?tag:"xsd:boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__boolean(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap *soap, bool *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_bool
+ *a = SOAP_DEFAULT_bool;
+#else
+ *a = (bool)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_bool[] =
+{ { (long)false, "false" },
+ { (long)true, "true" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap *soap, bool n)
+{
+ (void)soap; /* appease -Wall -Werror */
+return soap_code_str(soap_codes_bool, n!=0);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_bool), type) || soap_send(soap, soap_bool2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap *soap, const char *s, bool *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_bool, s);
+ if (map)
+ *a = (bool)(map->code != 0);
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || n < 0 || n > 1)
+ return soap->error = SOAP_TYPE;
+ *a = (bool)(n != 0);
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_bool, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2bool(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_bool, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_bool);
+ if (soap_out_bool(soap, tag?tag:"boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_bool(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->faultcode);
+ soap_default_string(soap, &a->faultstring);
+ soap_default_string(soap, &a->faultactor);
+ a->detail = NULL;
+ a->SOAP_ENV__Code = NULL;
+ a->SOAP_ENV__Reason = NULL;
+ soap_default_string(soap, &a->SOAP_ENV__Node);
+ soap_default_string(soap, &a->SOAP_ENV__Role);
+ a->SOAP_ENV__Detail = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->faultcode);
+ soap_serialize_string(soap, &a->faultstring);
+ soap_serialize_string(soap, &a->faultactor);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->detail);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Code);
+ soap_serialize_PointerToSOAP_ENV__Reason(soap, &a->SOAP_ENV__Reason);
+ soap_serialize_string(soap, &a->SOAP_ENV__Node);
+ soap_serialize_string(soap, &a->SOAP_ENV__Role);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->SOAP_ENV__Detail);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type)
+{
+ const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault), type))
+ return soap->error;
+ if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, ""))
+ return soap->error;
+ if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "xsd:string"))
+ return soap->error;
+ if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "xsd:string"))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", -1, &a->SOAP_ENV__Code, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", -1, &a->SOAP_ENV__Reason, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Node", -1, &a->SOAP_ENV__Node, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Role", -1, &a->SOAP_ENV__Role, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", -1, &a->SOAP_ENV__Detail, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap *soap, const char *tag, struct SOAP_ENV__Fault *a, const char *type)
+{
+ size_t soap_flag_faultcode = 1;
+ size_t soap_flag_faultstring = 1;
+ size_t soap_flag_faultactor = 1;
+ size_t soap_flag_detail = 1;
+ size_t soap_flag_SOAP_ENV__Code = 1;
+ size_t soap_flag_SOAP_ENV__Reason = 1;
+ size_t soap_flag_SOAP_ENV__Node = 1;
+ size_t soap_flag_SOAP_ENV__Role = 1;
+ size_t soap_flag_SOAP_ENV__Detail = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Fault(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_faultcode && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "faultcode", &a->faultcode, ""))
+ { soap_flag_faultcode--;
+ continue;
+ }
+ if (soap_flag_faultstring && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultstring", &a->faultstring, "xsd:string"))
+ { soap_flag_faultstring--;
+ continue;
+ }
+ if (soap_flag_faultactor && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultactor", &a->faultactor, "xsd:string"))
+ { soap_flag_faultactor--;
+ continue;
+ }
+ if (soap_flag_detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "detail", &a->detail, ""))
+ { soap_flag_detail--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Code && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", &a->SOAP_ENV__Code, ""))
+ { soap_flag_SOAP_ENV__Code--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Reason && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", &a->SOAP_ENV__Reason, ""))
+ { soap_flag_SOAP_ENV__Reason--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Node && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Node", &a->SOAP_ENV__Node, "xsd:string"))
+ { soap_flag_SOAP_ENV__Node--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Role && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Role", &a->SOAP_ENV__Role, "xsd:string"))
+ { soap_flag_SOAP_ENV__Role--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", &a->SOAP_ENV__Detail, ""))
+ { soap_flag_SOAP_ENV__Detail--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault, 0, sizeof(struct SOAP_ENV__Fault), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault);
+ if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Fault(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Fault);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Fault);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Fault*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason), type))
+ return soap->error;
+ if (soap->lang)
+ soap_set_attr(soap, "xml:lang", soap->lang, 1);
+ if (soap_out_string(soap, "SOAP-ENV:Text", -1, &a->SOAP_ENV__Text, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Text = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Reason(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Text && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Text", &a->SOAP_ENV__Text, "xsd:string"))
+ { soap_flag_SOAP_ENV__Text--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason, 0, sizeof(struct SOAP_ENV__Reason), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason);
+ if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Reason);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Reason);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Reason*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ a->__type = 0;
+ a->fault = NULL;
+ a->__any = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_markelement(soap, a->fault, a->__type);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail), type))
+ return soap->error;
+ if (soap_putelement(soap, a->fault, "fault", -1, a->__type))
+ return soap->error;
+ soap_outliteral(soap, "-any", &a->__any, NULL);
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail *a, const char *type)
+{
+ size_t soap_flag_fault = 1;
+ size_t soap_flag___any = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Detail(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_fault && soap->error == SOAP_TAG_MISMATCH)
+ if ((a->fault = soap_getelement(soap, &a->__type)))
+ { soap_flag_fault = 0;
+ continue;
+ }
+ if (soap_flag___any && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_inliteral(soap, "-any", &a->__any))
+ { soap_flag___any--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail, 0, sizeof(struct SOAP_ENV__Detail), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail);
+ if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Detail);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Detail);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Detail*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->SOAP_ENV__Value);
+ a->SOAP_ENV__Subcode = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->SOAP_ENV__Value);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Subcode);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type)
+{
+ const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code), type))
+ return soap->error;
+ if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Value = 1;
+ size_t soap_flag_SOAP_ENV__Subcode = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Code(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Value && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "SOAP-ENV:Value", &a->SOAP_ENV__Value, ""))
+ { soap_flag_SOAP_ENV__Value--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Subcode && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", &a->SOAP_ENV__Subcode, ""))
+ { soap_flag_SOAP_ENV__Subcode--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code, 0, sizeof(struct SOAP_ENV__Code), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code);
+ if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Code);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Code);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Code*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header), type))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap *soap, const char *tag, struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Header(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header, 0, sizeof(struct SOAP_ENV__Header), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header);
+ if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Header(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Header);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Header);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Header*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, struct KMS_Certificate__RetrieveEntityCertificate *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->EntityID);
+ soap_default_xsd__hexBinary(soap, &a->ClientAuthenticationResponse);
+ soap_default_xsd__hexBinary(soap, &a->ServerAuthenticationChallenge);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, const struct KMS_Certificate__RetrieveEntityCertificate *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->EntityID);
+ soap_serialize_xsd__hexBinary(soap, &a->ClientAuthenticationResponse);
+ soap_serialize_xsd__hexBinary(soap, &a->ServerAuthenticationChallenge);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, const char *tag, int id, const struct KMS_Certificate__RetrieveEntityCertificate *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "EntityID", -1, &a->EntityID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "ClientAuthenticationResponse", -1, &a->ClientAuthenticationResponse, "xsd:hexBinary"))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "ServerAuthenticationChallenge", -1, &a->ServerAuthenticationChallenge, "xsd:hexBinary"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificate * SOAP_FMAC4 soap_in_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, const char *tag, struct KMS_Certificate__RetrieveEntityCertificate *a, const char *type)
+{
+ size_t soap_flag_EntityID = 1;
+ size_t soap_flag_ClientAuthenticationResponse = 1;
+ size_t soap_flag_ServerAuthenticationChallenge = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Certificate__RetrieveEntityCertificate *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate, sizeof(struct KMS_Certificate__RetrieveEntityCertificate), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Certificate__RetrieveEntityCertificate(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_EntityID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "EntityID", &a->EntityID, "xsd:string"))
+ { soap_flag_EntityID--;
+ continue;
+ }
+ if (soap_flag_ClientAuthenticationResponse && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "ClientAuthenticationResponse", &a->ClientAuthenticationResponse, "xsd:hexBinary"))
+ { soap_flag_ClientAuthenticationResponse--;
+ continue;
+ }
+ if (soap_flag_ServerAuthenticationChallenge && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "ServerAuthenticationChallenge", &a->ServerAuthenticationChallenge, "xsd:hexBinary"))
+ { soap_flag_ServerAuthenticationChallenge--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Certificate__RetrieveEntityCertificate *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate, 0, sizeof(struct KMS_Certificate__RetrieveEntityCertificate), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_ClientAuthenticationResponse > 0 || soap_flag_ServerAuthenticationChallenge > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, const struct KMS_Certificate__RetrieveEntityCertificate *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate);
+ if (soap_out_KMS_Certificate__RetrieveEntityCertificate(soap, tag?tag:"KMS-Certificate:RetrieveEntityCertificate", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificate * SOAP_FMAC4 soap_get_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, struct KMS_Certificate__RetrieveEntityCertificate *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Certificate__RetrieveEntityCertificate(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Certificate__RetrieveEntityCertificate * SOAP_FMAC2 soap_instantiate_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Certificate__RetrieveEntityCertificate(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Certificate__RetrieveEntityCertificate);
+ if (size)
+ *size = sizeof(struct KMS_Certificate__RetrieveEntityCertificate);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Certificate__RetrieveEntityCertificate[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Certificate__RetrieveEntityCertificate);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Certificate__RetrieveEntityCertificate*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Certificate__RetrieveEntityCertificate %p -> %p\n", q, p));
+ *(struct KMS_Certificate__RetrieveEntityCertificate*)p = *(struct KMS_Certificate__RetrieveEntityCertificate*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, struct KMS_Certificate__RetrieveEntityCertificateResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__hexBinary(soap, &a->ServerAuthenticationResponse);
+ soap_default_xsd__hexBinary(soap, &a->Certificate);
+ soap_default_xsd__hexBinary(soap, &a->WrappedPrivateKeyMaterial);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, const struct KMS_Certificate__RetrieveEntityCertificateResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__hexBinary(soap, &a->ServerAuthenticationResponse);
+ soap_serialize_xsd__hexBinary(soap, &a->Certificate);
+ soap_serialize_xsd__hexBinary(soap, &a->WrappedPrivateKeyMaterial);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, const char *tag, int id, const struct KMS_Certificate__RetrieveEntityCertificateResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse), type))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "ServerAuthenticationResponse", -1, &a->ServerAuthenticationResponse, "xsd:hexBinary"))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "Certificate", -1, &a->Certificate, "xsd:hexBinary"))
+ return soap->error;
+ if (soap_out_xsd__hexBinary(soap, "WrappedPrivateKeyMaterial", -1, &a->WrappedPrivateKeyMaterial, "xsd:hexBinary"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificateResponse * SOAP_FMAC4 soap_in_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, const char *tag, struct KMS_Certificate__RetrieveEntityCertificateResponse *a, const char *type)
+{
+ size_t soap_flag_ServerAuthenticationResponse = 1;
+ size_t soap_flag_Certificate = 1;
+ size_t soap_flag_WrappedPrivateKeyMaterial = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Certificate__RetrieveEntityCertificateResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse, sizeof(struct KMS_Certificate__RetrieveEntityCertificateResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Certificate__RetrieveEntityCertificateResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_ServerAuthenticationResponse && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "ServerAuthenticationResponse", &a->ServerAuthenticationResponse, "xsd:hexBinary"))
+ { soap_flag_ServerAuthenticationResponse--;
+ continue;
+ }
+ if (soap_flag_Certificate && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "Certificate", &a->Certificate, "xsd:hexBinary"))
+ { soap_flag_Certificate--;
+ continue;
+ }
+ if (soap_flag_WrappedPrivateKeyMaterial && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__hexBinary(soap, "WrappedPrivateKeyMaterial", &a->WrappedPrivateKeyMaterial, "xsd:hexBinary"))
+ { soap_flag_WrappedPrivateKeyMaterial--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Certificate__RetrieveEntityCertificateResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse, 0, sizeof(struct KMS_Certificate__RetrieveEntityCertificateResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_ServerAuthenticationResponse > 0 || soap_flag_Certificate > 0 || soap_flag_WrappedPrivateKeyMaterial > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, const struct KMS_Certificate__RetrieveEntityCertificateResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse);
+ if (soap_out_KMS_Certificate__RetrieveEntityCertificateResponse(soap, tag?tag:"KMS-Certificate:RetrieveEntityCertificateResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificateResponse * SOAP_FMAC4 soap_get_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, struct KMS_Certificate__RetrieveEntityCertificateResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Certificate__RetrieveEntityCertificateResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Certificate__RetrieveEntityCertificateResponse * SOAP_FMAC2 soap_instantiate_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Certificate__RetrieveEntityCertificateResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Certificate__RetrieveEntityCertificateResponse);
+ if (size)
+ *size = sizeof(struct KMS_Certificate__RetrieveEntityCertificateResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Certificate__RetrieveEntityCertificateResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Certificate__RetrieveEntityCertificateResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Certificate__RetrieveEntityCertificateResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Certificate__RetrieveEntityCertificateResponse %p -> %p\n", q, p));
+ *(struct KMS_Certificate__RetrieveEntityCertificateResponse*)p = *(struct KMS_Certificate__RetrieveEntityCertificateResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary const*a)
+{
+ if (a->__ptr)
+ soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Certificate_xsd__hexBinary);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap *soap, const char *tag, int id, const struct xsd__hexBinary *a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Certificate_xsd__hexBinary);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ if (soap_puthex(soap, a->__ptr, a->__size))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap *soap, const char *tag, struct xsd__hexBinary *a, const char *type)
+{
+ (void)type; /* appease -Wall -Werror */
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":hexBinary"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct xsd__hexBinary *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Certificate_xsd__hexBinary, sizeof(struct xsd__hexBinary), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_xsd__hexBinary(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__ptr = soap_gethex(soap, &a->__size);
+ if ((!a->__ptr && soap->error) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct xsd__hexBinary *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Certificate_xsd__hexBinary, 0, sizeof(struct xsd__hexBinary), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap *soap, const struct xsd__hexBinary *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Certificate_xsd__hexBinary);
+ if (soap_out_xsd__hexBinary(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__hexBinary(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_xsd__hexBinary(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Certificate_xsd__hexBinary, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary);
+ if (size)
+ *size = sizeof(struct xsd__hexBinary);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct xsd__hexBinary);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct xsd__hexBinary*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct xsd__hexBinary %p -> %p\n", q, p));
+ *(struct xsd__hexBinary*)p = *(struct xsd__hexBinary*)q;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason))
+ soap_serialize_SOAP_ENV__Reason(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Reason *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Reason(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Reason **)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Reason(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Reason);
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail))
+ soap_serialize_SOAP_ENV__Detail(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Detail *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Detail(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Detail **)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Detail(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Detail);
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code))
+ soap_serialize_SOAP_ENV__Code(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Code *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Code(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Code **)soap_malloc(soap, sizeof(struct SOAP_ENV__Code *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Code(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Code);
+ if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap *soap, unsigned char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_Certificate_unsignedByte);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap *soap, const char *tag, int id, unsigned char *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Certificate_unsignedByte);
+ if (id < 0)
+ return soap->error;
+ return soap_out_unsignedByte(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap *soap, const char *tag, unsigned char **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (unsigned char **)soap_malloc(soap, sizeof(unsigned char *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_unsignedByte(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (unsigned char **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Certificate_unsignedByte, sizeof(unsigned char), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap *soap, unsigned char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_PointerTounsignedByte);
+ if (soap_out_PointerTounsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap *soap, unsigned char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerTounsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_xsd__duration);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_xsd__duration, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__duration);
+ if (soap_out_xsd__duration(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__duration(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_xsd__dateTime);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_xsd__dateTime, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__dateTime);
+ if (soap_out_xsd__dateTime(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__dateTime(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_xsd__string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_xsd__string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_xsd__string);
+ if (soap_out_xsd__string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate__QName);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Certificate__QName, 2, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate__QName);
+ if (soap_out__QName(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in__QName(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap *soap, char **a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_string
+ *a = SOAP_DEFAULT_string;
+#else
+ *a = (char *)0;
+#endif
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_Certificate_string);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Certificate_string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Certificate_string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Certificate_string);
+ if (soap_out_string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+} // namespace KMS_Certificate
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_CertificateC.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateClient.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateClient.cpp
new file mode 100644
index 0000000000..89607f2999
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateClient.cpp
@@ -0,0 +1,102 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CertificateClient.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CertificateService/KMS_Certificate_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+#include "KMS_CertificateH.h"
+
+namespace KMS_Certificate {
+
+SOAP_SOURCE_STAMP("@(#) KMS_CertificateClient.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *EntityID, struct xsd__hexBinary ClientAuthenticationResponse, struct xsd__hexBinary ServerAuthenticationChallenge, struct KMS_Certificate__RetrieveEntityCertificateResponse &result)
+{ struct KMS_Certificate__RetrieveEntityCertificate soap_tmp_KMS_Certificate__RetrieveEntityCertificate;
+ soap_tmp_KMS_Certificate__RetrieveEntityCertificate.EntityID = EntityID;
+ soap_tmp_KMS_Certificate__RetrieveEntityCertificate.ClientAuthenticationResponse = ClientAuthenticationResponse;
+ soap_tmp_KMS_Certificate__RetrieveEntityCertificate.ServerAuthenticationChallenge = ServerAuthenticationChallenge;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Certificate__RetrieveEntityCertificate(soap, &soap_tmp_KMS_Certificate__RetrieveEntityCertificate);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Certificate__RetrieveEntityCertificate(soap, &soap_tmp_KMS_Certificate__RetrieveEntityCertificate, "KMS-Certificate:RetrieveEntityCertificate", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Certificate__RetrieveEntityCertificate(soap, &soap_tmp_KMS_Certificate__RetrieveEntityCertificate, "KMS-Certificate:RetrieveEntityCertificate", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Certificate__RetrieveEntityCertificateResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Certificate__RetrieveEntityCertificateResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+} // namespace KMS_Certificate
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_CertificateClient.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateH.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateH.h
new file mode 100644
index 0000000000..7b41bd1a6a
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateH.h
@@ -0,0 +1,652 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CertificateH.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CertificateService/KMS_Certificate_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_CertificateH_H
+#define KMS_CertificateH_H
+#include "KMS_CertificateStub.h"
+
+namespace KMS_Certificate {
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
+SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_byte
+#define SOAP_TYPE_KMS_Certificate_byte (3)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*);
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*);
+
+#define soap_write_byte(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_byte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*);
+
+#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_int
+#define SOAP_TYPE_KMS_Certificate_int (1)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*);
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*);
+
+#define soap_write_int(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*);
+
+#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__int
+#define SOAP_TYPE_KMS_Certificate_xsd__int (11)
+#endif
+
+#define soap_default_xsd__int(soap, a) soap_default_long(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap*, const char*, long *, const char*);
+
+#define soap_write_xsd__int(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_xsd__int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_xsd__int(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_long
+#define SOAP_TYPE_KMS_Certificate_long (10)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap*, long *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap*, const char*, long *, const char*);
+
+#define soap_write_long(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_long(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__long
+#define SOAP_TYPE_KMS_Certificate_xsd__long (15)
+#endif
+
+#define soap_default_xsd__long(soap, a) soap_default_LONG64(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_xsd__long(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_xsd__long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_xsd__long(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_LONG64
+#define SOAP_TYPE_KMS_Certificate_LONG64 (14)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap*, LONG64 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_LONG64(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_LONG64(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_LONG64(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_LONG64(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__float
+#define SOAP_TYPE_KMS_Certificate_xsd__float (9)
+#endif
+
+#define soap_default_xsd__float(soap, a) soap_default_float(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_xsd__float(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_xsd__float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_xsd__float(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_float
+#define SOAP_TYPE_KMS_Certificate_float (8)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap*, float *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_float(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_float(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_unsignedByte
+#define SOAP_TYPE_KMS_Certificate_unsignedByte (20)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap*, unsigned char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap*, const char*, int, const unsigned char *, const char*);
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap*, const char*, unsigned char *, const char*);
+
+#define soap_write_unsignedByte(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_unsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap*, const unsigned char *, const char*, const char*);
+
+#define soap_read_unsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_unsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap*, unsigned char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_unsignedInt
+#define SOAP_TYPE_KMS_Certificate_unsignedInt (19)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap*, unsigned int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap*, const char*, int, const unsigned int *, const char*);
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap*, const char*, unsigned int *, const char*);
+
+#define soap_write_unsignedInt(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_unsignedInt(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap*, const unsigned int *, const char*, const char*);
+
+#define soap_read_unsignedInt(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_unsignedInt(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap*, unsigned int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__boolean
+#define SOAP_TYPE_KMS_Certificate_xsd__boolean (13)
+#endif
+
+#define soap_default_xsd__boolean(soap, a) soap_default_bool(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap*, const char*, bool *);
+
+#define soap_write_xsd__boolean(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_xsd__boolean(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_xsd__boolean(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__boolean(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap*, bool *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_bool
+#define SOAP_TYPE_KMS_Certificate_bool (12)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap*, bool *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap*, const char*, bool *);
+
+#define soap_write_bool(soap, data) ( soap_begin_send(soap) || KMS_Certificate::soap_put_bool(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_bool(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_bool(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap*, bool *, const char*, const char*);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault (33)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*);
+
+#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_SOAP_ENV__Fault(soap, data), 0) || KMS_Certificate::soap_put_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Fault(soap, n) soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Fault(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason (32)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*);
+
+#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_SOAP_ENV__Reason(soap, data), 0) || KMS_Certificate::soap_put_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Reason(soap, n) soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Reason(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail (29)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*);
+
+#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_SOAP_ENV__Detail(soap, data), 0) || KMS_Certificate::soap_put_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Detail(soap, n) soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Detail(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code (27)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*);
+
+#define soap_write_SOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_SOAP_ENV__Code(soap, data), 0) || KMS_Certificate::soap_put_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Code(soap, n) soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Code(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header (26)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*);
+
+#define soap_write_SOAP_ENV__Header(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_SOAP_ENV__Header(soap, data), 0) || KMS_Certificate::soap_put_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Header(soap, n) soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Header(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate
+#define SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate (25)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Certificate__RetrieveEntityCertificate(struct soap*, struct KMS_Certificate__RetrieveEntityCertificate *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Certificate__RetrieveEntityCertificate(struct soap*, const struct KMS_Certificate__RetrieveEntityCertificate *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Certificate__RetrieveEntityCertificate(struct soap*, const char*, int, const struct KMS_Certificate__RetrieveEntityCertificate *, const char*);
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificate * SOAP_FMAC4 soap_in_KMS_Certificate__RetrieveEntityCertificate(struct soap*, const char*, struct KMS_Certificate__RetrieveEntityCertificate *, const char*);
+
+#define soap_write_KMS_Certificate__RetrieveEntityCertificate(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_KMS_Certificate__RetrieveEntityCertificate(soap, data), 0) || KMS_Certificate::soap_put_KMS_Certificate__RetrieveEntityCertificate(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Certificate__RetrieveEntityCertificate(struct soap*, const struct KMS_Certificate__RetrieveEntityCertificate *, const char*, const char*);
+
+#define soap_read_KMS_Certificate__RetrieveEntityCertificate(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_KMS_Certificate__RetrieveEntityCertificate(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificate * SOAP_FMAC4 soap_get_KMS_Certificate__RetrieveEntityCertificate(struct soap*, struct KMS_Certificate__RetrieveEntityCertificate *, const char*, const char*);
+
+#define soap_new_KMS_Certificate__RetrieveEntityCertificate(soap, n) soap_instantiate_KMS_Certificate__RetrieveEntityCertificate(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Certificate__RetrieveEntityCertificate(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Certificate__RetrieveEntityCertificate * SOAP_FMAC2 soap_instantiate_KMS_Certificate__RetrieveEntityCertificate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Certificate__RetrieveEntityCertificate(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse
+#define SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse (22)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, struct KMS_Certificate__RetrieveEntityCertificateResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, const struct KMS_Certificate__RetrieveEntityCertificateResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, const char*, int, const struct KMS_Certificate__RetrieveEntityCertificateResponse *, const char*);
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificateResponse * SOAP_FMAC4 soap_in_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, const char*, struct KMS_Certificate__RetrieveEntityCertificateResponse *, const char*);
+
+#define soap_write_KMS_Certificate__RetrieveEntityCertificateResponse(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_KMS_Certificate__RetrieveEntityCertificateResponse(soap, data), 0) || KMS_Certificate::soap_put_KMS_Certificate__RetrieveEntityCertificateResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, const struct KMS_Certificate__RetrieveEntityCertificateResponse *, const char*, const char*);
+
+#define soap_read_KMS_Certificate__RetrieveEntityCertificateResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_KMS_Certificate__RetrieveEntityCertificateResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Certificate__RetrieveEntityCertificateResponse * SOAP_FMAC4 soap_get_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, struct KMS_Certificate__RetrieveEntityCertificateResponse *, const char*, const char*);
+
+#define soap_new_KMS_Certificate__RetrieveEntityCertificateResponse(soap, n) soap_instantiate_KMS_Certificate__RetrieveEntityCertificateResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Certificate__RetrieveEntityCertificateResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Certificate__RetrieveEntityCertificateResponse * SOAP_FMAC2 soap_instantiate_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Certificate__RetrieveEntityCertificateResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__hexBinary
+#define SOAP_TYPE_KMS_Certificate_xsd__hexBinary (18)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap*, struct xsd__hexBinary *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap*, struct xsd__hexBinary const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap*, const char*, int, const struct xsd__hexBinary *, const char*);
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap*, const char*, struct xsd__hexBinary *, const char*);
+
+#define soap_write_xsd__hexBinary(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_xsd__hexBinary(soap, data), 0) || KMS_Certificate::soap_put_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap*, const struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_read_xsd__hexBinary(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap*, struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_new_xsd__hexBinary(soap, n) soap_instantiate_xsd__hexBinary(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_xsd__hexBinary(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Reason (35)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_PointerToSOAP_ENV__Reason(soap, data), 0) || KMS_Certificate::soap_put_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Detail (34)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_PointerToSOAP_ENV__Detail(soap, data), 0) || KMS_Certificate::soap_put_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Code
+#define SOAP_TYPE_KMS_Certificate_PointerToSOAP_ENV__Code (28)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_PointerToSOAP_ENV__Code(soap, data), 0) || KMS_Certificate::soap_put_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_PointerTounsignedByte
+#define SOAP_TYPE_KMS_Certificate_PointerTounsignedByte (21)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap*, unsigned char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap*, const char *, int, unsigned char *const*, const char *);
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap*, const char*, unsigned char **, const char*);
+
+#define soap_write_PointerTounsignedByte(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_PointerTounsignedByte(soap, data), 0) || KMS_Certificate::soap_put_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap*, unsigned char *const*, const char*, const char*);
+
+#define soap_read_PointerTounsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap*, unsigned char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__duration
+#define SOAP_TYPE_KMS_Certificate_xsd__duration (17)
+#endif
+
+#define soap_default_xsd__duration(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__duration(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__duration(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_xsd__duration(soap, data), 0) || KMS_Certificate::soap_put_xsd__duration(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__duration(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__duration(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__dateTime
+#define SOAP_TYPE_KMS_Certificate_xsd__dateTime (16)
+#endif
+
+#define soap_default_xsd__dateTime(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__dateTime(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__dateTime(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_xsd__dateTime(soap, data), 0) || KMS_Certificate::soap_put_xsd__dateTime(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__dateTime(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__dateTime(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__string
+#define SOAP_TYPE_KMS_Certificate_xsd__string (7)
+#endif
+
+#define soap_default_xsd__string(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__string(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__string(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_xsd__string(soap, data), 0) || KMS_Certificate::soap_put_xsd__string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__string(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_xsd__string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate__QName
+#define SOAP_TYPE_KMS_Certificate__QName (5)
+#endif
+
+#define soap_default__QName(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize__QName(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*);
+
+#define soap_write__QName(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize__QName(soap, data), 0) || KMS_Certificate::soap_put__QName(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Certificate_string
+#define SOAP_TYPE_KMS_Certificate_string (4)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_string(soap, data) ( soap_begin_send(soap) || (KMS_Certificate::soap_serialize_string(soap, data), 0) || KMS_Certificate::soap_put_string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !KMS_Certificate::soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*);
+
+} // namespace KMS_Certificate
+
+
+#endif
+
+/* End of KMS_CertificateH.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateStub.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateStub.h
new file mode 100644
index 0000000000..a57c516f99
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_CertificateStub.h
@@ -0,0 +1,262 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_CertificateStub.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/CertificateService/KMS_Certificate_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_CertificateStub_H
+#define KMS_CertificateStub_H
+#ifndef WITH_NONAMESPACES
+#define WITH_NONAMESPACES
+#endif
+#ifndef WITH_NOGLOBAL
+#define WITH_NOGLOBAL
+#endif
+#include "stdsoap2.h"
+
+namespace KMS_Certificate {
+
+/******************************************************************************\
+ * *
+ * Enumerations *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Types with Custom Serializers *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Classes and Structs *
+ * *
+\******************************************************************************/
+
+
+#if 0 /* volatile type: do not declare here, declared elsewhere */
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__hexBinary
+#define SOAP_TYPE_KMS_Certificate_xsd__hexBinary (18)
+/* hexBinary schema type: */
+struct xsd__hexBinary
+{
+public:
+ unsigned char *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse
+#define SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificateResponse (22)
+/* KMS-Certificate:RetrieveEntityCertificateResponse */
+struct KMS_Certificate__RetrieveEntityCertificateResponse
+{
+public:
+ struct xsd__hexBinary ServerAuthenticationResponse; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* required element of type xsd:hexBinary */
+ struct xsd__hexBinary Certificate; /* required element of type xsd:hexBinary */
+ struct xsd__hexBinary WrappedPrivateKeyMaterial; /* required element of type xsd:hexBinary */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate
+#define SOAP_TYPE_KMS_Certificate_KMS_Certificate__RetrieveEntityCertificate (25)
+/* KMS-Certificate:RetrieveEntityCertificate */
+struct KMS_Certificate__RetrieveEntityCertificate
+{
+public:
+ char *EntityID; /* optional element of type xsd:string */
+ struct xsd__hexBinary ClientAuthenticationResponse; /* required element of type xsd:hexBinary */
+ struct xsd__hexBinary ServerAuthenticationChallenge; /* required element of type xsd:hexBinary */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Header (26)
+/* SOAP Header: */
+struct SOAP_ENV__Header
+{
+#ifdef WITH_NOEMPTYSTRUCT
+private:
+ char dummy; /* dummy member to enable compilation */
+#endif
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Code (27)
+/* SOAP Fault Code: */
+struct SOAP_ENV__Code
+{
+public:
+ char *SOAP_ENV__Value; /* optional element of type xsd:QName */
+ struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Detail (29)
+/* SOAP-ENV:Detail */
+struct SOAP_ENV__Detail
+{
+public:
+ int __type; /* any type of element <fault> (defined below) */
+ void *fault; /* transient */
+ char *__any;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Reason (32)
+/* SOAP-ENV:Reason */
+struct SOAP_ENV__Reason
+{
+public:
+ char *SOAP_ENV__Text; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_Certificate_SOAP_ENV__Fault (33)
+/* SOAP Fault: */
+struct SOAP_ENV__Fault
+{
+public:
+ char *faultcode; /* optional element of type xsd:QName */
+ char *faultstring; /* optional element of type xsd:string */
+ char *faultactor; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */
+ struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */
+ struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */
+ char *SOAP_ENV__Node; /* optional element of type xsd:string */
+ char *SOAP_ENV__Role; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */
+};
+#endif
+
+/******************************************************************************\
+ * *
+ * Typedefs *
+ * *
+\******************************************************************************/
+
+#ifndef SOAP_TYPE_KMS_Certificate__QName
+#define SOAP_TYPE_KMS_Certificate__QName (5)
+typedef char *_QName;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate__XML
+#define SOAP_TYPE_KMS_Certificate__XML (6)
+typedef char *_XML;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__string
+#define SOAP_TYPE_KMS_Certificate_xsd__string (7)
+typedef char *xsd__string;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__float
+#define SOAP_TYPE_KMS_Certificate_xsd__float (9)
+typedef float xsd__float;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__int
+#define SOAP_TYPE_KMS_Certificate_xsd__int (11)
+typedef long xsd__int;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__boolean
+#define SOAP_TYPE_KMS_Certificate_xsd__boolean (13)
+typedef bool xsd__boolean;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__long
+#define SOAP_TYPE_KMS_Certificate_xsd__long (15)
+typedef LONG64 xsd__long;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__dateTime
+#define SOAP_TYPE_KMS_Certificate_xsd__dateTime (16)
+typedef char *xsd__dateTime;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Certificate_xsd__duration
+#define SOAP_TYPE_KMS_Certificate_xsd__duration (17)
+typedef char *xsd__duration;
+#endif
+
+
+/******************************************************************************\
+ * *
+ * Externals *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Server-Side Operations *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Certificate__RetrieveEntityCertificate(struct soap*, char *EntityID, struct xsd__hexBinary ClientAuthenticationResponse, struct xsd__hexBinary ServerAuthenticationChallenge, struct KMS_Certificate__RetrieveEntityCertificateResponse &result);
+
+/******************************************************************************\
+ * *
+ * Server-Side Skeletons to Invoke Service Operations *
+ * *
+\******************************************************************************/
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Certificate_serve(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Certificate_serve_request(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Certificate__RetrieveEntityCertificate(struct soap*);
+
+/******************************************************************************\
+ * *
+ * Client-Side Call Stubs *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Certificate__RetrieveEntityCertificate(struct soap *soap, const char *soap_endpoint, const char *soap_action, char *EntityID, struct xsd__hexBinary ClientAuthenticationResponse, struct xsd__hexBinary ServerAuthenticationChallenge, struct KMS_Certificate__RetrieveEntityCertificateResponse &result);
+
+} // namespace KMS_Certificate
+
+
+#endif
+
+/* End of KMS_CertificateStub.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_Discovery.nsmap b/usr/src/lib/libkmsagent/common/SOAP/KMS_Discovery.nsmap
new file mode 100644
index 0000000000..401e481af4
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_Discovery.nsmap
@@ -0,0 +1,36 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include "KMS_DiscoveryH.h"
+SOAP_NMAC struct Namespace KMS_Discovery_namespaces[] =
+{
+ {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope"},
+ {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding"},
+ {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},
+ {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},
+ {"KMS-Discovery", "http://www.sun.com/KMS/KMS-Discovery"},
+ {NULL, NULL}
+};
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryC.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryC.cpp
new file mode 100644
index 0000000000..d74d4b84f6
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryC.cpp
@@ -0,0 +1,2904 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_DiscoveryC.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/DiscoveryService/KMS_Discovery_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+
+#include "KMS_DiscoveryH.h"
+
+namespace KMS_Discovery {
+
+SOAP_SOURCE_STAMP("@(#) KMS_DiscoveryC.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap)
+{
+ if (soap->header)
+ soap_serialize_SOAP_ENV__Header(soap, soap->header);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap)
+{
+ if (soap->header)
+ { soap->part = SOAP_IN_HEADER;
+ if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, NULL))
+ return soap->error;
+ soap->part = SOAP_END_HEADER;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap)
+{
+ soap->part = SOAP_IN_HEADER;
+ soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", NULL, NULL);
+ soap->part = SOAP_END_HEADER;
+ return soap->header == NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap)
+{
+ if (!soap->header)
+ { if ((soap->header = soap_new_SOAP_ENV__Header(soap, -1)))
+ soap_default_SOAP_ENV__Header(soap, soap->header);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap)
+{
+ if (!soap->fault)
+ { soap->fault = soap_new_SOAP_ENV__Fault(soap, -1);
+ if (!soap->fault)
+ return;
+ soap_default_SOAP_ENV__Fault(soap, soap->fault);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Code)
+ { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason)
+ { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap, -1);
+ soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->fault)
+ soap_serialize_SOAP_ENV__Fault(soap, soap->fault);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap)
+{
+ if (soap->fault)
+ return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", NULL);
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap)
+{
+ return (soap->fault = soap_get_SOAP_ENV__Fault(soap, NULL, "SOAP-ENV:Fault", NULL)) == NULL;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value;
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ { if (!soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
+ { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value;
+ }
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text;
+ return (const char**)&soap->fault->faultstring;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 1)
+ { if (!soap->fault->detail)
+ { soap->fault->detail = (struct SOAP_ENV__Detail*)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail));
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->detail);
+ }
+ return (const char**)&soap->fault->detail->__any;
+ }
+ if (!soap->fault->SOAP_ENV__Detail)
+ { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1);
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->SOAP_ENV__Detail);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Detail->__any;
+}
+
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap)
+{
+ int t;
+ if (soap->version == 1)
+ { for (;;)
+ { if (!soap_getelement(soap, &t))
+ if (soap->error || soap_ignore_element(soap))
+ break;
+ }
+ }
+ if (soap->error == SOAP_NO_TAG || soap->error == SOAP_EOF)
+ soap->error = SOAP_OK;
+ return soap->error;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type)
+{
+ if (soap_peek_element(soap))
+ return NULL;
+ if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id)))
+ *type = soap_lookup_type(soap, soap->href);
+ switch (*type)
+ {
+ case SOAP_TYPE_KMS_Discovery_byte:
+ return soap_in_byte(soap, NULL, NULL, "xsd:byte");
+ case SOAP_TYPE_KMS_Discovery_int:
+ return soap_in_int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_Discovery_xsd__int:
+ return soap_in_xsd__int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE_KMS_Discovery_long:
+ return soap_in_long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Discovery_xsd__long:
+ return soap_in_xsd__long(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Discovery_LONG64:
+ return soap_in_LONG64(soap, NULL, NULL, "xsd:long");
+ case SOAP_TYPE_KMS_Discovery_xsd__float:
+ return soap_in_xsd__float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_Discovery_float:
+ return soap_in_float(soap, NULL, NULL, "xsd:float");
+ case SOAP_TYPE_KMS_Discovery_unsignedByte:
+ return soap_in_unsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Discovery_unsignedInt:
+ return soap_in_unsignedInt(soap, NULL, NULL, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_Discovery_xsd__boolean:
+ return soap_in_xsd__boolean(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_Discovery_bool:
+ return soap_in_bool(soap, NULL, NULL, "xsd:boolean");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster:
+ return soap_in_KMS_Discovery__DiscoverCluster(soap, NULL, NULL, "KMS-Discovery:DiscoverCluster");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse:
+ return soap_in_KMS_Discovery__DiscoverClusterResponse(soap, NULL, NULL, "KMS-Discovery:DiscoverClusterResponse");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers:
+ return soap_in_KMS_Discovery__ArrayOfClusterMembers(soap, NULL, NULL, "KMS-Discovery:ArrayOfClusterMembers");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember:
+ return soap_in_KMS_Discovery_ClusterMember(soap, NULL, NULL, "KMS-Discovery-ClusterMember");
+ case SOAP_TYPE_KMS_Discovery_xsd__hexBinary:
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Discovery_PointerToKMS_Discovery_ClusterMember:
+ return soap_in_PointerToKMS_Discovery_ClusterMember(soap, NULL, NULL, "KMS-Discovery-ClusterMember");
+ case SOAP_TYPE_KMS_Discovery_PointerTounsignedByte:
+ return soap_in_PointerTounsignedByte(soap, NULL, NULL, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Discovery_xsd__networkAddress:
+ { char **s;
+ s = soap_in_xsd__networkAddress(soap, NULL, NULL, "xsd:networkAddress");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Discovery_xsd__kmaVersion:
+ { char **s;
+ s = soap_in_xsd__kmaVersion(soap, NULL, NULL, "xsd:kmaVersion");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Discovery_xsd__duration:
+ { char **s;
+ s = soap_in_xsd__duration(soap, NULL, NULL, "xsd:duration");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Discovery_xsd__dateTime:
+ { char **s;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, "xsd:dateTime");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Discovery_xsd__string:
+ { char **s;
+ s = soap_in_xsd__string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Discovery__QName:
+ { char **s;
+ s = soap_in__QName(soap, NULL, NULL, "xsd:QName");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_KMS_Discovery_string:
+ { char **s;
+ s = soap_in_string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ default:
+ { const char *t = soap->type;
+ if (!*t)
+ t = soap->tag;
+ if (!soap_match_tag(soap, t, "xsd:byte"))
+ { *type = SOAP_TYPE_KMS_Discovery_byte;
+ return soap_in_byte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_Discovery_int;
+ return soap_in_int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_KMS_Discovery_xsd__int;
+ return soap_in_xsd__int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Discovery_long;
+ return soap_in_long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Discovery_xsd__long;
+ return soap_in_xsd__long(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:long"))
+ { *type = SOAP_TYPE_KMS_Discovery_LONG64;
+ return soap_in_LONG64(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_Discovery_xsd__float;
+ return soap_in_xsd__float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:float"))
+ { *type = SOAP_TYPE_KMS_Discovery_float;
+ return soap_in_float(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedByte"))
+ { *type = SOAP_TYPE_KMS_Discovery_unsignedByte;
+ return soap_in_unsignedByte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:unsignedInt"))
+ { *type = SOAP_TYPE_KMS_Discovery_unsignedInt;
+ return soap_in_unsignedInt(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_Discovery_xsd__boolean;
+ return soap_in_xsd__boolean(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:boolean"))
+ { *type = SOAP_TYPE_KMS_Discovery_bool;
+ return soap_in_bool(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Discovery:DiscoverCluster"))
+ { *type = SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster;
+ return soap_in_KMS_Discovery__DiscoverCluster(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Discovery:DiscoverClusterResponse"))
+ { *type = SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse;
+ return soap_in_KMS_Discovery__DiscoverClusterResponse(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Discovery:ArrayOfClusterMembers"))
+ { *type = SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers;
+ return soap_in_KMS_Discovery__ArrayOfClusterMembers(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "KMS-Discovery-ClusterMember"))
+ { *type = SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember;
+ return soap_in_KMS_Discovery_ClusterMember(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:hexBinary"))
+ { *type = SOAP_TYPE_KMS_Discovery_xsd__hexBinary;
+ return soap_in_xsd__hexBinary(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:networkAddress"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery_xsd__networkAddress;
+ s = soap_in_xsd__networkAddress(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:kmaVersion"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery_xsd__kmaVersion;
+ s = soap_in_xsd__kmaVersion(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:duration"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery_xsd__duration;
+ s = soap_in_xsd__duration(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:dateTime"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery_xsd__dateTime;
+ s = soap_in_xsd__dateTime(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery_xsd__string;
+ s = soap_in_xsd__string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:QName"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery__QName;
+ s = soap_in__QName(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_KMS_Discovery_string;
+ s = soap_in_string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ t = soap->tag;
+ }
+ }
+ soap->error = SOAP_TAG_MISMATCH;
+ return NULL;
+}
+#endif
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap)
+{
+ if (!soap_peek_element(soap))
+ { int t;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body));
+ if (soap->mustUnderstand && !soap->other)
+ return soap->error = SOAP_MUSTUNDERSTAND;
+ if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag));
+ return soap->error = SOAP_TAG_MISMATCH;
+ }
+ if (!*soap->id || !soap_getelement(soap, &t))
+ { soap->peeked = 0;
+ if (soap->fignore)
+ soap->error = soap->fignore(soap, soap->tag);
+ else
+ soap->error = SOAP_OK;
+ DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag));
+ if (!soap->error && soap->body)
+ { soap->level++;
+ while (!soap_ignore_element(soap))
+ ;
+ if (soap->error == SOAP_NO_TAG)
+ soap->error = soap_element_end_in(soap, NULL);
+ }
+ }
+ }
+ return soap->error;
+}
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap)
+{
+ int i;
+ struct soap_plist *pp;
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)))
+ for (i = 0; i < SOAP_PTRHASH; i++)
+ for (pp = soap->pht[i]; pp; pp = pp->next)
+ if (pp->mark1 == 2 || pp->mark2 == 2)
+ if (soap_putelement(soap, pp->ptr, "id", pp->id, pp->type))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, const char *tag, int id, int type)
+{
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_Discovery_byte:
+ return soap_out_byte(soap, tag, id, (const char *)ptr, "xsd:byte");
+ case SOAP_TYPE_KMS_Discovery_int:
+ return soap_out_int(soap, tag, id, (const int *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_Discovery_xsd__int:
+ return soap_out_xsd__int(soap, tag, id, (const long *)ptr, "xsd:int");
+ case SOAP_TYPE_KMS_Discovery_long:
+ return soap_out_long(soap, tag, id, (const long *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Discovery_xsd__long:
+ return soap_out_xsd__long(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Discovery_LONG64:
+ return soap_out_LONG64(soap, tag, id, (const LONG64 *)ptr, "xsd:long");
+ case SOAP_TYPE_KMS_Discovery_xsd__float:
+ return soap_out_xsd__float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_Discovery_float:
+ return soap_out_float(soap, tag, id, (const float *)ptr, "xsd:float");
+ case SOAP_TYPE_KMS_Discovery_unsignedByte:
+ return soap_out_unsignedByte(soap, tag, id, (const unsigned char *)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Discovery_unsignedInt:
+ return soap_out_unsignedInt(soap, tag, id, (const unsigned int *)ptr, "xsd:unsignedInt");
+ case SOAP_TYPE_KMS_Discovery_xsd__boolean:
+ return soap_out_xsd__boolean(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_Discovery_bool:
+ return soap_out_bool(soap, tag, id, (const bool *)ptr, "xsd:boolean");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster:
+ return soap_out_KMS_Discovery__DiscoverCluster(soap, tag, id, (const struct KMS_Discovery__DiscoverCluster *)ptr, "KMS-Discovery:DiscoverCluster");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse:
+ return soap_out_KMS_Discovery__DiscoverClusterResponse(soap, tag, id, (const struct KMS_Discovery__DiscoverClusterResponse *)ptr, "KMS-Discovery:DiscoverClusterResponse");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers:
+ return soap_out_KMS_Discovery__ArrayOfClusterMembers(soap, tag, id, (const struct KMS_Discovery__ArrayOfClusterMembers *)ptr, "KMS-Discovery:ArrayOfClusterMembers");
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember:
+ return soap_out_KMS_Discovery_ClusterMember(soap, tag, id, (const struct KMS_Discovery_ClusterMember *)ptr, "KMS-Discovery-ClusterMember");
+ case SOAP_TYPE_KMS_Discovery_xsd__hexBinary:
+ return soap_out_xsd__hexBinary(soap, tag, id, (const struct xsd__hexBinary *)ptr, "xsd:hexBinary");
+ case SOAP_TYPE_KMS_Discovery_PointerToKMS_Discovery_ClusterMember:
+ return soap_out_PointerToKMS_Discovery_ClusterMember(soap, tag, id, (struct KMS_Discovery_ClusterMember *const*)ptr, "KMS-Discovery-ClusterMember");
+ case SOAP_TYPE_KMS_Discovery_PointerTounsignedByte:
+ return soap_out_PointerTounsignedByte(soap, tag, id, (unsigned char *const*)ptr, "xsd:unsignedByte");
+ case SOAP_TYPE_KMS_Discovery_xsd__networkAddress:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:networkAddress");
+ case SOAP_TYPE_KMS_Discovery_xsd__kmaVersion:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:kmaVersion");
+ case SOAP_TYPE_KMS_Discovery_xsd__duration:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:duration");
+ case SOAP_TYPE_KMS_Discovery_xsd__dateTime:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:dateTime");
+ case SOAP_TYPE_KMS_Discovery_xsd__string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ case SOAP_TYPE_KMS_Discovery__QName:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:QName");
+ case SOAP_TYPE_KMS_Discovery_string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ }
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, int type)
+{
+ (void)soap; (void)ptr; (void)type; /* appease -Wall -Werror */
+ switch (type)
+ {
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster:
+ soap_serialize_KMS_Discovery__DiscoverCluster(soap, (const struct KMS_Discovery__DiscoverCluster *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse:
+ soap_serialize_KMS_Discovery__DiscoverClusterResponse(soap, (const struct KMS_Discovery__DiscoverClusterResponse *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers:
+ soap_serialize_KMS_Discovery__ArrayOfClusterMembers(soap, (const struct KMS_Discovery__ArrayOfClusterMembers *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember:
+ soap_serialize_KMS_Discovery_ClusterMember(soap, (const struct KMS_Discovery_ClusterMember *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_xsd__hexBinary:
+ soap_serialize_xsd__hexBinary(soap, (const struct xsd__hexBinary *)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_PointerToKMS_Discovery_ClusterMember:
+ soap_serialize_PointerToKMS_Discovery_ClusterMember(soap, (struct KMS_Discovery_ClusterMember *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_PointerTounsignedByte:
+ soap_serialize_PointerTounsignedByte(soap, (unsigned char *const*)ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_xsd__networkAddress:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_xsd__kmaVersion:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_xsd__duration:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_xsd__dateTime:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_xsd__string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery__QName:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ }
+}
+#endif
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n)
+{
+ switch (t)
+ {
+ case SOAP_TYPE_KMS_Discovery_xsd__hexBinary:
+ return (void*)soap_instantiate_xsd__hexBinary(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember:
+ return (void*)soap_instantiate_KMS_Discovery_ClusterMember(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers:
+ return (void*)soap_instantiate_KMS_Discovery__ArrayOfClusterMembers(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse:
+ return (void*)soap_instantiate_KMS_Discovery__DiscoverClusterResponse(soap, -1, type, arrayType, n);
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster:
+ return (void*)soap_instantiate_KMS_Discovery__DiscoverCluster(soap, -1, type, arrayType, n);
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header:
+ return (void*)soap_instantiate_SOAP_ENV__Header(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code:
+ return (void*)soap_instantiate_SOAP_ENV__Code(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail:
+ return (void*)soap_instantiate_SOAP_ENV__Detail(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason:
+ return (void*)soap_instantiate_SOAP_ENV__Reason(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault:
+ return (void*)soap_instantiate_SOAP_ENV__Fault(soap, -1, type, arrayType, n);
+#endif
+ }
+ return NULL;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p)
+{ switch (p->type)
+ {
+ case SOAP_TYPE_KMS_Discovery_xsd__hexBinary:
+ if (p->size < 0)
+ SOAP_DELETE((struct xsd__hexBinary*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct xsd__hexBinary*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Discovery_ClusterMember*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Discovery_ClusterMember*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Discovery__ArrayOfClusterMembers*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Discovery__ArrayOfClusterMembers*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Discovery__DiscoverClusterResponse*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Discovery__DiscoverClusterResponse*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster:
+ if (p->size < 0)
+ SOAP_DELETE((struct KMS_Discovery__DiscoverCluster*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct KMS_Discovery__DiscoverCluster*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr);
+ break;
+ case SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr);
+ break;
+ default: return SOAP_ERR;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType)
+{ return soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_byte
+ *a = SOAP_DEFAULT_byte;
+#else
+ *a = (char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type)
+{
+ return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_byte);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap *soap, const char *tag, char *a, const char *type)
+{ char *p;
+ p = soap_inbyte(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_byte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap *soap, const char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_byte);
+ if (soap_out_byte(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap *soap, char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_byte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_int
+ *a = SOAP_DEFAULT_int;
+#else
+ *a = (int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type)
+{
+ return soap_outint(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_int);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap *soap, const char *tag, int *a, const char *type)
+{ int *p;
+ p = soap_inint(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap *soap, const int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_int);
+ if (soap_out_int(soap, tag?tag:"int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap *soap, int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__int);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__int);
+ if (soap_out_xsd__int(soap, tag?tag:"xsd:int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap *soap, long *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_long
+ *a = SOAP_DEFAULT_long;
+#else
+ *a = (long)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap *soap, const char *tag, int id, const long *a, const char *type)
+{
+ return soap_outlong(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_long);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap *soap, const char *tag, long *a, const char *type)
+{ long *p;
+ p = soap_inlong(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap *soap, const long *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_long);
+ if (soap_out_long(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap *soap, long *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__long);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__long);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__long);
+ if (soap_out_xsd__long(soap, tag?tag:"xsd:long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__long(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap *soap, LONG64 *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_LONG64
+ *a = SOAP_DEFAULT_LONG64;
+#else
+ *a = (LONG64)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
+{
+ return soap_outLONG64(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_LONG64);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap *soap, const char *tag, LONG64 *a, const char *type)
+{ LONG64 *p;
+ p = soap_inLONG64(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_LONG64);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap *soap, const LONG64 *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_LONG64);
+ if (soap_out_LONG64(soap, tag?tag:"long", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap *soap, LONG64 *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_LONG64(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__float);
+ if (soap_out_xsd__float(soap, tag?tag:"xsd:float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap *soap, float *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_float
+ *a = SOAP_DEFAULT_float;
+#else
+ *a = (float)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap *soap, const char *tag, int id, const float *a, const char *type)
+{
+ return soap_outfloat(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_float);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap *soap, const char *tag, float *a, const char *type)
+{ float *p;
+ p = soap_infloat(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_float);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap *soap, const float *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_float);
+ if (soap_out_float(soap, tag?tag:"float", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap *soap, float *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_float(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap *soap, unsigned char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedByte
+ *a = SOAP_DEFAULT_unsignedByte;
+#else
+ *a = (unsigned char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *a, const char *type)
+{
+ return soap_outunsignedByte(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_unsignedByte);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap *soap, const char *tag, unsigned char *a, const char *type)
+{ unsigned char *p;
+ p = soap_inunsignedByte(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_unsignedByte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap *soap, const unsigned char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_unsignedByte);
+ if (soap_out_unsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap *soap, unsigned char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap *soap, unsigned int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_unsignedInt
+ *a = SOAP_DEFAULT_unsignedInt;
+#else
+ *a = (unsigned int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *a, const char *type)
+{
+ return soap_outunsignedInt(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_unsignedInt);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap *soap, const char *tag, unsigned int *a, const char *type)
+{ unsigned int *p;
+ p = soap_inunsignedInt(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_unsignedInt);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap *soap, const unsigned int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_unsignedInt);
+ if (soap_out_unsignedInt(soap, tag?tag:"unsignedInt", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap *soap, unsigned int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_unsignedInt(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap *soap, bool n)
+{ return soap_bool2s(soap, n);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_xsd__boolean), type) || soap_send(soap, soap_xsd__boolean2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap *soap, const char *s, bool *a)
+{
+ return soap_s2bool(soap, s, a);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_xsd__boolean, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2xsd__boolean(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_xsd__boolean, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__boolean);
+ if (soap_out_xsd__boolean(soap, tag?tag:"xsd:boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__boolean(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap *soap, bool *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_bool
+ *a = SOAP_DEFAULT_bool;
+#else
+ *a = (bool)0;
+#endif
+}
+
+static const struct soap_code_map soap_codes_bool[] =
+{ { (long)false, "false" },
+ { (long)true, "true" },
+ { 0, NULL }
+};
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap *soap, bool n)
+{
+ (void)soap; /* appease -Wall -Werror */
+return soap_code_str(soap_codes_bool, n!=0);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap *soap, const char *tag, int id, const bool *a, const char *type)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_bool), type) || soap_send(soap, soap_bool2s(soap, *a)))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap *soap, const char *s, bool *a)
+{
+ const struct soap_code_map *map;
+ if (!s)
+ return soap->error;
+ map = soap_code(soap_codes_bool, s);
+ if (map)
+ *a = (bool)(map->code != 0);
+ else
+ { long n;
+ if (soap_s2long(soap, s, &n) || n < 0 || n > 1)
+ return soap->error = SOAP_TYPE;
+ *a = (bool)(n != 0);
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap *soap, const char *tag, bool *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":boolean"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (bool *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_bool, sizeof(bool), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ if (soap->body && !*soap->href)
+ { if (!a || soap_s2bool(soap, soap_value(soap), a) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (bool *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_bool, 0, sizeof(bool), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap *soap, const bool *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_bool);
+ if (soap_out_bool(soap, tag?tag:"boolean", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap *soap, bool *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_bool(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->faultcode);
+ soap_default_string(soap, &a->faultstring);
+ soap_default_string(soap, &a->faultactor);
+ a->detail = NULL;
+ a->SOAP_ENV__Code = NULL;
+ a->SOAP_ENV__Reason = NULL;
+ soap_default_string(soap, &a->SOAP_ENV__Node);
+ soap_default_string(soap, &a->SOAP_ENV__Role);
+ a->SOAP_ENV__Detail = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->faultcode);
+ soap_serialize_string(soap, &a->faultstring);
+ soap_serialize_string(soap, &a->faultactor);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->detail);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Code);
+ soap_serialize_PointerToSOAP_ENV__Reason(soap, &a->SOAP_ENV__Reason);
+ soap_serialize_string(soap, &a->SOAP_ENV__Node);
+ soap_serialize_string(soap, &a->SOAP_ENV__Role);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->SOAP_ENV__Detail);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type)
+{
+ const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault), type))
+ return soap->error;
+ if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, ""))
+ return soap->error;
+ if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "xsd:string"))
+ return soap->error;
+ if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "xsd:string"))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", -1, &a->SOAP_ENV__Code, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", -1, &a->SOAP_ENV__Reason, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Node", -1, &a->SOAP_ENV__Node, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Role", -1, &a->SOAP_ENV__Role, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", -1, &a->SOAP_ENV__Detail, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap *soap, const char *tag, struct SOAP_ENV__Fault *a, const char *type)
+{
+ size_t soap_flag_faultcode = 1;
+ size_t soap_flag_faultstring = 1;
+ size_t soap_flag_faultactor = 1;
+ size_t soap_flag_detail = 1;
+ size_t soap_flag_SOAP_ENV__Code = 1;
+ size_t soap_flag_SOAP_ENV__Reason = 1;
+ size_t soap_flag_SOAP_ENV__Node = 1;
+ size_t soap_flag_SOAP_ENV__Role = 1;
+ size_t soap_flag_SOAP_ENV__Detail = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Fault(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_faultcode && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "faultcode", &a->faultcode, ""))
+ { soap_flag_faultcode--;
+ continue;
+ }
+ if (soap_flag_faultstring && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultstring", &a->faultstring, "xsd:string"))
+ { soap_flag_faultstring--;
+ continue;
+ }
+ if (soap_flag_faultactor && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultactor", &a->faultactor, "xsd:string"))
+ { soap_flag_faultactor--;
+ continue;
+ }
+ if (soap_flag_detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "detail", &a->detail, ""))
+ { soap_flag_detail--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Code && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", &a->SOAP_ENV__Code, ""))
+ { soap_flag_SOAP_ENV__Code--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Reason && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", &a->SOAP_ENV__Reason, ""))
+ { soap_flag_SOAP_ENV__Reason--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Node && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Node", &a->SOAP_ENV__Node, "xsd:string"))
+ { soap_flag_SOAP_ENV__Node--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Role && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Role", &a->SOAP_ENV__Role, "xsd:string"))
+ { soap_flag_SOAP_ENV__Role--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", &a->SOAP_ENV__Detail, ""))
+ { soap_flag_SOAP_ENV__Detail--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault, 0, sizeof(struct SOAP_ENV__Fault), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault);
+ if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Fault(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Fault);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Fault);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Fault*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason), type))
+ return soap->error;
+ if (soap->lang)
+ soap_set_attr(soap, "xml:lang", soap->lang, 1);
+ if (soap_out_string(soap, "SOAP-ENV:Text", -1, &a->SOAP_ENV__Text, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Text = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Reason(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Text && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Text", &a->SOAP_ENV__Text, "xsd:string"))
+ { soap_flag_SOAP_ENV__Text--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason, 0, sizeof(struct SOAP_ENV__Reason), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason);
+ if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Reason);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Reason);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Reason*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ a->__type = 0;
+ a->fault = NULL;
+ a->__any = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_markelement(soap, a->fault, a->__type);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail), type))
+ return soap->error;
+ if (soap_putelement(soap, a->fault, "fault", -1, a->__type))
+ return soap->error;
+ soap_outliteral(soap, "-any", &a->__any, NULL);
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail *a, const char *type)
+{
+ size_t soap_flag_fault = 1;
+ size_t soap_flag___any = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Detail(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_fault && soap->error == SOAP_TAG_MISMATCH)
+ if ((a->fault = soap_getelement(soap, &a->__type)))
+ { soap_flag_fault = 0;
+ continue;
+ }
+ if (soap_flag___any && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_inliteral(soap, "-any", &a->__any))
+ { soap_flag___any--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail, 0, sizeof(struct SOAP_ENV__Detail), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail);
+ if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Detail);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Detail);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Detail*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->SOAP_ENV__Value);
+ a->SOAP_ENV__Subcode = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->SOAP_ENV__Value);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Subcode);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type)
+{
+ const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code), type))
+ return soap->error;
+ if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Value = 1;
+ size_t soap_flag_SOAP_ENV__Subcode = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Code(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Value && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "SOAP-ENV:Value", &a->SOAP_ENV__Value, ""))
+ { soap_flag_SOAP_ENV__Value--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Subcode && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", &a->SOAP_ENV__Subcode, ""))
+ { soap_flag_SOAP_ENV__Subcode--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code, 0, sizeof(struct SOAP_ENV__Code), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code);
+ if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Code);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Code);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Code*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header), type))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap *soap, const char *tag, struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Header(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header, 0, sizeof(struct SOAP_ENV__Header), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header);
+ if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Header(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Header);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Header);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Header*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery__DiscoverCluster(struct soap *soap, struct KMS_Discovery__DiscoverCluster *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ /* transient _ skipped */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery__DiscoverCluster(struct soap *soap, const struct KMS_Discovery__DiscoverCluster *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ /* transient _ skipped */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery__DiscoverCluster(struct soap *soap, const char *tag, int id, const struct KMS_Discovery__DiscoverCluster *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster), type))
+ return soap->error;
+ /* transient _ skipped */
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Discovery__DiscoverCluster * SOAP_FMAC4 soap_in_KMS_Discovery__DiscoverCluster(struct soap *soap, const char *tag, struct KMS_Discovery__DiscoverCluster *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Discovery__DiscoverCluster *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster, sizeof(struct KMS_Discovery__DiscoverCluster), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Discovery__DiscoverCluster(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ /* transient _ skipped */
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Discovery__DiscoverCluster *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster, 0, sizeof(struct KMS_Discovery__DiscoverCluster), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery__DiscoverCluster(struct soap *soap, const struct KMS_Discovery__DiscoverCluster *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster);
+ if (soap_out_KMS_Discovery__DiscoverCluster(soap, tag?tag:"KMS-Discovery:DiscoverCluster", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Discovery__DiscoverCluster * SOAP_FMAC4 soap_get_KMS_Discovery__DiscoverCluster(struct soap *soap, struct KMS_Discovery__DiscoverCluster *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Discovery__DiscoverCluster(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Discovery__DiscoverCluster * SOAP_FMAC2 soap_instantiate_KMS_Discovery__DiscoverCluster(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Discovery__DiscoverCluster(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery__DiscoverCluster);
+ if (size)
+ *size = sizeof(struct KMS_Discovery__DiscoverCluster);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery__DiscoverCluster[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Discovery__DiscoverCluster);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Discovery__DiscoverCluster*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery__DiscoverCluster(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Discovery__DiscoverCluster %p -> %p\n", q, p));
+ *(struct KMS_Discovery__DiscoverCluster*)p = *(struct KMS_Discovery__DiscoverCluster*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, struct KMS_Discovery__DiscoverClusterResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__string(soap, &a->EntitySiteID);
+ soap_default_KMS_Discovery__ArrayOfClusterMembers(soap, &a->ArrayOfClusterMembers);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, const struct KMS_Discovery__DiscoverClusterResponse *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->EntitySiteID);
+ soap_serialize_KMS_Discovery__ArrayOfClusterMembers(soap, &a->ArrayOfClusterMembers);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, const char *tag, int id, const struct KMS_Discovery__DiscoverClusterResponse *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse), type))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "EntitySiteID", -1, &a->EntitySiteID, "xsd:string"))
+ return soap->error;
+ if (soap_out_KMS_Discovery__ArrayOfClusterMembers(soap, "ArrayOfClusterMembers", -1, &a->ArrayOfClusterMembers, "KMS-Discovery:ArrayOfClusterMembers"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Discovery__DiscoverClusterResponse * SOAP_FMAC4 soap_in_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, const char *tag, struct KMS_Discovery__DiscoverClusterResponse *a, const char *type)
+{
+ size_t soap_flag_EntitySiteID = 1;
+ size_t soap_flag_ArrayOfClusterMembers = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Discovery__DiscoverClusterResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse, sizeof(struct KMS_Discovery__DiscoverClusterResponse), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Discovery__DiscoverClusterResponse(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_EntitySiteID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "EntitySiteID", &a->EntitySiteID, "xsd:string"))
+ { soap_flag_EntitySiteID--;
+ continue;
+ }
+ if (soap_flag_ArrayOfClusterMembers && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_KMS_Discovery__ArrayOfClusterMembers(soap, "ArrayOfClusterMembers", &a->ArrayOfClusterMembers, "KMS-Discovery:ArrayOfClusterMembers"))
+ { soap_flag_ArrayOfClusterMembers--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Discovery__DiscoverClusterResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse, 0, sizeof(struct KMS_Discovery__DiscoverClusterResponse), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, const struct KMS_Discovery__DiscoverClusterResponse *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse);
+ if (soap_out_KMS_Discovery__DiscoverClusterResponse(soap, tag?tag:"KMS-Discovery:DiscoverClusterResponse", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Discovery__DiscoverClusterResponse * SOAP_FMAC4 soap_get_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, struct KMS_Discovery__DiscoverClusterResponse *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Discovery__DiscoverClusterResponse(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Discovery__DiscoverClusterResponse * SOAP_FMAC2 soap_instantiate_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Discovery__DiscoverClusterResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery__DiscoverClusterResponse);
+ if (size)
+ *size = sizeof(struct KMS_Discovery__DiscoverClusterResponse);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery__DiscoverClusterResponse[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Discovery__DiscoverClusterResponse);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Discovery__DiscoverClusterResponse*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery__DiscoverClusterResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Discovery__DiscoverClusterResponse %p -> %p\n", q, p));
+ *(struct KMS_Discovery__DiscoverClusterResponse*)p = *(struct KMS_Discovery__DiscoverClusterResponse*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, struct KMS_Discovery__ArrayOfClusterMembers *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, struct KMS_Discovery__ArrayOfClusterMembers const*a)
+{
+ int i;
+ if (a->__ptr && !soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers))
+ for (i = 0; i < a->__size; i++)
+ { soap_embedded(soap, a->__ptr + i, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember);
+ soap_serialize_KMS_Discovery_ClusterMember(soap, a->__ptr + i);
+ }
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, const char *tag, int id, const struct KMS_Discovery__ArrayOfClusterMembers *a, const char *type)
+{
+ int i, n = a->__size;
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ for (i = 0; i < n; i++)
+ {
+ soap_out_KMS_Discovery_ClusterMember(soap, "item", -1, &a->__ptr[i], "KMS-Discovery-ClusterMember");
+ }
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Discovery__ArrayOfClusterMembers * SOAP_FMAC4 soap_in_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, const char *tag, struct KMS_Discovery__ArrayOfClusterMembers *a, const char *type)
+{ int i, j;
+ struct KMS_Discovery_ClusterMember *p;
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_array(soap, "KMS-Discovery-ClusterMember") && soap_match_tag(soap, soap->type, type))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct KMS_Discovery__ArrayOfClusterMembers *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers, sizeof(struct KMS_Discovery__ArrayOfClusterMembers), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Discovery__ArrayOfClusterMembers(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__size = soap_getsize(soap->arraySize, soap->arrayOffset, &j);
+ if (a->__size >= 0)
+ { a->__ptr = (struct KMS_Discovery_ClusterMember *)soap_malloc(soap, sizeof(struct KMS_Discovery_ClusterMember) * a->__size);
+ for (i = 0; i < a->__size; i++)
+ soap_default_KMS_Discovery_ClusterMember(soap, a->__ptr+i);
+ for (i = 0; i < a->__size; i++)
+ { soap_peek_element(soap);
+ if (soap->position)
+ { i = soap->positions[0]-j;
+ if (i < 0 || i >= a->__size)
+ { soap->error = SOAP_IOB;
+ return NULL;
+ }
+ }
+ if (!soap_in_KMS_Discovery_ClusterMember(soap, NULL, a->__ptr + i, "KMS-Discovery-ClusterMember"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ }
+ else
+ { if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (a->__size = 0; ; a->__size++)
+ { p = (struct KMS_Discovery_ClusterMember *)soap_push_block(soap, NULL, sizeof(struct KMS_Discovery_ClusterMember));
+ if (!p)
+ return NULL;
+ soap_default_KMS_Discovery_ClusterMember(soap, p);
+ if (!soap_in_KMS_Discovery_ClusterMember(soap, NULL, p, "KMS-Discovery-ClusterMember"))
+ { if (soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ break;
+ }
+ }
+ soap_pop_block(soap, NULL);
+ a->__ptr = (struct KMS_Discovery_ClusterMember *)soap_malloc(soap, soap->blist->size);
+ soap_save_block(soap, NULL, (char*)a->__ptr, 1);
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Discovery__ArrayOfClusterMembers *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers, 0, sizeof(struct KMS_Discovery__ArrayOfClusterMembers), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, const struct KMS_Discovery__ArrayOfClusterMembers *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers);
+ if (soap_out_KMS_Discovery__ArrayOfClusterMembers(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Discovery__ArrayOfClusterMembers * SOAP_FMAC4 soap_get_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, struct KMS_Discovery__ArrayOfClusterMembers *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Discovery__ArrayOfClusterMembers(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Discovery__ArrayOfClusterMembers * SOAP_FMAC2 soap_instantiate_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Discovery__ArrayOfClusterMembers(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery__ArrayOfClusterMembers);
+ if (size)
+ *size = sizeof(struct KMS_Discovery__ArrayOfClusterMembers);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery__ArrayOfClusterMembers[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Discovery__ArrayOfClusterMembers);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Discovery__ArrayOfClusterMembers*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery__ArrayOfClusterMembers(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Discovery__ArrayOfClusterMembers %p -> %p\n", q, p));
+ *(struct KMS_Discovery__ArrayOfClusterMembers*)p = *(struct KMS_Discovery__ArrayOfClusterMembers*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery_ClusterMember(struct soap *soap, struct KMS_Discovery_ClusterMember *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_xsd__long(soap, &a->KMAID);
+ soap_default_xsd__string(soap, &a->KMAName);
+ soap_default_xsd__string(soap, &a->KMASiteID);
+ soap_default_xsd__string(soap, &a->KMAHostName);
+ soap_default_xsd__string(soap, &a->KMANetworkAddress);
+ soap_default_xsd__boolean(soap, &a->Enabled);
+ soap_default_xsd__int(soap, &a->Load);
+ soap_default_xsd__boolean(soap, &a->Responding);
+ a->KMAVersion = (char *)"";
+ a->KMAHostNameIPv6 = (char *)"";
+ a->KMANetworkAddressIPv6 = (char *)"";
+ a->KMS_Discovery__Locked = (bool)0;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery_ClusterMember(struct soap *soap, const struct KMS_Discovery_ClusterMember *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_xsd__string(soap, &a->KMAName);
+ soap_serialize_xsd__string(soap, &a->KMASiteID);
+ soap_serialize_xsd__string(soap, &a->KMAHostName);
+ soap_serialize_xsd__string(soap, &a->KMANetworkAddress);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery_ClusterMember(struct soap *soap, const char *tag, int id, const struct KMS_Discovery_ClusterMember *a, const char *type)
+{
+ if (a->KMAVersion)
+ soap_set_attr(soap, "KMAVersion", a->KMAVersion, 1);
+ if (a->KMAHostNameIPv6)
+ soap_set_attr(soap, "KMAHostNameIPv6", a->KMAHostNameIPv6, 1);
+ if (a->KMANetworkAddressIPv6)
+ soap_set_attr(soap, "KMANetworkAddressIPv6", a->KMANetworkAddressIPv6, 1);
+ soap_set_attr(soap, "KMS-Discovery:Locked", soap_xsd__boolean2s(soap, a->KMS_Discovery__Locked), 1);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember), type))
+ return soap->error;
+ if (soap_out_xsd__long(soap, "KMAID", -1, &a->KMAID, "xsd:long"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KMAName", -1, &a->KMAName, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KMASiteID", -1, &a->KMASiteID, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KMAHostName", -1, &a->KMAHostName, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__string(soap, "KMANetworkAddress", -1, &a->KMANetworkAddress, "xsd:string"))
+ return soap->error;
+ if (soap_out_xsd__boolean(soap, "Enabled", -1, &a->Enabled, "xsd:boolean"))
+ return soap->error;
+ if (soap_out_xsd__int(soap, "Load", -1, &a->Load, "xsd:int"))
+ return soap->error;
+ if (soap_out_xsd__boolean(soap, "Responding", -1, &a->Responding, "xsd:boolean"))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember * SOAP_FMAC4 soap_in_KMS_Discovery_ClusterMember(struct soap *soap, const char *tag, struct KMS_Discovery_ClusterMember *a, const char *type)
+{
+ size_t soap_flag_KMAID = 1;
+ size_t soap_flag_KMAName = 1;
+ size_t soap_flag_KMASiteID = 1;
+ size_t soap_flag_KMAHostName = 1;
+ size_t soap_flag_KMANetworkAddress = 1;
+ size_t soap_flag_Enabled = 1;
+ size_t soap_flag_Load = 1;
+ size_t soap_flag_Responding = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct KMS_Discovery_ClusterMember *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember, sizeof(struct KMS_Discovery_ClusterMember), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_KMS_Discovery_ClusterMember(soap, a);
+ if (soap_s2string(soap, soap_attr_value(soap, "KMAVersion", 0), &a->KMAVersion, -1, -1))
+ return NULL;
+ if (soap_s2string(soap, soap_attr_value(soap, "KMAHostNameIPv6", 0), &a->KMAHostNameIPv6, -1, -1))
+ return NULL;
+ if (soap_s2string(soap, soap_attr_value(soap, "KMANetworkAddressIPv6", 0), &a->KMANetworkAddressIPv6, -1, -1))
+ return NULL;
+ if (soap_s2xsd__boolean(soap, soap_attr_value(soap, "KMS-Discovery:Locked", 0), &a->KMS_Discovery__Locked))
+ return NULL;
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_KMAID && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__long(soap, "KMAID", &a->KMAID, "xsd:long"))
+ { soap_flag_KMAID--;
+ continue;
+ }
+ if (soap_flag_KMAName && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KMAName", &a->KMAName, "xsd:string"))
+ { soap_flag_KMAName--;
+ continue;
+ }
+ if (soap_flag_KMASiteID && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KMASiteID", &a->KMASiteID, "xsd:string"))
+ { soap_flag_KMASiteID--;
+ continue;
+ }
+ if (soap_flag_KMAHostName && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KMAHostName", &a->KMAHostName, "xsd:string"))
+ { soap_flag_KMAHostName--;
+ continue;
+ }
+ if (soap_flag_KMANetworkAddress && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_xsd__string(soap, "KMANetworkAddress", &a->KMANetworkAddress, "xsd:string"))
+ { soap_flag_KMANetworkAddress--;
+ continue;
+ }
+ if (soap_flag_Enabled && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__boolean(soap, "Enabled", &a->Enabled, "xsd:boolean"))
+ { soap_flag_Enabled--;
+ continue;
+ }
+ if (soap_flag_Load && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__int(soap, "Load", &a->Load, "xsd:int"))
+ { soap_flag_Load--;
+ continue;
+ }
+ if (soap_flag_Responding && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_xsd__boolean(soap, "Responding", &a->Responding, "xsd:boolean"))
+ { soap_flag_Responding--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Discovery_ClusterMember *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember, 0, sizeof(struct KMS_Discovery_ClusterMember), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ if ((soap->mode & SOAP_XML_STRICT) && (soap_flag_KMAID > 0 || soap_flag_Enabled > 0 || soap_flag_Load > 0 || soap_flag_Responding > 0))
+ { soap->error = SOAP_OCCURS;
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery_ClusterMember(struct soap *soap, const struct KMS_Discovery_ClusterMember *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember);
+ if (soap_out_KMS_Discovery_ClusterMember(soap, tag?tag:"KMS-Discovery-ClusterMember", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember * SOAP_FMAC4 soap_get_KMS_Discovery_ClusterMember(struct soap *soap, struct KMS_Discovery_ClusterMember *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_KMS_Discovery_ClusterMember(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct KMS_Discovery_ClusterMember * SOAP_FMAC2 soap_instantiate_KMS_Discovery_ClusterMember(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_KMS_Discovery_ClusterMember(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery_ClusterMember);
+ if (size)
+ *size = sizeof(struct KMS_Discovery_ClusterMember);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct KMS_Discovery_ClusterMember[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct KMS_Discovery_ClusterMember);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct KMS_Discovery_ClusterMember*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery_ClusterMember(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct KMS_Discovery_ClusterMember %p -> %p\n", q, p));
+ *(struct KMS_Discovery_ClusterMember*)p = *(struct KMS_Discovery_ClusterMember*)q;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+ a->__size = 0;
+ a->__ptr = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary const*a)
+{
+ if (a->__ptr)
+ soap_array_reference(soap, a, (struct soap_array*)&a->__ptr, 1, SOAP_TYPE_KMS_Discovery_xsd__hexBinary);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap *soap, const char *tag, int id, const struct xsd__hexBinary *a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, a, (struct soap_array*)&a->__ptr, 1, type, SOAP_TYPE_KMS_Discovery_xsd__hexBinary);
+ if (id < 0)
+ return soap->error;
+ if (soap_element_begin_out(soap, tag, id, type))
+ return soap->error;
+ if (soap_puthex(soap, a->__ptr, a->__size))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap *soap, const char *tag, struct xsd__hexBinary *a, const char *type)
+{
+ (void)type; /* appease -Wall -Werror */
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (*soap->type && soap_match_tag(soap, soap->type, type) && soap_match_tag(soap, soap->type, ":hexBinary"))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ a = (struct xsd__hexBinary *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_KMS_Discovery_xsd__hexBinary, sizeof(struct xsd__hexBinary), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_xsd__hexBinary(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ a->__ptr = soap_gethex(soap, &a->__size);
+ if ((!a->__ptr && soap->error) || soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct xsd__hexBinary *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_KMS_Discovery_xsd__hexBinary, 0, sizeof(struct xsd__hexBinary), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap *soap, const struct xsd__hexBinary *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, (struct soap_array*)&a->__ptr, 1, tag, SOAP_TYPE_KMS_Discovery_xsd__hexBinary);
+ if (soap_out_xsd__hexBinary(soap, tag?tag:"SOAP-ENC:Array", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap *soap, struct xsd__hexBinary *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__hexBinary(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_xsd__hexBinary(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_KMS_Discovery_xsd__hexBinary, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary);
+ if (size)
+ *size = sizeof(struct xsd__hexBinary);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct xsd__hexBinary[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct xsd__hexBinary);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct xsd__hexBinary*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct xsd__hexBinary %p -> %p\n", q, p));
+ *(struct xsd__hexBinary*)p = *(struct xsd__hexBinary*)q;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason))
+ soap_serialize_SOAP_ENV__Reason(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Reason *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Reason(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Reason **)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Reason(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Reason);
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail))
+ soap_serialize_SOAP_ENV__Detail(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Detail *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Detail(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Detail **)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Detail(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Detail);
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code))
+ soap_serialize_SOAP_ENV__Code(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Code *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Code(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Code **)soap_malloc(soap, sizeof(struct SOAP_ENV__Code *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Code(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Code);
+ if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Discovery_ClusterMember(struct soap *soap, struct KMS_Discovery_ClusterMember *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember))
+ soap_serialize_KMS_Discovery_ClusterMember(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Discovery_ClusterMember(struct soap *soap, const char *tag, int id, struct KMS_Discovery_ClusterMember *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember);
+ if (id < 0)
+ return soap->error;
+ return soap_out_KMS_Discovery_ClusterMember(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember ** SOAP_FMAC4 soap_in_PointerToKMS_Discovery_ClusterMember(struct soap *soap, const char *tag, struct KMS_Discovery_ClusterMember **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct KMS_Discovery_ClusterMember **)soap_malloc(soap, sizeof(struct KMS_Discovery_ClusterMember *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_KMS_Discovery_ClusterMember(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct KMS_Discovery_ClusterMember **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember, sizeof(struct KMS_Discovery_ClusterMember), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Discovery_ClusterMember(struct soap *soap, struct KMS_Discovery_ClusterMember *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_PointerToKMS_Discovery_ClusterMember);
+ if (soap_out_PointerToKMS_Discovery_ClusterMember(soap, tag?tag:"KMS-Discovery-ClusterMember", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember ** SOAP_FMAC4 soap_get_PointerToKMS_Discovery_ClusterMember(struct soap *soap, struct KMS_Discovery_ClusterMember **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToKMS_Discovery_ClusterMember(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap *soap, unsigned char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_Discovery_unsignedByte);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap *soap, const char *tag, int id, unsigned char *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_KMS_Discovery_unsignedByte);
+ if (id < 0)
+ return soap->error;
+ return soap_out_unsignedByte(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap *soap, const char *tag, unsigned char **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (unsigned char **)soap_malloc(soap, sizeof(unsigned char *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_unsignedByte(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (unsigned char **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_KMS_Discovery_unsignedByte, sizeof(unsigned char), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap *soap, unsigned char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_PointerTounsignedByte);
+ if (soap_out_PointerTounsignedByte(soap, tag?tag:"unsignedByte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap *soap, unsigned char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerTounsignedByte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__networkAddress(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__networkAddress);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__networkAddress(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__networkAddress, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__networkAddress(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__networkAddress);
+ if (soap_out_xsd__networkAddress(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__networkAddress(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__networkAddress(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__kmaVersion(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__kmaVersion);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__kmaVersion(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__kmaVersion, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__kmaVersion(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__kmaVersion);
+ if (soap_out_xsd__kmaVersion(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__kmaVersion(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__kmaVersion(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__duration);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__duration, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__duration);
+ if (soap_out_xsd__duration(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__duration(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__dateTime);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__dateTime, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__dateTime);
+ if (soap_out_xsd__dateTime(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__dateTime(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_xsd__string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_xsd__string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_xsd__string);
+ if (soap_out_xsd__string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_xsd__string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery__QName);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery__QName, 2, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery__QName);
+ if (soap_out__QName(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in__QName(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap *soap, char **a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_string
+ *a = SOAP_DEFAULT_string;
+#else
+ *a = (char *)0;
+#endif
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_KMS_Discovery_string);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_KMS_Discovery_string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_KMS_Discovery_string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_KMS_Discovery_string);
+ if (soap_out_string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+} // namespace KMS_Discovery
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_DiscoveryC.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryClient.cpp b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryClient.cpp
new file mode 100644
index 0000000000..5e3341003a
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryClient.cpp
@@ -0,0 +1,100 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_DiscoveryClient.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/DiscoveryService/KMS_Discovery_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+#include "KMS_DiscoveryH.h"
+
+namespace KMS_Discovery {
+
+SOAP_SOURCE_STAMP("@(#) KMS_DiscoveryClient.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Discovery__DiscoverCluster(struct soap *soap, const char *soap_endpoint, const char *soap_action, void *_, struct KMS_Discovery__DiscoverClusterResponse &result)
+{ struct KMS_Discovery__DiscoverCluster soap_tmp_KMS_Discovery__DiscoverCluster;
+ soap_tmp_KMS_Discovery__DiscoverCluster._ = _;
+ soap_begin(soap);
+ soap_serializeheader(soap);
+ soap_serialize_KMS_Discovery__DiscoverCluster(soap, &soap_tmp_KMS_Discovery__DiscoverCluster);
+ if (soap_begin_count(soap))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Discovery__DiscoverCluster(soap, &soap_tmp_KMS_Discovery__DiscoverCluster, "KMS-Discovery:DiscoverCluster", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap->error;
+ }
+ if (soap_end_count(soap))
+ return soap->error;
+ if (soap_connect(soap, soap_endpoint, soap_action)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_put_KMS_Discovery__DiscoverCluster(soap, &soap_tmp_KMS_Discovery__DiscoverCluster, "KMS-Discovery:DiscoverCluster", NULL)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap)
+ || soap_end_send(soap))
+ return soap_closesock(soap);
+ if (!&result)
+ return soap_closesock(soap);
+ soap_default_KMS_Discovery__DiscoverClusterResponse(soap, &result);
+ if (soap_begin_recv(soap)
+ || soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap))
+ return soap_closesock(soap);
+ if (soap_recv_fault(soap, 1))
+ return soap->error;
+ soap_get_KMS_Discovery__DiscoverClusterResponse(soap, &result, "", "");
+ if (soap->error)
+ return soap_recv_fault(soap, 0);
+ if (soap_body_end_in(soap)
+ || soap_envelope_end_in(soap)
+ || soap_end_recv(soap))
+ return soap_closesock(soap);
+ return soap_closesock(soap);
+}
+
+} // namespace KMS_Discovery
+
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of KMS_DiscoveryClient.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryH.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryH.h
new file mode 100644
index 0000000000..0cffb3ac19
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryH.h
@@ -0,0 +1,757 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_DiscoveryH.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/DiscoveryService/KMS_Discovery_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_DiscoveryH_H
+#define KMS_DiscoveryH_H
+#include "KMS_DiscoveryStub.h"
+
+namespace KMS_Discovery {
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
+SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_byte
+#define SOAP_TYPE_KMS_Discovery_byte (3)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*);
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*);
+
+#define soap_write_byte(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_byte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*);
+
+#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_int
+#define SOAP_TYPE_KMS_Discovery_int (1)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*);
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*);
+
+#define soap_write_int(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*);
+
+#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__int
+#define SOAP_TYPE_KMS_Discovery_xsd__int (11)
+#endif
+
+#define soap_default_xsd__int(soap, a) soap_default_long(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__int(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_xsd__int(struct soap*, const char*, long *, const char*);
+
+#define soap_write_xsd__int(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_xsd__int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__int(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_xsd__int(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_xsd__int(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_long
+#define SOAP_TYPE_KMS_Discovery_long (10)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_long(struct soap*, long *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_long(struct soap*, const char*, int, const long *, const char*);
+SOAP_FMAC3 long * SOAP_FMAC4 soap_in_long(struct soap*, const char*, long *, const char*);
+
+#define soap_write_long(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_long(struct soap*, const long *, const char*, const char*);
+
+#define soap_read_long(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 long * SOAP_FMAC4 soap_get_long(struct soap*, long *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__long
+#define SOAP_TYPE_KMS_Discovery_xsd__long (15)
+#endif
+
+#define soap_default_xsd__long(soap, a) soap_default_LONG64(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__long(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_xsd__long(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_xsd__long(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_xsd__long(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__long(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_xsd__long(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__long(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_xsd__long(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_LONG64
+#define SOAP_TYPE_KMS_Discovery_LONG64 (14)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_LONG64(struct soap*, LONG64 *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_LONG64(struct soap*, const char*, int, const LONG64 *, const char*);
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_in_LONG64(struct soap*, const char*, LONG64 *, const char*);
+
+#define soap_write_LONG64(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_LONG64(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_LONG64(struct soap*, const LONG64 *, const char*, const char*);
+
+#define soap_read_LONG64(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_LONG64(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 LONG64 * SOAP_FMAC4 soap_get_LONG64(struct soap*, LONG64 *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__float
+#define SOAP_TYPE_KMS_Discovery_xsd__float (9)
+#endif
+
+#define soap_default_xsd__float(soap, a) soap_default_float(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_xsd__float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_xsd__float(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_xsd__float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_xsd__float(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_xsd__float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_float
+#define SOAP_TYPE_KMS_Discovery_float (8)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_float(struct soap*, float *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_float(struct soap*, const char*, int, const float *, const char*);
+SOAP_FMAC3 float * SOAP_FMAC4 soap_in_float(struct soap*, const char*, float *, const char*);
+
+#define soap_write_float(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_float(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_float(struct soap*, const float *, const char*, const char*);
+
+#define soap_read_float(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_float(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 float * SOAP_FMAC4 soap_get_float(struct soap*, float *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_unsignedByte
+#define SOAP_TYPE_KMS_Discovery_unsignedByte (22)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedByte(struct soap*, unsigned char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedByte(struct soap*, const char*, int, const unsigned char *, const char*);
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_in_unsignedByte(struct soap*, const char*, unsigned char *, const char*);
+
+#define soap_write_unsignedByte(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_unsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedByte(struct soap*, const unsigned char *, const char*, const char*);
+
+#define soap_read_unsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_unsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char * SOAP_FMAC4 soap_get_unsignedByte(struct soap*, unsigned char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_unsignedInt
+#define SOAP_TYPE_KMS_Discovery_unsignedInt (21)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_unsignedInt(struct soap*, unsigned int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_unsignedInt(struct soap*, const char*, int, const unsigned int *, const char*);
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_in_unsignedInt(struct soap*, const char*, unsigned int *, const char*);
+
+#define soap_write_unsignedInt(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_unsignedInt(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_unsignedInt(struct soap*, const unsigned int *, const char*, const char*);
+
+#define soap_read_unsignedInt(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_unsignedInt(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned int * SOAP_FMAC4 soap_get_unsignedInt(struct soap*, unsigned int *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__boolean
+#define SOAP_TYPE_KMS_Discovery_xsd__boolean (13)
+#endif
+
+#define soap_default_xsd__boolean(soap, a) soap_default_bool(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__boolean(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_xsd__boolean2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_xsd__boolean(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2xsd__boolean(struct soap*, const char*, bool *);
+
+#define soap_write_xsd__boolean(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_xsd__boolean(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__boolean(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_xsd__boolean(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__boolean(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_xsd__boolean(struct soap*, bool *, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_bool
+#define SOAP_TYPE_KMS_Discovery_bool (12)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_bool(struct soap*, bool *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_bool(struct soap*, const char*, int, const bool *, const char*);
+
+SOAP_FMAC3S const char* SOAP_FMAC4S soap_bool2s(struct soap*, bool);
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_in_bool(struct soap*, const char*, bool *, const char*);
+
+SOAP_FMAC3S int SOAP_FMAC4S soap_s2bool(struct soap*, const char*, bool *);
+
+#define soap_write_bool(soap, data) ( soap_begin_send(soap) || KMS_Discovery::soap_put_bool(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_bool(struct soap*, const bool *, const char*, const char*);
+
+#define soap_read_bool(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_bool(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 bool * SOAP_FMAC4 soap_get_bool(struct soap*, bool *, const char*, const char*);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault (38)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*);
+
+#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_SOAP_ENV__Fault(soap, data), 0) || KMS_Discovery::soap_put_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Fault(soap, n) soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Fault(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason (37)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*);
+
+#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_SOAP_ENV__Reason(soap, data), 0) || KMS_Discovery::soap_put_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Reason(soap, n) soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Reason(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail (36)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*);
+
+#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_SOAP_ENV__Detail(soap, data), 0) || KMS_Discovery::soap_put_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Detail(soap, n) soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Detail(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code (34)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*);
+
+#define soap_write_SOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_SOAP_ENV__Code(soap, data), 0) || KMS_Discovery::soap_put_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Code(soap, n) soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Code(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header (33)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*);
+
+#define soap_write_SOAP_ENV__Header(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_SOAP_ENV__Header(soap, data), 0) || KMS_Discovery::soap_put_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Header(soap, n) soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Header(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster (32)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery__DiscoverCluster(struct soap*, struct KMS_Discovery__DiscoverCluster *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery__DiscoverCluster(struct soap*, const struct KMS_Discovery__DiscoverCluster *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery__DiscoverCluster(struct soap*, const char*, int, const struct KMS_Discovery__DiscoverCluster *, const char*);
+SOAP_FMAC3 struct KMS_Discovery__DiscoverCluster * SOAP_FMAC4 soap_in_KMS_Discovery__DiscoverCluster(struct soap*, const char*, struct KMS_Discovery__DiscoverCluster *, const char*);
+
+#define soap_write_KMS_Discovery__DiscoverCluster(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_KMS_Discovery__DiscoverCluster(soap, data), 0) || KMS_Discovery::soap_put_KMS_Discovery__DiscoverCluster(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery__DiscoverCluster(struct soap*, const struct KMS_Discovery__DiscoverCluster *, const char*, const char*);
+
+#define soap_read_KMS_Discovery__DiscoverCluster(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_KMS_Discovery__DiscoverCluster(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Discovery__DiscoverCluster * SOAP_FMAC4 soap_get_KMS_Discovery__DiscoverCluster(struct soap*, struct KMS_Discovery__DiscoverCluster *, const char*, const char*);
+
+#define soap_new_KMS_Discovery__DiscoverCluster(soap, n) soap_instantiate_KMS_Discovery__DiscoverCluster(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Discovery__DiscoverCluster(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Discovery__DiscoverCluster * SOAP_FMAC2 soap_instantiate_KMS_Discovery__DiscoverCluster(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery__DiscoverCluster(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse (29)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery__DiscoverClusterResponse(struct soap*, struct KMS_Discovery__DiscoverClusterResponse *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery__DiscoverClusterResponse(struct soap*, const struct KMS_Discovery__DiscoverClusterResponse *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery__DiscoverClusterResponse(struct soap*, const char*, int, const struct KMS_Discovery__DiscoverClusterResponse *, const char*);
+SOAP_FMAC3 struct KMS_Discovery__DiscoverClusterResponse * SOAP_FMAC4 soap_in_KMS_Discovery__DiscoverClusterResponse(struct soap*, const char*, struct KMS_Discovery__DiscoverClusterResponse *, const char*);
+
+#define soap_write_KMS_Discovery__DiscoverClusterResponse(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_KMS_Discovery__DiscoverClusterResponse(soap, data), 0) || KMS_Discovery::soap_put_KMS_Discovery__DiscoverClusterResponse(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery__DiscoverClusterResponse(struct soap*, const struct KMS_Discovery__DiscoverClusterResponse *, const char*, const char*);
+
+#define soap_read_KMS_Discovery__DiscoverClusterResponse(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_KMS_Discovery__DiscoverClusterResponse(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Discovery__DiscoverClusterResponse * SOAP_FMAC4 soap_get_KMS_Discovery__DiscoverClusterResponse(struct soap*, struct KMS_Discovery__DiscoverClusterResponse *, const char*, const char*);
+
+#define soap_new_KMS_Discovery__DiscoverClusterResponse(soap, n) soap_instantiate_KMS_Discovery__DiscoverClusterResponse(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Discovery__DiscoverClusterResponse(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Discovery__DiscoverClusterResponse * SOAP_FMAC2 soap_instantiate_KMS_Discovery__DiscoverClusterResponse(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery__DiscoverClusterResponse(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers (25)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery__ArrayOfClusterMembers(struct soap*, struct KMS_Discovery__ArrayOfClusterMembers *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery__ArrayOfClusterMembers(struct soap*, struct KMS_Discovery__ArrayOfClusterMembers const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery__ArrayOfClusterMembers(struct soap*, const char*, int, const struct KMS_Discovery__ArrayOfClusterMembers *, const char*);
+SOAP_FMAC3 struct KMS_Discovery__ArrayOfClusterMembers * SOAP_FMAC4 soap_in_KMS_Discovery__ArrayOfClusterMembers(struct soap*, const char*, struct KMS_Discovery__ArrayOfClusterMembers *, const char*);
+
+#define soap_write_KMS_Discovery__ArrayOfClusterMembers(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_KMS_Discovery__ArrayOfClusterMembers(soap, data), 0) || KMS_Discovery::soap_put_KMS_Discovery__ArrayOfClusterMembers(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery__ArrayOfClusterMembers(struct soap*, const struct KMS_Discovery__ArrayOfClusterMembers *, const char*, const char*);
+
+#define soap_read_KMS_Discovery__ArrayOfClusterMembers(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_KMS_Discovery__ArrayOfClusterMembers(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Discovery__ArrayOfClusterMembers * SOAP_FMAC4 soap_get_KMS_Discovery__ArrayOfClusterMembers(struct soap*, struct KMS_Discovery__ArrayOfClusterMembers *, const char*, const char*);
+
+#define soap_new_KMS_Discovery__ArrayOfClusterMembers(soap, n) soap_instantiate_KMS_Discovery__ArrayOfClusterMembers(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Discovery__ArrayOfClusterMembers(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Discovery__ArrayOfClusterMembers * SOAP_FMAC2 soap_instantiate_KMS_Discovery__ArrayOfClusterMembers(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery__ArrayOfClusterMembers(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember (24)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_KMS_Discovery_ClusterMember(struct soap*, struct KMS_Discovery_ClusterMember *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_KMS_Discovery_ClusterMember(struct soap*, const struct KMS_Discovery_ClusterMember *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_KMS_Discovery_ClusterMember(struct soap*, const char*, int, const struct KMS_Discovery_ClusterMember *, const char*);
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember * SOAP_FMAC4 soap_in_KMS_Discovery_ClusterMember(struct soap*, const char*, struct KMS_Discovery_ClusterMember *, const char*);
+
+#define soap_write_KMS_Discovery_ClusterMember(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_KMS_Discovery_ClusterMember(soap, data), 0) || KMS_Discovery::soap_put_KMS_Discovery_ClusterMember(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_KMS_Discovery_ClusterMember(struct soap*, const struct KMS_Discovery_ClusterMember *, const char*, const char*);
+
+#define soap_read_KMS_Discovery_ClusterMember(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_KMS_Discovery_ClusterMember(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember * SOAP_FMAC4 soap_get_KMS_Discovery_ClusterMember(struct soap*, struct KMS_Discovery_ClusterMember *, const char*, const char*);
+
+#define soap_new_KMS_Discovery_ClusterMember(soap, n) soap_instantiate_KMS_Discovery_ClusterMember(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_KMS_Discovery_ClusterMember(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct KMS_Discovery_ClusterMember * SOAP_FMAC2 soap_instantiate_KMS_Discovery_ClusterMember(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_KMS_Discovery_ClusterMember(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__hexBinary
+#define SOAP_TYPE_KMS_Discovery_xsd__hexBinary (20)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_xsd__hexBinary(struct soap*, struct xsd__hexBinary *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_xsd__hexBinary(struct soap*, struct xsd__hexBinary const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__hexBinary(struct soap*, const char*, int, const struct xsd__hexBinary *, const char*);
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_in_xsd__hexBinary(struct soap*, const char*, struct xsd__hexBinary *, const char*);
+
+#define soap_write_xsd__hexBinary(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_xsd__hexBinary(soap, data), 0) || KMS_Discovery::soap_put_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__hexBinary(struct soap*, const struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_read_xsd__hexBinary(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__hexBinary(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct xsd__hexBinary * SOAP_FMAC4 soap_get_xsd__hexBinary(struct soap*, struct xsd__hexBinary *, const char*, const char*);
+
+#define soap_new_xsd__hexBinary(soap, n) soap_instantiate_xsd__hexBinary(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_xsd__hexBinary(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct xsd__hexBinary * SOAP_FMAC2 soap_instantiate_xsd__hexBinary(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_xsd__hexBinary(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Reason (40)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_PointerToSOAP_ENV__Reason(soap, data), 0) || KMS_Discovery::soap_put_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Detail (39)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_PointerToSOAP_ENV__Detail(soap, data), 0) || KMS_Discovery::soap_put_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Code
+#define SOAP_TYPE_KMS_Discovery_PointerToSOAP_ENV__Code (35)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_PointerToSOAP_ENV__Code(soap, data), 0) || KMS_Discovery::soap_put_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*);
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_PointerToKMS_Discovery_ClusterMember
+#define SOAP_TYPE_KMS_Discovery_PointerToKMS_Discovery_ClusterMember (26)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToKMS_Discovery_ClusterMember(struct soap*, struct KMS_Discovery_ClusterMember *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToKMS_Discovery_ClusterMember(struct soap*, const char *, int, struct KMS_Discovery_ClusterMember *const*, const char *);
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember ** SOAP_FMAC4 soap_in_PointerToKMS_Discovery_ClusterMember(struct soap*, const char*, struct KMS_Discovery_ClusterMember **, const char*);
+
+#define soap_write_PointerToKMS_Discovery_ClusterMember(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_PointerToKMS_Discovery_ClusterMember(soap, data), 0) || KMS_Discovery::soap_put_PointerToKMS_Discovery_ClusterMember(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToKMS_Discovery_ClusterMember(struct soap*, struct KMS_Discovery_ClusterMember *const*, const char*, const char*);
+
+#define soap_read_PointerToKMS_Discovery_ClusterMember(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_PointerToKMS_Discovery_ClusterMember(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct KMS_Discovery_ClusterMember ** SOAP_FMAC4 soap_get_PointerToKMS_Discovery_ClusterMember(struct soap*, struct KMS_Discovery_ClusterMember **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_PointerTounsignedByte
+#define SOAP_TYPE_KMS_Discovery_PointerTounsignedByte (23)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTounsignedByte(struct soap*, unsigned char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTounsignedByte(struct soap*, const char *, int, unsigned char *const*, const char *);
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_in_PointerTounsignedByte(struct soap*, const char*, unsigned char **, const char*);
+
+#define soap_write_PointerTounsignedByte(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_PointerTounsignedByte(soap, data), 0) || KMS_Discovery::soap_put_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTounsignedByte(struct soap*, unsigned char *const*, const char*, const char*);
+
+#define soap_read_PointerTounsignedByte(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_PointerTounsignedByte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 unsigned char ** SOAP_FMAC4 soap_get_PointerTounsignedByte(struct soap*, unsigned char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__networkAddress
+#define SOAP_TYPE_KMS_Discovery_xsd__networkAddress (19)
+#endif
+
+#define soap_default_xsd__networkAddress(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__networkAddress(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__networkAddress(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__networkAddress(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__networkAddress(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_xsd__networkAddress(soap, data), 0) || KMS_Discovery::soap_put_xsd__networkAddress(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__networkAddress(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__networkAddress(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__networkAddress(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__networkAddress(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__kmaVersion
+#define SOAP_TYPE_KMS_Discovery_xsd__kmaVersion (18)
+#endif
+
+#define soap_default_xsd__kmaVersion(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__kmaVersion(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__kmaVersion(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__kmaVersion(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__kmaVersion(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_xsd__kmaVersion(soap, data), 0) || KMS_Discovery::soap_put_xsd__kmaVersion(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__kmaVersion(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__kmaVersion(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__kmaVersion(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__kmaVersion(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__duration
+#define SOAP_TYPE_KMS_Discovery_xsd__duration (17)
+#endif
+
+#define soap_default_xsd__duration(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__duration(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__duration(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__duration(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__duration(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_xsd__duration(soap, data), 0) || KMS_Discovery::soap_put_xsd__duration(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__duration(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__duration(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__duration(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__duration(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__dateTime
+#define SOAP_TYPE_KMS_Discovery_xsd__dateTime (16)
+#endif
+
+#define soap_default_xsd__dateTime(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__dateTime(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__dateTime(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__dateTime(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__dateTime(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_xsd__dateTime(soap, data), 0) || KMS_Discovery::soap_put_xsd__dateTime(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__dateTime(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__dateTime(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__dateTime(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__dateTime(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__string
+#define SOAP_TYPE_KMS_Discovery_xsd__string (7)
+#endif
+
+#define soap_default_xsd__string(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize_xsd__string(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_xsd__string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_xsd__string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_xsd__string(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_xsd__string(soap, data), 0) || KMS_Discovery::soap_put_xsd__string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_xsd__string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_xsd__string(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_xsd__string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_xsd__string(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery__QName
+#define SOAP_TYPE_KMS_Discovery__QName (5)
+#endif
+
+#define soap_default__QName(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize__QName(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*);
+
+#define soap_write__QName(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize__QName(soap, data), 0) || KMS_Discovery::soap_put__QName(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_KMS_Discovery_string
+#define SOAP_TYPE_KMS_Discovery_string (4)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_string(soap, data) ( soap_begin_send(soap) || (KMS_Discovery::soap_serialize_string(soap, data), 0) || KMS_Discovery::soap_put_string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !KMS_Discovery::soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*);
+
+} // namespace KMS_Discovery
+
+
+#endif
+
+/* End of KMS_DiscoveryH.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryStub.h b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryStub.h
new file mode 100644
index 0000000000..d91409eb3d
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/KMS_DiscoveryStub.h
@@ -0,0 +1,301 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* KMS_DiscoveryStub.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/DiscoveryService/KMS_Discovery_SOAP.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef KMS_DiscoveryStub_H
+#define KMS_DiscoveryStub_H
+#ifndef WITH_NONAMESPACES
+#define WITH_NONAMESPACES
+#endif
+#ifndef WITH_NOGLOBAL
+#define WITH_NOGLOBAL
+#endif
+#include "stdsoap2.h"
+
+namespace KMS_Discovery {
+
+/******************************************************************************\
+ * *
+ * Enumerations *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Types with Custom Serializers *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Classes and Structs *
+ * *
+\******************************************************************************/
+
+
+#if 0 /* volatile type: do not declare here, declared elsewhere */
+
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__hexBinary
+#define SOAP_TYPE_KMS_Discovery_xsd__hexBinary (20)
+/* hexBinary schema type: */
+struct xsd__hexBinary
+{
+public:
+ unsigned char *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery_ClusterMember (24)
+/* KMS-Discovery-ClusterMember */
+struct KMS_Discovery_ClusterMember
+{
+public:
+ LONG64 KMAID; /* required element of type xsd:long */
+ char *KMAName; /* optional element of type xsd:string */
+ char *KMASiteID; /* optional element of type xsd:string */
+ char *KMAHostName; /* optional element of type xsd:string */
+ char *KMANetworkAddress; /* optional element of type xsd:string */
+ bool Enabled; /* required element of type xsd:boolean */
+ long Load; /* required element of type xsd:int */
+ bool Responding; /* required element of type xsd:boolean */
+ char *KMAVersion; /* optional attribute of type xsd:kmaVersion */
+ char *KMAHostNameIPv6; /* optional attribute of type xsd:networkAddress */
+ char *KMANetworkAddressIPv6; /* optional attribute of type xsd:networkAddress */
+ bool KMS_Discovery__Locked; /* optional attribute of type xsd:boolean */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery__ArrayOfClusterMembers (25)
+/* Sequence of KMS-Discovery:ArrayOfClusterMembers schema type: */
+struct KMS_Discovery__ArrayOfClusterMembers
+{
+public:
+ struct KMS_Discovery_ClusterMember *__ptr;
+ int __size;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverClusterResponse (29)
+/* KMS-Discovery:DiscoverClusterResponse */
+struct KMS_Discovery__DiscoverClusterResponse
+{
+public:
+ char *EntitySiteID; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:string */
+ struct KMS_Discovery__ArrayOfClusterMembers ArrayOfClusterMembers; /* optional element of type KMS-Discovery:ArrayOfClusterMembers */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster
+#define SOAP_TYPE_KMS_Discovery_KMS_Discovery__DiscoverCluster (32)
+/* KMS-Discovery:DiscoverCluster */
+struct KMS_Discovery__DiscoverCluster
+{
+public:
+ void *_; /* transient */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Header (33)
+/* SOAP Header: */
+struct SOAP_ENV__Header
+{
+#ifdef WITH_NOEMPTYSTRUCT
+private:
+ char dummy; /* dummy member to enable compilation */
+#endif
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Code (34)
+/* SOAP Fault Code: */
+struct SOAP_ENV__Code
+{
+public:
+ char *SOAP_ENV__Value; /* optional element of type xsd:QName */
+ struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Detail (36)
+/* SOAP-ENV:Detail */
+struct SOAP_ENV__Detail
+{
+public:
+ int __type; /* any type of element <fault> (defined below) */
+ void *fault; /* transient */
+ char *__any;
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Reason (37)
+/* SOAP-ENV:Reason */
+struct SOAP_ENV__Reason
+{
+public:
+ char *SOAP_ENV__Text; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault
+#define SOAP_TYPE_KMS_Discovery_SOAP_ENV__Fault (38)
+/* SOAP Fault: */
+struct SOAP_ENV__Fault
+{
+public:
+ char *faultcode; /* optional element of type xsd:QName */
+ char *faultstring; /* optional element of type xsd:string */
+ char *faultactor; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */
+ struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */
+ struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */
+ char *SOAP_ENV__Node; /* optional element of type xsd:string */
+ char *SOAP_ENV__Role; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */
+};
+#endif
+
+/******************************************************************************\
+ * *
+ * Typedefs *
+ * *
+\******************************************************************************/
+
+#ifndef SOAP_TYPE_KMS_Discovery__QName
+#define SOAP_TYPE_KMS_Discovery__QName (5)
+typedef char *_QName;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery__XML
+#define SOAP_TYPE_KMS_Discovery__XML (6)
+typedef char *_XML;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__string
+#define SOAP_TYPE_KMS_Discovery_xsd__string (7)
+typedef char *xsd__string;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__float
+#define SOAP_TYPE_KMS_Discovery_xsd__float (9)
+typedef float xsd__float;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__int
+#define SOAP_TYPE_KMS_Discovery_xsd__int (11)
+typedef long xsd__int;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__boolean
+#define SOAP_TYPE_KMS_Discovery_xsd__boolean (13)
+typedef bool xsd__boolean;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__long
+#define SOAP_TYPE_KMS_Discovery_xsd__long (15)
+typedef LONG64 xsd__long;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__dateTime
+#define SOAP_TYPE_KMS_Discovery_xsd__dateTime (16)
+typedef char *xsd__dateTime;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__duration
+#define SOAP_TYPE_KMS_Discovery_xsd__duration (17)
+typedef char *xsd__duration;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__kmaVersion
+#define SOAP_TYPE_KMS_Discovery_xsd__kmaVersion (18)
+typedef char *xsd__kmaVersion;
+#endif
+
+#ifndef SOAP_TYPE_KMS_Discovery_xsd__networkAddress
+#define SOAP_TYPE_KMS_Discovery_xsd__networkAddress (19)
+typedef char *xsd__networkAddress;
+#endif
+
+
+/******************************************************************************\
+ * *
+ * Externals *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Server-Side Operations *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Discovery__DiscoverCluster(struct soap*, void *_, struct KMS_Discovery__DiscoverClusterResponse &result);
+
+/******************************************************************************\
+ * *
+ * Server-Side Skeletons to Invoke Service Operations *
+ * *
+\******************************************************************************/
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Discovery_serve(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 KMS_Discovery_serve_request(struct soap*);
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_serve_KMS_Discovery__DiscoverCluster(struct soap*);
+
+/******************************************************************************\
+ * *
+ * Client-Side Call Stubs *
+ * *
+\******************************************************************************/
+
+
+SOAP_FMAC5 int SOAP_FMAC6 soap_call_KMS_Discovery__DiscoverCluster(struct soap *soap, const char *soap_endpoint, const char *soap_action, void *_, struct KMS_Discovery__DiscoverClusterResponse &result);
+
+} // namespace KMS_Discovery
+
+
+#endif
+
+/* End of KMS_DiscoveryStub.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/envC.cpp b/usr/src/lib/libkmsagent/common/SOAP/envC.cpp
new file mode 100644
index 0000000000..a8f1887388
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/envC.cpp
@@ -0,0 +1,1359 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* envC.cpp
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/Env/env.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#if defined(__BORLANDC__)
+#pragma option push -w-8060
+#pragma option push -w-8004
+#endif
+
+#include "envH.h"
+
+SOAP_SOURCE_STAMP("@(#) envC.cpp ver 2.7.17 2010-06-08 19:16:38 GMT")
+
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap)
+{
+ if (soap->header)
+ soap_serialize_SOAP_ENV__Header(soap, soap->header);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap)
+{
+ if (soap->header)
+ { soap->part = SOAP_IN_HEADER;
+ if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, NULL))
+ return soap->error;
+ soap->part = SOAP_END_HEADER;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap *soap)
+{
+ soap->part = SOAP_IN_HEADER;
+ soap->header = soap_in_SOAP_ENV__Header(soap, "SOAP-ENV:Header", NULL, NULL);
+ soap->part = SOAP_END_HEADER;
+ return soap->header == NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap)
+{
+ if (!soap->header)
+ { if ((soap->header = soap_new_SOAP_ENV__Header(soap, -1)))
+ soap_default_SOAP_ENV__Header(soap, soap->header);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap)
+{
+ if (!soap->fault)
+ { soap->fault = soap_new_SOAP_ENV__Fault(soap, -1);
+ if (!soap->fault)
+ return;
+ soap_default_SOAP_ENV__Fault(soap, soap->fault);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Code)
+ { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code);
+ }
+ if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason)
+ { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap, -1);
+ soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason);
+ }
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->fault)
+ soap_serialize_SOAP_ENV__Fault(soap, soap->fault);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap)
+{
+ if (soap->fault)
+ return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", NULL);
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap *soap)
+{
+ return (soap->fault = soap_get_SOAP_ENV__Fault(soap, NULL, "SOAP-ENV:Fault", NULL)) == NULL;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value;
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ { if (!soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
+ { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap, -1);
+ soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value;
+ }
+ return (const char**)&soap->fault->faultcode;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 2)
+ return (const char**)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text;
+ return (const char**)&soap->fault->faultstring;
+}
+
+SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap)
+{
+ soap_fault(soap);
+ if (soap->version == 1)
+ { if (!soap->fault->detail)
+ { soap->fault->detail = (struct SOAP_ENV__Detail*)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail));
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->detail);
+ }
+ return (const char**)&soap->fault->detail->__any;
+ }
+ if (!soap->fault->SOAP_ENV__Detail)
+ { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1);
+ soap_default_SOAP_ENV__Detail(soap, soap->fault->SOAP_ENV__Detail);
+ }
+ return (const char**)&soap->fault->SOAP_ENV__Detail->__any;
+}
+
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap)
+{
+ int t;
+ if (soap->version == 1)
+ { for (;;)
+ { if (!soap_getelement(soap, &t))
+ if (soap->error || soap_ignore_element(soap))
+ break;
+ }
+ }
+ if (soap->error == SOAP_NO_TAG || soap->error == SOAP_EOF)
+ soap->error = SOAP_OK;
+ return soap->error;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type)
+{
+ if (soap_peek_element(soap))
+ return NULL;
+ if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id)))
+ *type = soap_lookup_type(soap, soap->href);
+ switch (*type)
+ {
+ case SOAP_TYPE_byte:
+ return soap_in_byte(soap, NULL, NULL, "xsd:byte");
+ case SOAP_TYPE_int:
+ return soap_in_int(soap, NULL, NULL, "xsd:int");
+ case SOAP_TYPE__QName:
+ { char **s;
+ s = soap_in__QName(soap, NULL, NULL, "xsd:QName");
+ return s ? *s : NULL;
+ }
+ case SOAP_TYPE_string:
+ { char **s;
+ s = soap_in_string(soap, NULL, NULL, "xsd:string");
+ return s ? *s : NULL;
+ }
+ default:
+ { const char *t = soap->type;
+ if (!*t)
+ t = soap->tag;
+ if (!soap_match_tag(soap, t, "xsd:byte"))
+ { *type = SOAP_TYPE_byte;
+ return soap_in_byte(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:int"))
+ { *type = SOAP_TYPE_int;
+ return soap_in_int(soap, NULL, NULL, NULL);
+ }
+ if (!soap_match_tag(soap, t, "xsd:QName"))
+ { char **s;
+ *type = SOAP_TYPE__QName;
+ s = soap_in__QName(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ if (!soap_match_tag(soap, t, "xsd:string"))
+ { char **s;
+ *type = SOAP_TYPE_string;
+ s = soap_in_string(soap, NULL, NULL, NULL);
+ return s ? *s : NULL;
+ }
+ t = soap->tag;
+ }
+ }
+ soap->error = SOAP_TAG_MISMATCH;
+ return NULL;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap)
+{
+ if (!soap_peek_element(soap))
+ { int t;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body));
+ if (soap->mustUnderstand && !soap->other)
+ return soap->error = SOAP_MUSTUNDERSTAND;
+ if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag));
+ return soap->error = SOAP_TAG_MISMATCH;
+ }
+ if (!*soap->id || !soap_getelement(soap, &t))
+ { soap->peeked = 0;
+ if (soap->fignore)
+ soap->error = soap->fignore(soap, soap->tag);
+ else
+ soap->error = SOAP_OK;
+ DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag));
+ if (!soap->error && soap->body)
+ { soap->level++;
+ while (!soap_ignore_element(soap))
+ ;
+ if (soap->error == SOAP_NO_TAG)
+ soap->error = soap_element_end_in(soap, NULL);
+ }
+ }
+ }
+ return soap->error;
+}
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap)
+{
+ int i;
+ struct soap_plist *pp;
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & (SOAP_XML_TREE | SOAP_XML_GRAPH)))
+ for (i = 0; i < SOAP_PTRHASH; i++)
+ for (pp = soap->pht[i]; pp; pp = pp->next)
+ if (pp->mark1 == 2 || pp->mark2 == 2)
+ if (soap_putelement(soap, pp->ptr, "id", pp->id, pp->type))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+#ifndef WITH_NOIDREF
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, const char *tag, int id, int type)
+{
+ switch (type)
+ {
+ case SOAP_TYPE_byte:
+ return soap_out_byte(soap, tag, id, (const char *)ptr, "xsd:byte");
+ case SOAP_TYPE_int:
+ return soap_out_int(soap, tag, id, (const int *)ptr, "xsd:int");
+ case SOAP_TYPE__QName:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:QName");
+ case SOAP_TYPE_string:
+ return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string");
+ }
+ return SOAP_OK;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#ifndef WITH_NOIDREF
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, int type)
+{
+ (void)soap; (void)ptr; (void)type; /* appease -Wall -Werror */
+ switch (type)
+ {
+ case SOAP_TYPE__QName:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ case SOAP_TYPE_string:
+ soap_serialize_string(soap, (char*const*)&ptr);
+ break;
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap *soap, int t, const char *type, const char *arrayType, size_t *n)
+{
+ switch (t)
+ {
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_SOAP_ENV__Header:
+ return (void*)soap_instantiate_SOAP_ENV__Header(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_SOAP_ENV__Code:
+ return (void*)soap_instantiate_SOAP_ENV__Code(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_SOAP_ENV__Detail:
+ return (void*)soap_instantiate_SOAP_ENV__Detail(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_SOAP_ENV__Reason:
+ return (void*)soap_instantiate_SOAP_ENV__Reason(soap, -1, type, arrayType, n);
+#endif
+#ifndef WITH_NOGLOBAL
+ case SOAP_TYPE_SOAP_ENV__Fault:
+ return (void*)soap_instantiate_SOAP_ENV__Fault(soap, -1, type, arrayType, n);
+#endif
+ }
+ return NULL;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p)
+{ switch (p->type)
+ {
+ case SOAP_TYPE_SOAP_ENV__Header:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr);
+ break;
+ case SOAP_TYPE_SOAP_ENV__Code:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr);
+ break;
+ case SOAP_TYPE_SOAP_ENV__Detail:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr);
+ break;
+ case SOAP_TYPE_SOAP_ENV__Reason:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr);
+ break;
+ case SOAP_TYPE_SOAP_ENV__Fault:
+ if (p->size < 0)
+ SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr);
+ else
+ SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr);
+ break;
+ default: return SOAP_ERR;
+ }
+ return SOAP_OK;
+}
+
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType)
+{ return soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_byte
+ *a = SOAP_DEFAULT_byte;
+#else
+ *a = (char)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type)
+{
+ return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_byte);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap *soap, const char *tag, char *a, const char *type)
+{ char *p;
+ p = soap_inbyte(soap, tag, a, type, SOAP_TYPE_byte);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap *soap, const char *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_byte);
+ if (soap_out_byte(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap *soap, char *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_byte(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_int
+ *a = SOAP_DEFAULT_int;
+#else
+ *a = (int)0;
+#endif
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type)
+{
+ return soap_outint(soap, tag, id, a, type, SOAP_TYPE_int);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap *soap, const char *tag, int *a, const char *type)
+{ int *p;
+ p = soap_inint(soap, tag, a, type, SOAP_TYPE_int);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap *soap, const int *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_int);
+ if (soap_out_int(soap, tag?tag:"int", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap *soap, int *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_int(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->faultcode);
+ soap_default_string(soap, &a->faultstring);
+ soap_default_string(soap, &a->faultactor);
+ a->detail = NULL;
+ a->SOAP_ENV__Code = NULL;
+ a->SOAP_ENV__Reason = NULL;
+ soap_default_string(soap, &a->SOAP_ENV__Node);
+ soap_default_string(soap, &a->SOAP_ENV__Role);
+ a->SOAP_ENV__Detail = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->faultcode);
+ soap_serialize_string(soap, &a->faultstring);
+ soap_serialize_string(soap, &a->faultactor);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->detail);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Code);
+ soap_serialize_PointerToSOAP_ENV__Reason(soap, &a->SOAP_ENV__Reason);
+ soap_serialize_string(soap, &a->SOAP_ENV__Node);
+ soap_serialize_string(soap, &a->SOAP_ENV__Role);
+ soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->SOAP_ENV__Detail);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type)
+{
+ const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Fault), type))
+ return soap->error;
+ if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, ""))
+ return soap->error;
+ if (soap_out_string(soap, "faultstring", -1, &a->faultstring, ""))
+ return soap->error;
+ if (soap_out_string(soap, "faultactor", -1, &a->faultactor, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", -1, &a->SOAP_ENV__Code, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", -1, &a->SOAP_ENV__Reason, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Node", -1, &a->SOAP_ENV__Node, ""))
+ return soap->error;
+ if (soap_out_string(soap, "SOAP-ENV:Role", -1, &a->SOAP_ENV__Role, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", -1, &a->SOAP_ENV__Detail, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap *soap, const char *tag, struct SOAP_ENV__Fault *a, const char *type)
+{
+ size_t soap_flag_faultcode = 1;
+ size_t soap_flag_faultstring = 1;
+ size_t soap_flag_faultactor = 1;
+ size_t soap_flag_detail = 1;
+ size_t soap_flag_SOAP_ENV__Code = 1;
+ size_t soap_flag_SOAP_ENV__Reason = 1;
+ size_t soap_flag_SOAP_ENV__Node = 1;
+ size_t soap_flag_SOAP_ENV__Role = 1;
+ size_t soap_flag_SOAP_ENV__Detail = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Fault(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_faultcode && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "faultcode", &a->faultcode, ""))
+ { soap_flag_faultcode--;
+ continue;
+ }
+ if (soap_flag_faultstring && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultstring", &a->faultstring, "xsd:string"))
+ { soap_flag_faultstring--;
+ continue;
+ }
+ if (soap_flag_faultactor && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "faultactor", &a->faultactor, "xsd:string"))
+ { soap_flag_faultactor--;
+ continue;
+ }
+ if (soap_flag_detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "detail", &a->detail, ""))
+ { soap_flag_detail--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Code && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Code", &a->SOAP_ENV__Code, ""))
+ { soap_flag_SOAP_ENV__Code--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Reason && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", &a->SOAP_ENV__Reason, ""))
+ { soap_flag_SOAP_ENV__Reason--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Node && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Node", &a->SOAP_ENV__Node, "xsd:string"))
+ { soap_flag_SOAP_ENV__Node--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Role && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Role", &a->SOAP_ENV__Role, "xsd:string"))
+ { soap_flag_SOAP_ENV__Role--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Detail && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", &a->SOAP_ENV__Detail, ""))
+ { soap_flag_SOAP_ENV__Detail--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Fault, 0, sizeof(struct SOAP_ENV__Fault), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Fault);
+ if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Fault(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Fault, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Fault);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Fault);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Fault*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize_string(soap, &a->SOAP_ENV__Text);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Reason), type))
+ return soap->error;
+ if (soap->lang)
+ soap_set_attr(soap, "xml:lang", soap->lang, 1);
+ if (soap_out_string(soap, "SOAP-ENV:Text", -1, &a->SOAP_ENV__Text, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Text = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Reason(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Text && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in_string(soap, "SOAP-ENV:Text", &a->SOAP_ENV__Text, "xsd:string"))
+ { soap_flag_SOAP_ENV__Text--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Reason, 0, sizeof(struct SOAP_ENV__Reason), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Reason);
+ if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Reason, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Reason);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Reason);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Reason*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ a->__type = 0;
+ a->fault = NULL;
+ a->__any = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_markelement(soap, a->fault, a->__type);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Detail), type))
+ return soap->error;
+ if (soap_putelement(soap, a->fault, "fault", -1, a->__type))
+ return soap->error;
+ soap_outliteral(soap, "-any", &a->__any, NULL);
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail *a, const char *type)
+{
+ size_t soap_flag_fault = 1;
+ size_t soap_flag___any = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Detail(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_fault && soap->error == SOAP_TAG_MISMATCH)
+ if ((a->fault = soap_getelement(soap, &a->__type)))
+ { soap_flag_fault = 0;
+ continue;
+ }
+ if (soap_flag___any && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_inliteral(soap, "-any", &a->__any))
+ { soap_flag___any--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Detail, 0, sizeof(struct SOAP_ENV__Detail), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Detail);
+ if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Detail, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Detail);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Detail);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Detail*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_default__QName(soap, &a->SOAP_ENV__Value);
+ a->SOAP_ENV__Subcode = NULL;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+ soap_serialize__QName(soap, &a->SOAP_ENV__Value);
+ soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Subcode);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type)
+{
+ const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value);
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Code), type))
+ return soap->error;
+ if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, ""))
+ return soap->error;
+ if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, ""))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code *a, const char *type)
+{
+ size_t soap_flag_SOAP_ENV__Value = 1;
+ size_t soap_flag_SOAP_ENV__Subcode = 1;
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Code(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap_flag_SOAP_ENV__Value && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG))
+ if (soap_in__QName(soap, "SOAP-ENV:Value", &a->SOAP_ENV__Value, ""))
+ { soap_flag_SOAP_ENV__Value--;
+ continue;
+ }
+ if (soap_flag_SOAP_ENV__Subcode && soap->error == SOAP_TAG_MISMATCH)
+ if (soap_in_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", &a->SOAP_ENV__Subcode, ""))
+ { soap_flag_SOAP_ENV__Subcode--;
+ continue;
+ }
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Code, 0, sizeof(struct SOAP_ENV__Code), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Code);
+ if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Code, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Code);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Code);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Code*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a)
+{
+ (void)soap; (void)a; /* appease -Wall -Werror */
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap *soap, const char *tag, struct SOAP_ENV__Header *a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 0, type))
+ return NULL;
+ a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, NULL, NULL, NULL);
+ if (!a)
+ return NULL;
+ soap_default_SOAP_ENV__Header(soap, a);
+ if (soap->body && !*soap->href)
+ {
+ for (;;)
+ { soap->error = SOAP_TAG_MISMATCH;
+ if (soap->error == SOAP_TAG_MISMATCH)
+ soap->error = soap_ignore_element(soap);
+ if (soap->error == SOAP_NO_TAG)
+ break;
+ if (soap->error)
+ return NULL;
+ }
+ if (soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Header, 0, sizeof(struct SOAP_ENV__Header), 0, NULL);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Header);
+ if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p, const char *tag, const char *type)
+{
+ if ((p = soap_in_SOAP_ENV__Header(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size)
+{
+ (void)type; (void)arrayType; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:""));
+ struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Header, n, soap_fdelete);
+ if (!cp)
+ return NULL;
+ if (n < 0)
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header);
+ if (size)
+ *size = sizeof(struct SOAP_ENV__Header);
+ }
+ else
+ { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header[n]);
+ if (!cp->ptr)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ if (size)
+ *size = n * sizeof(struct SOAP_ENV__Header);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr));
+ return (struct SOAP_ENV__Header*)cp->ptr;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{
+ (void)soap; (void)st; (void)len; (void)n; /* appease -Wall -Werror */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p));
+ *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_SOAP_ENV__Reason))
+ soap_serialize_SOAP_ENV__Reason(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Reason *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Reason);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Reason(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Reason **)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Reason(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerToSOAP_ENV__Reason);
+ if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Reason(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_SOAP_ENV__Detail))
+ soap_serialize_SOAP_ENV__Detail(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Detail *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Detail);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Detail(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Detail **)soap_malloc(soap, sizeof(struct SOAP_ENV__Detail *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Detail(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerToSOAP_ENV__Detail);
+ if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Detail(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a)
+{
+ if (!soap_reference(soap, *a, SOAP_TYPE_SOAP_ENV__Code))
+ soap_serialize_SOAP_ENV__Code(soap, *a);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Code *const*a, const char *type)
+{
+ id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Code);
+ if (id < 0)
+ return soap->error;
+ return soap_out_SOAP_ENV__Code(soap, tag, id, *a, type);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code **a, const char *type)
+{
+ if (soap_element_begin_in(soap, tag, 1, NULL))
+ return NULL;
+ if (!a)
+ if (!(a = (struct SOAP_ENV__Code **)soap_malloc(soap, sizeof(struct SOAP_ENV__Code *))))
+ return NULL;
+ *a = NULL;
+ if (!soap->null && *soap->href != '#')
+ { soap_revert(soap);
+ if (!(*a = soap_in_SOAP_ENV__Code(soap, tag, *a, type)))
+ return NULL;
+ }
+ else
+ { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ }
+ return a;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerToSOAP_ENV__Code);
+ if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_PointerToSOAP_ENV__Code(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#endif
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE__QName);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE__QName, 2, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE__QName);
+ if (soap_out__QName(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in__QName(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap *soap, char **a)
+{
+ (void)soap; /* appease -Wall -Werror */
+#ifdef SOAP_DEFAULT_string
+ *a = SOAP_DEFAULT_string;
+#else
+ *a = (char *)0;
+#endif
+}
+
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
+{
+ soap_reference(soap, *a, SOAP_TYPE_string);
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap *soap, const char *tag, int id, char *const*a, const char *type)
+{
+ return soap_outstring(soap, tag, id, a, type, SOAP_TYPE_string);
+}
+
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap *soap, const char *tag, char **a, const char *type)
+{ char **p;
+ p = soap_instring(soap, tag, a, type, SOAP_TYPE_string, 1, -1, -1);
+ return p;
+}
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap *soap, char *const*a, const char *tag, const char *type)
+{
+ register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_string);
+ if (soap_out_string(soap, tag?tag:"byte", id, a, type))
+ return soap->error;
+ return soap_putindependent(soap);
+}
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap *soap, char **p, const char *tag, const char *type)
+{
+ if ((p = soap_in_string(soap, tag, p, type)))
+ if (soap_getindependent(soap))
+ return NULL;
+ return p;
+}
+
+#if defined(__BORLANDC__)
+#pragma option pop
+#pragma option pop
+#endif
+
+/* End of envC.cpp */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/envH.h b/usr/src/lib/libkmsagent/common/SOAP/envH.h
new file mode 100644
index 0000000000..3e32983a7c
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/envH.h
@@ -0,0 +1,329 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* envH.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/Env/env.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef envH_H
+#define envH_H
+#include "envStub.h"
+#ifndef WITH_NOIDREF
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
+SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
+SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
+
+#ifdef __cplusplus
+}
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
+#endif
+SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
+
+SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
+SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
+
+#ifndef SOAP_TYPE_byte
+#define SOAP_TYPE_byte (3)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*);
+SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*);
+
+#define soap_write_byte(soap, data) ( soap_begin_send(soap) || soap_put_byte(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*);
+
+#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*);
+
+#ifndef SOAP_TYPE_int
+#define SOAP_TYPE_int (1)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*);
+SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*);
+
+#define soap_write_int(soap, data) ( soap_begin_send(soap) || soap_put_int(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*);
+
+#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*);
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_SOAP_ENV__Fault
+#define SOAP_TYPE_SOAP_ENV__Fault (14)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*);
+
+#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Fault(soap, data), 0) || soap_put_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Fault(soap, n) soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Fault(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_SOAP_ENV__Reason
+#define SOAP_TYPE_SOAP_ENV__Reason (13)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*);
+
+#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Reason(soap, data), 0) || soap_put_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Reason(soap, n) soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Reason(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_SOAP_ENV__Detail
+#define SOAP_TYPE_SOAP_ENV__Detail (10)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*);
+
+#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Detail(soap, data), 0) || soap_put_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Detail(soap, n) soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Detail(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_SOAP_ENV__Code
+#define SOAP_TYPE_SOAP_ENV__Code (8)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*);
+
+#define soap_write_SOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Code(soap, data), 0) || soap_put_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Code(soap, n) soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Code(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_SOAP_ENV__Header
+#define SOAP_TYPE_SOAP_ENV__Header (7)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*);
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*);
+
+#define soap_write_SOAP_ENV__Header(soap, data) ( soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Header(soap, data), 0) || soap_put_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*);
+
+#define soap_new_SOAP_ENV__Header(soap, n) soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL)
+
+
+#define soap_delete_SOAP_ENV__Header(soap, p) soap_delete(soap, p)
+
+SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
+SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason
+#define SOAP_TYPE_PointerToSOAP_ENV__Reason (16)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Reason(soap, data), 0) || soap_put_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail
+#define SOAP_TYPE_PointerToSOAP_ENV__Detail (15)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Detail(soap, data), 0) || soap_put_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*);
+
+#endif
+
+#ifndef WITH_NOGLOBAL
+
+#ifndef SOAP_TYPE_PointerToSOAP_ENV__Code
+#define SOAP_TYPE_PointerToSOAP_ENV__Code (9)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *);
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*);
+
+#define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Code(soap, data), 0) || soap_put_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*);
+
+#define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*);
+
+#endif
+
+#ifndef SOAP_TYPE__QName
+#define SOAP_TYPE__QName (5)
+#endif
+
+#define soap_default__QName(soap, a) soap_default_string(soap, a)
+
+
+#define soap_serialize__QName(soap, a) soap_serialize_string(soap, a)
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*);
+
+#define soap_write__QName(soap, data) ( soap_begin_send(soap) || (soap_serialize__QName(soap, data), 0) || soap_put__QName(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*);
+
+#ifndef SOAP_TYPE_string
+#define SOAP_TYPE_string (4)
+#endif
+SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **);
+SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*);
+SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*);
+SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*);
+
+#define soap_write_string(soap, data) ( soap_begin_send(soap) || (soap_serialize_string(soap, data), 0) || soap_put_string(soap, data, NULL, NULL) || soap_end_send(soap) )
+
+SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*);
+
+#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap) )
+
+SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*);
+
+#endif
+
+/* End of envH.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/envStub.h b/usr/src/lib/libkmsagent/common/SOAP/envStub.h
new file mode 100644
index 0000000000..6642474746
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/envStub.h
@@ -0,0 +1,151 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/* envStub.h
+ Generated by gSOAP 2.7.17 from ../gsoapStubs/Env/env.h
+ Copyright(C) 2000-2010, Robert van Engelen, Genivia Inc. All Rights Reserved.
+ This part of the software is released under one of the following licenses:
+ GPL, the gSOAP public license, or Genivia's license for commercial use.
+*/
+
+#ifndef envStub_H
+#define envStub_H
+#include "stdsoap2.h"
+
+/******************************************************************************\
+ * *
+ * Enumerations *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Types with Custom Serializers *
+ * *
+\******************************************************************************/
+
+
+/******************************************************************************\
+ * *
+ * Classes and Structs *
+ * *
+\******************************************************************************/
+
+
+#if 0 /* volatile type: do not declare here, declared elsewhere */
+
+#endif
+
+#ifndef SOAP_TYPE_SOAP_ENV__Header
+#define SOAP_TYPE_SOAP_ENV__Header (7)
+/* SOAP Header: */
+struct SOAP_ENV__Header
+{
+#ifdef WITH_NOEMPTYSTRUCT
+private:
+ char dummy; /* dummy member to enable compilation */
+#endif
+};
+#endif
+
+#ifndef SOAP_TYPE_SOAP_ENV__Code
+#define SOAP_TYPE_SOAP_ENV__Code (8)
+/* SOAP Fault Code: */
+struct SOAP_ENV__Code
+{
+public:
+ char *SOAP_ENV__Value; /* optional element of type xsd:QName */
+ struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */
+};
+#endif
+
+#ifndef SOAP_TYPE_SOAP_ENV__Detail
+#define SOAP_TYPE_SOAP_ENV__Detail (10)
+/* SOAP-ENV:Detail */
+struct SOAP_ENV__Detail
+{
+public:
+ int __type; /* any type of element <fault> (defined below) */
+ void *fault; /* transient */
+ char *__any;
+};
+#endif
+
+#ifndef SOAP_TYPE_SOAP_ENV__Reason
+#define SOAP_TYPE_SOAP_ENV__Reason (13)
+/* SOAP-ENV:Reason */
+struct SOAP_ENV__Reason
+{
+public:
+ char *SOAP_ENV__Text; /* optional element of type xsd:string */
+};
+#endif
+
+#ifndef SOAP_TYPE_SOAP_ENV__Fault
+#define SOAP_TYPE_SOAP_ENV__Fault (14)
+/* SOAP Fault: */
+struct SOAP_ENV__Fault
+{
+public:
+ char *faultcode; /* optional element of type xsd:QName */
+ char *faultstring; /* optional element of type xsd:string */
+ char *faultactor; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */
+ struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */
+ struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */
+ char *SOAP_ENV__Node; /* optional element of type xsd:string */
+ char *SOAP_ENV__Role; /* optional element of type xsd:string */
+ struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */
+};
+#endif
+
+/******************************************************************************\
+ * *
+ * Typedefs *
+ * *
+\******************************************************************************/
+
+#ifndef SOAP_TYPE__QName
+#define SOAP_TYPE__QName (5)
+typedef char *_QName;
+#endif
+
+#ifndef SOAP_TYPE__XML
+#define SOAP_TYPE__XML (6)
+typedef char *_XML;
+#endif
+
+
+/******************************************************************************\
+ * *
+ * Externals *
+ * *
+\******************************************************************************/
+
+
+#endif
+
+/* End of envStub.h */
diff --git a/usr/src/lib/libkmsagent/common/SOAP/stdsoap2.cpp b/usr/src/lib/libkmsagent/common/SOAP/stdsoap2.cpp
new file mode 100644
index 0000000000..725f64b08b
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/stdsoap2.cpp
@@ -0,0 +1,15632 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+/*
+ stdsoap2.c[pp] 2.7.17
+
+ gSOAP runtime engine
+
+gSOAP XML Web services tools
+Copyright (C) 2000-2010, Robert van Engelen, Genivia Inc., All Rights Reserved.
+This part of the software is released under ONE of the following licenses:
+GPL, or the gSOAP public license, or Genivia's license for commercial use.
+--------------------------------------------------------------------------------
+Contributors:
+
+Oracle, Inc. - additions are noted in the code commented with
+"Oracle customization"
+ - customization of the SSL accept timeout
+ - work around for SSL_Sleep reporting closed connection
+ - Function ssl_auth_init was static, but is now exported for external override
+ - redirection of gSoap debug logs when debug builds enabled
+ - added SSL_CTX_set_cipher_list call to restrict the cipher suite to RSA-2048/AES
+ TLS_RSA_WITH_AES_256_CBC_SHA is defined in RFC 3268
+ also see http://www.openssl.org/docs/apps/ciphers.html
+ - Added SSL_OP_NO_SSLv3 to force use of TLS
+ - bug fix: added call to close socket handle in various places noted in the code,
+ since the caller overwrites soap->socket with the return value
+ - compile warning cleanup
+
+
+ Wind River Systems Inc., for the following additions under gSOAP public license:
+ - vxWorks compatible
+--------------------------------------------------------------------------------
+gSOAP public license.
+
+The contents of this file are subject to the gSOAP Public License Version 1.3
+(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.cs.fsu.edu/~engelen/soaplicense.html
+Software distributed under the License is distributed on an "AS IS" basis,
+WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+for the specific language governing rights and limitations under the License.
+
+The Initial Developer of the Original Code is Robert A. van Engelen.
+Copyright (C) 2000-2010, Robert van Engelen, Genivia Inc., All Rights Reserved.
+--------------------------------------------------------------------------------
+GPL license.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+Author contact information:
+engelen@genivia.com / engelen@acm.org
+
+This program is released under the GPL with the additional exemption that
+compiling, linking, and/or using OpenSSL is allowed.
+--------------------------------------------------------------------------------
+A commercial use license is available from Genivia, Inc., contact@genivia.com
+--------------------------------------------------------------------------------
+
+Installation note:
+
+Win32 build needs winsock.dll (Visual C++ "wsock32.lib")
+To do this in Visual C++ 6.0, go to "Project", "settings", select the "Link"
+tab (the project file needs to be selected in the file view) and add
+"wsock32.lib" to the "Object/library modules" entry
+
+On Mac OS X with gcc (GCC) 3.1 20020420 (prerelease) you MUST compile with
+-fstack_check when using -O2 because gcc 3.1 has a bug that smashes the stack
+when locally allocated data exceeds 64K.
+
+*/
+
+#ifdef AS400
+# pragma convert(819) /* EBCDIC to ASCII */
+#endif
+
+#include "stdsoap2.h"
+
+/*
+ Oracle customization for OpenSSL 0.9.8 removal of deprecated function usage: RSA_generate_key
+*/
+#ifdef WITH_OPENSSL
+#ifdef OPENSSL_NO_DEPRECATED
+#include <openssl/rsa.h>
+#include <openssl/bn.h>
+#include <openssl/dh.h>
+#endif
+#endif
+
+#ifdef SOAP_MEM_DEBUG
+#ifndef WIN32
+#include <ucontext.h> /* Oracle customization (for printstack(3C)) */
+#endif
+#endif
+
+#ifdef __BORLANDC__
+# pragma warn -8060
+#else
+# ifdef WIN32
+# ifdef UNDER_CE
+# pragma comment(lib, "winsock.lib")
+# else
+# pragma comment(lib, "wsock32.lib")
+# endif
+# pragma warning(disable : 4996) /* disable deprecation warnings */
+# endif
+#endif
+
+#ifdef __cplusplus
+SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.7.17 2010-05-10 00:00:00 GMT")
+extern "C" {
+#else
+SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.7.17 2010-05-10 00:00:00 GMT")
+#endif
+
+/* 8bit character representing unknown/nonrepresentable character data (e.g. not supported by current locale with multibyte support enabled) */
+#ifndef SOAP_UNKNOWN_CHAR
+#define SOAP_UNKNOWN_CHAR (127)
+#endif
+
+/* EOF=-1 */
+#define SOAP_LT (soap_wchar)(-2) /* XML character '<' */
+#define SOAP_TT (soap_wchar)(-3) /* XML character '</' */
+#define SOAP_GT (soap_wchar)(-4) /* XML character '>' */
+#define SOAP_QT (soap_wchar)(-5) /* XML character '"' */
+#define SOAP_AP (soap_wchar)(-6) /* XML character ''' */
+
+#define soap_blank(c) ((c) >= 0 && (c) <= 32)
+#define soap_notblank(c) ((c) > 32)
+
+#if defined(WIN32) && !defined(UNDER_CE)
+#define soap_hash_ptr(p) ((PtrToUlong(p) >> 3) & (SOAP_PTRHASH - 1))
+#else
+#define soap_hash_ptr(p) ((size_t)(((unsigned long)(p) >> 3) & (SOAP_PTRHASH-1)))
+#endif
+
+#if !defined(WITH_LEAN) || defined(SOAP_DEBUG)
+static void soap_init_logs(struct soap*);
+#endif
+#ifdef SOAP_DEBUG
+static void soap_close_logfile(struct soap*, int);
+static void soap_set_logfile(struct soap*, int, const char*);
+#endif
+
+#ifdef SOAP_MEM_DEBUG
+static void soap_init_mht(struct soap*);
+static void soap_free_mht(struct soap*);
+static void soap_track_unlink(struct soap*, const void*);
+#endif
+
+#ifndef PALM_2
+static int soap_set_error(struct soap*, const char*, const char*, const char*, const char*, int);
+static int soap_copy_fault(struct soap*, const char*, const char*, const char*, const char*);
+static int soap_getattrval(struct soap*, char*, size_t, soap_wchar);
+#endif
+
+#ifndef PALM_1
+static void soap_free_ns(struct soap *soap);
+static soap_wchar soap_char(struct soap*);
+static soap_wchar soap_get_pi(struct soap*);
+static int soap_isxdigit(int);
+static void *fplugin(struct soap*, const char*);
+static char *soap_get_http_body(struct soap*);
+static size_t soap_count_attachments(struct soap *soap);
+static int soap_try_connect_command(struct soap*, int http_command, const char *endpoint, const char *action);
+#ifndef WITH_NOIDREF
+static void soap_update_ptrs(struct soap*, char*, char*, char*, char*);
+static int soap_has_copies(struct soap*, const char*, const char*);
+static void soap_init_iht(struct soap*);
+static void soap_free_iht(struct soap*);
+static void soap_init_pht(struct soap*);
+static void soap_free_pht(struct soap*);
+#endif
+#endif
+
+#ifndef WITH_LEAN
+static const char *soap_set_validation_fault(struct soap*, const char*, const char*);
+static int soap_isnumeric(struct soap*, const char*);
+static struct soap_nlist *soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized);
+static void soap_utilize_ns(struct soap *soap, const char *tag, size_t n);
+#endif
+
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static struct soap_multipart *soap_new_multipart(struct soap*, struct soap_multipart**, struct soap_multipart**, char*, size_t);
+static int soap_putdimefield(struct soap*, const char*, size_t);
+static char *soap_getdimefield(struct soap*, size_t);
+static void soap_select_mime_boundary(struct soap*);
+static int soap_valid_mime_boundary(struct soap*);
+static void soap_resolve_attachment(struct soap*, struct soap_multipart*);
+#endif
+#endif
+
+#ifdef WITH_GZIP
+static int soap_getgziphdr(struct soap*);
+#endif
+
+#ifdef WITH_OPENSSL
+int soap_ssl_init_done = 0;
+
+//
+// Oracle customization
+//
+// Function ssl_auth_init was static, but is now exported for external override
+/*
+static int ssl_auth_init(struct soap*);
+*/
+int ssl_auth_init(struct soap*);
+static int ssl_verify_callback(int, X509_STORE_CTX*);
+static int ssl_verify_callback_allow_expired_certificate(int, X509_STORE_CTX*);
+static int ssl_password(char*, int, int, void *);
+#endif
+
+#if !defined(WITH_NOHTTP) || !defined(WITH_LEANER)
+#ifndef PALM_1
+static const char *soap_decode(char*, size_t, const char*, const char*);
+#endif
+#endif
+
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static soap_wchar soap_getchunkchar(struct soap*);
+static const char *http_error(struct soap*, int);
+static int http_get(struct soap*);
+static int http_405(struct soap*);
+static int http_post(struct soap*, const char*, const char*, int, const char*, const char*, size_t);
+static int http_send_header(struct soap*, const char*);
+static int http_post_header(struct soap*, const char*, const char*);
+static int http_response(struct soap*, int, size_t);
+static int http_parse(struct soap*);
+static int http_parse_header(struct soap*, const char*, const char*);
+#endif
+#endif
+
+#ifndef WITH_NOIO
+
+#ifndef PALM_1
+static int fsend(struct soap*, const char*, size_t);
+static size_t frecv(struct soap*, char*, size_t);
+static int tcp_init(struct soap*);
+static const char *tcp_error(struct soap*);
+#ifndef WITH_IPV6
+static int tcp_gethost(struct soap*, const char *addr, struct in_addr *inaddr);
+#endif
+static SOAP_SOCKET tcp_connect(struct soap*, const char *endpoint, const char *host, int port);
+static SOAP_SOCKET tcp_accept(struct soap*, SOAP_SOCKET, struct sockaddr*, int*);
+static int tcp_select(struct soap*, SOAP_SOCKET, int, int);
+static int tcp_disconnect(struct soap*);
+static int tcp_closesocket(struct soap*, SOAP_SOCKET);
+static int tcp_shutdownsocket(struct soap*, SOAP_SOCKET, int);
+static const char *soap_strerror(struct soap*);
+#endif
+
+#define SOAP_TCP_SELECT_RCV 0x1
+#define SOAP_TCP_SELECT_SND 0x2
+#define SOAP_TCP_SELECT_ERR 0x4
+#define SOAP_TCP_SELECT_ALL 0x7
+
+#if defined(WIN32)
+ #define SOAP_SOCKBLOCK(fd) \
+ { u_long blocking = 0; \
+ ioctlsocket(fd, FIONBIO, &blocking); \
+ }
+ #define SOAP_SOCKNONBLOCK(fd) \
+ { u_long nonblocking = 1; \
+ ioctlsocket(fd, FIONBIO, &nonblocking); \
+ }
+#elif defined(VXWORKS)
+ #define SOAP_SOCKBLOCK(fd) \
+ { u_long blocking = 0; \
+ ioctl(fd, FIONBIO, (int)(&blocking)); \
+ }
+ #define SOAP_SOCKNONBLOCK(fd) \
+ { u_long nonblocking = 1; \
+ ioctl(fd, FIONBIO, (int)(&nonblocking)); \
+ }
+#elif defined(PALM)
+ #define SOAP_SOCKBLOCK(fd) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0)&~O_NONBLOCK);
+ #define SOAP_SOCKNONBLOCK(fd) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0)|O_NONBLOCK);
+#elif defined(SYMBIAN)
+ #define SOAP_SOCKBLOCK(fd) \
+ { long blocking = 0; \
+ ioctl(fd, 0/*FIONBIO*/, &blocking); \
+ }
+ #define SOAP_SOCKNONBLOCK(fd) \
+ { long nonblocking = 1; \
+ ioctl(fd, 0/*FIONBIO*/, &nonblocking); \
+ }
+#else
+ #define SOAP_SOCKBLOCK(fd) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)&~O_NONBLOCK);
+ #define SOAP_SOCKNONBLOCK(fd) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK);
+#endif
+
+#endif
+
+#if defined(PALM) && !defined(PALM_2)
+unsigned short errno;
+#endif
+
+#ifndef PALM_1
+static const char soap_env1[42] = "http://schemas.xmlsoap.org/soap/envelope/";
+static const char soap_enc1[42] = "http://schemas.xmlsoap.org/soap/encoding/";
+static const char soap_env2[40] = "http://www.w3.org/2003/05/soap-envelope";
+static const char soap_enc2[40] = "http://www.w3.org/2003/05/soap-encoding";
+static const char soap_rpc[35] = "http://www.w3.org/2003/05/soap-rpc";
+#endif
+
+#ifndef PALM_1
+const struct soap_double_nan soap_double_nan = {0xFFFFFFFF, 0xFFFFFFFF};
+static const char soap_base64o[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char soap_base64i[81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31XXXXXX\32\33\34\35\36\37\40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\60\61\62\63";
+#endif
+
+#ifndef WITH_LEAN
+static const char soap_indent[11] = "\n\t\t\t\t\t\t\t\t\t";
+/* Alternative indentation form for SOAP_XML_INDENT:
+static const char soap_indent[21] = "\n ";
+*/
+#endif
+
+#ifndef SOAP_CANARY
+# define SOAP_CANARY (0xC0DE)
+#endif
+
+static const char soap_padding[4] = "\0\0\0";
+#define SOAP_STR_PADDING (soap_padding)
+#define SOAP_STR_EOS (soap_padding)
+#define SOAP_NON_NULL (soap_padding)
+
+#ifndef WITH_LEAN
+static const struct soap_code_map html_entity_codes[] = /* entities for XHTML parsing */
+{ { 160, "nbsp" },
+ { 161, "iexcl" },
+ { 162, "cent" },
+ { 163, "pound" },
+ { 164, "curren" },
+ { 165, "yen" },
+ { 166, "brvbar" },
+ { 167, "sect" },
+ { 168, "uml" },
+ { 169, "copy" },
+ { 170, "ordf" },
+ { 171, "laquo" },
+ { 172, "not" },
+ { 173, "shy" },
+ { 174, "reg" },
+ { 175, "macr" },
+ { 176, "deg" },
+ { 177, "plusmn" },
+ { 178, "sup2" },
+ { 179, "sup3" },
+ { 180, "acute" },
+ { 181, "micro" },
+ { 182, "para" },
+ { 183, "middot" },
+ { 184, "cedil" },
+ { 185, "sup1" },
+ { 186, "ordm" },
+ { 187, "raquo" },
+ { 188, "frac14" },
+ { 189, "frac12" },
+ { 190, "frac34" },
+ { 191, "iquest" },
+ { 192, "Agrave" },
+ { 193, "Aacute" },
+ { 194, "Acirc" },
+ { 195, "Atilde" },
+ { 196, "Auml" },
+ { 197, "Aring" },
+ { 198, "AElig" },
+ { 199, "Ccedil" },
+ { 200, "Egrave" },
+ { 201, "Eacute" },
+ { 202, "Ecirc" },
+ { 203, "Euml" },
+ { 204, "Igrave" },
+ { 205, "Iacute" },
+ { 206, "Icirc" },
+ { 207, "Iuml" },
+ { 208, "ETH" },
+ { 209, "Ntilde" },
+ { 210, "Ograve" },
+ { 211, "Oacute" },
+ { 212, "Ocirc" },
+ { 213, "Otilde" },
+ { 214, "Ouml" },
+ { 215, "times" },
+ { 216, "Oslash" },
+ { 217, "Ugrave" },
+ { 218, "Uacute" },
+ { 219, "Ucirc" },
+ { 220, "Uuml" },
+ { 221, "Yacute" },
+ { 222, "THORN" },
+ { 223, "szlig" },
+ { 224, "agrave" },
+ { 225, "aacute" },
+ { 226, "acirc" },
+ { 227, "atilde" },
+ { 228, "auml" },
+ { 229, "aring" },
+ { 230, "aelig" },
+ { 231, "ccedil" },
+ { 232, "egrave" },
+ { 233, "eacute" },
+ { 234, "ecirc" },
+ { 235, "euml" },
+ { 236, "igrave" },
+ { 237, "iacute" },
+ { 238, "icirc" },
+ { 239, "iuml" },
+ { 240, "eth" },
+ { 241, "ntilde" },
+ { 242, "ograve" },
+ { 243, "oacute" },
+ { 244, "ocirc" },
+ { 245, "otilde" },
+ { 246, "ouml" },
+ { 247, "divide" },
+ { 248, "oslash" },
+ { 249, "ugrave" },
+ { 250, "uacute" },
+ { 251, "ucirc" },
+ { 252, "uuml" },
+ { 253, "yacute" },
+ { 254, "thorn" },
+ { 255, "yuml" },
+ { 0, NULL }
+};
+#endif
+
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+static const struct soap_code_map h_error_codes[] =
+{
+#ifdef HOST_NOT_FOUND
+ { HOST_NOT_FOUND, "Host not found" },
+#endif
+#ifdef TRY_AGAIN
+ { TRY_AGAIN, "Try Again" },
+#endif
+#ifdef NO_RECOVERY
+ { NO_RECOVERY, "No Recovery" },
+#endif
+#ifdef NO_DATA
+ { NO_DATA, "No Data" },
+#endif
+#ifdef NO_ADDRESS
+ { NO_ADDRESS, "No Address" },
+#endif
+ { 0, NULL }
+};
+#endif
+#endif
+
+#ifndef WITH_NOHTTP
+#ifndef WITH_LEAN
+static const struct soap_code_map h_http_error_codes[] =
+{ { 200, "OK" },
+ { 201, "Created" },
+ { 202, "Accepted" },
+ { 203, "Non-Authoritative Information" },
+ { 204, "No Content" },
+ { 205, "Reset Content" },
+ { 206, "Partial Content" },
+ { 300, "Multiple Choices" },
+ { 301, "Moved Permanently" },
+ { 302, "Found" },
+ { 303, "See Other" },
+ { 304, "Not Modified" },
+ { 305, "Use Proxy" },
+ { 307, "Temporary Redirect" },
+ { 400, "Bad Request" },
+ { 401, "Unauthorized" },
+ { 402, "Payment Required" },
+ { 403, "Forbidden" },
+ { 404, "Not Found" },
+ { 405, "Method Not Allowed" },
+ { 406, "Not Acceptable" },
+ { 407, "Proxy Authentication Required" },
+ { 408, "Request Time-out" },
+ { 409, "Conflict" },
+ { 410, "Gone" },
+ { 411, "Length Required" },
+ { 412, "Precondition Failed" },
+ { 413, "Request Entity Too Large" },
+ { 414, "Request-URI Too Large" },
+ { 415, "Unsupported Media Type" },
+ { 416, "Requested range not satisfiable" },
+ { 417, "Expectation Failed" },
+ { 500, "Internal Server Error" },
+ { 501, "Not Implemented" },
+ { 502, "Bad Gateway" },
+ { 503, "Service Unavailable" },
+ { 504, "Gateway Time-out" },
+ { 505, "HTTP Version not supported" },
+ { 0, NULL }
+};
+#endif
+#endif
+
+#ifdef WITH_OPENSSL
+static const struct soap_code_map h_ssl_error_codes[] =
+{
+#define _SSL_ERROR(e) { e, #e }
+ _SSL_ERROR(SSL_ERROR_SSL),
+ _SSL_ERROR(SSL_ERROR_ZERO_RETURN),
+ _SSL_ERROR(SSL_ERROR_WANT_READ),
+ _SSL_ERROR(SSL_ERROR_WANT_WRITE),
+ _SSL_ERROR(SSL_ERROR_WANT_CONNECT),
+ _SSL_ERROR(SSL_ERROR_WANT_X509_LOOKUP),
+ _SSL_ERROR(SSL_ERROR_SYSCALL),
+ { 0, NULL }
+};
+#endif
+
+#ifndef WITH_LEANER
+static const struct soap_code_map mime_codes[] =
+{ { SOAP_MIME_7BIT, "7bit" },
+ { SOAP_MIME_8BIT, "8bit" },
+ { SOAP_MIME_BINARY, "binary" },
+ { SOAP_MIME_QUOTED_PRINTABLE, "quoted-printable" },
+ { SOAP_MIME_BASE64, "base64" },
+ { SOAP_MIME_IETF_TOKEN, "ietf-token" },
+ { SOAP_MIME_X_TOKEN, "x-token" },
+ { 0, NULL }
+};
+#endif
+
+#ifdef WIN32
+static int tcp_done = 0;
+#endif
+
+#if defined(HP_UX) && defined(HAVE_GETHOSTBYNAME_R)
+extern int h_errno;
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+fsend(struct soap *soap, const char *s, size_t n)
+{ register int nwritten, err;
+#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
+ if (soap->os)
+ { soap->os->write(s, (std::streamsize)n);
+ if (soap->os->good())
+ return SOAP_OK;
+ soap->errnum = 0;
+ return SOAP_EOF;
+ }
+#endif
+ while (n)
+ { if (soap_valid_socket(soap->socket))
+ {
+ if (soap->send_timeout)
+ { for (;;)
+ { register int r;
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ALL, soap->send_timeout);
+ else
+#endif
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout);
+ if (r > 0)
+ break;
+ if (!r)
+ return SOAP_EOF;
+ err = soap->errnum;
+ if (!err)
+ return soap->error;
+ if (err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK)
+ return SOAP_EOF;
+ }
+ }
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ nwritten = SSL_write(soap->ssl, s, (int)n);
+ else if (soap->bio)
+ nwritten = BIO_write(soap->bio, s, (int)n);
+ else
+#endif
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ { if (soap->peerlen)
+ nwritten = sendto(soap->socket, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen);
+ else
+ nwritten = send(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags);
+ /* retry and back-off algorithm */
+ /* TODO: this is not very clear from specs so verify and limit conditions under which we should loop (e.g. ENOBUFS) */
+ if (nwritten < 0)
+ { int udp_repeat;
+ int udp_delay;
+ if ((soap->connect_flags & SO_BROADCAST))
+ udp_repeat = 3; /* SOAP-over-UDP MULTICAST_UDP_REPEAT - 1 */
+ else
+ udp_repeat = 1; /* SOAP-over-UDP UNICAST_UDP_REPEAT - 1 */
+ udp_delay = (soap_random % 201) + 50; /* UDP_MIN_DELAY .. UDP_MAX_DELAY */
+ do
+ { tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ERR, -1000 * udp_delay);
+ if (soap->peerlen)
+ nwritten = sendto(soap->socket, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen);
+ else
+ nwritten = send(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags);
+ udp_delay <<= 1;
+ if (udp_delay > 500) /* UDP_UPPER_DELAY */
+ udp_delay = 500;
+ }
+ while (nwritten < 0 && --udp_repeat > 0);
+ }
+ }
+ else
+#endif
+#if !defined(PALM) && !defined(AS400)
+ nwritten = send(soap->socket, s, (int)n, soap->socket_flags);
+#else
+ nwritten = send(soap->socket, (void*)s, n, soap->socket_flags);
+#endif
+ if (nwritten <= 0)
+ {
+ register int r = 0;
+ err = soap_socket_errno(soap->socket);
+#ifdef WITH_OPENSSL
+ if (soap->ssl && (r = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && r != SSL_ERROR_WANT_READ && r != SSL_ERROR_WANT_WRITE)
+ { soap->errnum = err;
+ return SOAP_EOF;
+ }
+#endif
+ if (err == SOAP_EWOULDBLOCK || err == SOAP_EAGAIN)
+ {
+#ifdef WITH_OPENSSL
+ if (soap->ssl && r == SSL_ERROR_WANT_READ)
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000);
+ else
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000);
+#else
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout ? soap->send_timeout : -10000);
+#endif
+ if (!r && soap->send_timeout)
+ return SOAP_EOF;
+ if (r < 0 && soap->errnum != SOAP_EINTR)
+ return SOAP_EOF;
+ }
+ else if (err && err != SOAP_EINTR)
+ { soap->errnum = err;
+ return SOAP_EOF;
+ }
+ nwritten = 0; /* and call write() again */
+ }
+ }
+ else
+ {
+#ifdef WITH_FASTCGI
+ nwritten = fwrite((void*)s, 1, n, stdout);
+ fflush(stdout);
+#else
+#ifdef UNDER_CE
+ nwritten = fwrite(s, 1, n, soap->sendfd);
+#else
+#ifdef VXWORKS
+#ifdef WMW_RPM_IO
+ if (soap->rpmreqid)
+ nwritten = (httpBlockPut(soap->rpmreqid, (char*)s, n) == 0) ? n : -1;
+ else
+#endif
+ nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w"));
+#else
+#ifdef WIN32
+ nwritten = _write(soap->sendfd, s, (unsigned int)n);
+#else
+ nwritten = write(soap->sendfd, s, (unsigned int)n);
+#endif
+#endif
+#endif
+#endif
+ if (nwritten <= 0)
+ {
+#ifndef WITH_FASTCGI
+ err = soap_errno;
+#else
+ err = EOF;
+#endif
+ if (err && err != SOAP_EINTR && err != SOAP_EWOULDBLOCK && err != SOAP_EAGAIN)
+ { soap->errnum = err;
+ return SOAP_EOF;
+ }
+ nwritten = 0; /* and call write() again */
+ }
+ }
+ n -= nwritten;
+ s += nwritten;
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_send_raw(struct soap *soap, const char *s, size_t n)
+{ if (!n)
+ return SOAP_OK;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { soap->count += n;
+#ifndef WITH_LEANER
+ if (soap->fpreparesend && (soap->mode & SOAP_IO) != SOAP_IO_STORE)
+ return soap->error = soap->fpreparesend(soap, s, n);
+#endif
+ return SOAP_OK;
+ }
+ if (soap->mode & SOAP_IO)
+ { register size_t i = SOAP_BUFLEN - soap->bufidx;
+ while (n >= i)
+ { memcpy(soap->buf + soap->bufidx, s, i);
+ soap->bufidx = SOAP_BUFLEN;
+ if (soap_flush(soap))
+ return soap->error;
+ s += i;
+ n -= i;
+ i = SOAP_BUFLEN;
+ }
+ memcpy(soap->buf + soap->bufidx, s, n);
+ soap->bufidx += n;
+ return SOAP_OK;
+ }
+ return soap_flush_raw(soap, s, n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_flush(struct soap *soap)
+{ register size_t n = soap->bufidx;
+ if (n)
+ {
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
+ { register int r;
+ if (soap->fpreparesend && (r = soap->fpreparesend(soap, soap->buf, n)))
+ return soap->error = r;
+ }
+#endif
+ soap->bufidx = 0;
+#ifdef WITH_ZLIB
+ if (soap->mode & SOAP_ENC_ZLIB)
+ { soap->d_stream->next_in = (Byte*)soap->buf;
+ soap->d_stream->avail_in = (unsigned int)n;
+#ifdef WITH_GZIP
+ soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)n);
+#endif
+ do
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating %u bytes\n", soap->d_stream->avail_in));
+ if (deflate(soap->d_stream, Z_NO_FLUSH) != Z_OK)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to deflate: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ if (!soap->d_stream->avail_out)
+ { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN))
+ return soap->error;
+ soap->d_stream->next_out = (Byte*)soap->z_buf;
+ soap->d_stream->avail_out = SOAP_BUFLEN;
+ }
+ } while (soap->d_stream->avail_in);
+ }
+ else
+#endif
+ return soap_flush_raw(soap, soap->buf, n);
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_flush_raw(struct soap *soap, const char *s, size_t n)
+{ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
+ { register char *t;
+ if (!(t = (char*)soap_push_block(soap, NULL, n)))
+ return soap->error = SOAP_EOM;
+ memcpy(t, s, n);
+ return SOAP_OK;
+ }
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
+ { char t[16];
+ sprintf(t, "\r\n%lX\r\n" + (soap->chunksize ? 0 : 2), (unsigned long)n);
+ DBGMSG(SENT, t, strlen(t));
+ if ((soap->error = soap->fsend(soap, t, strlen(t))))
+ return soap->error;
+ soap->chunksize += n;
+ }
+ DBGMSG(SENT, s, n);
+#endif
+ return soap->error = soap->fsend(soap, s, n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_send(struct soap *soap, const char *s)
+{ if (s)
+ return soap_send_raw(soap, s, strlen(s));
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_send2(struct soap *soap, const char *s1, const char *s2)
+{ if (soap_send(soap, s1))
+ return soap->error;
+ return soap_send(soap, s2);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_send3(struct soap *soap, const char *s1, const char *s2, const char *s3)
+{ if (soap_send(soap, s1)
+ || soap_send(soap, s2))
+ return soap->error;
+ return soap_send(soap, s3);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static size_t
+frecv(struct soap *soap, char *s, size_t n)
+{ register int r;
+ register int retries = 100; /* max 100 retries with non-blocking sockets */
+ soap->errnum = 0;
+#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
+ if (soap->is)
+ { if (soap->is->good())
+ return soap->is->read(s, (std::streamsize)n).gcount();
+ return 0;
+ }
+#endif
+ if (soap_valid_socket(soap->socket))
+ { for (;;)
+ {
+#ifdef WITH_OPENSSL
+ register int err = 0;
+#endif
+#ifdef WITH_OPENSSL
+ if (soap->recv_timeout && !soap->ssl) /* SSL: sockets are nonblocking */
+#else
+ if (soap->recv_timeout)
+#endif
+ { for (;;)
+ { r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout);
+ if (r > 0)
+ break;
+ if (!r)
+ return 0;
+ r = soap->errnum;
+ if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
+ return 0;
+ }
+ }
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ { r = SSL_read(soap->ssl, s, (int)n);
+ if (r > 0)
+ return (size_t)r;
+ err = SSL_get_error(soap->ssl, r);
+ if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE)
+ return 0;
+ }
+ else if (soap->bio)
+ { r = BIO_read(soap->bio, s, (int)n);
+ if (r > 0)
+ return (size_t)r;
+ return 0;
+ }
+ else
+#endif
+ {
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ { SOAP_SOCKLEN_T k = (SOAP_SOCKLEN_T)sizeof(soap->peer);
+ memset((void*)&soap->peer, 0, sizeof(soap->peer));
+ r = recvfrom(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, &k); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */
+ soap->peerlen = (size_t)k;
+#ifndef WITH_IPV6
+ soap->ip = ntohl(soap->peer.sin_addr.s_addr);
+#endif
+ }
+ else
+#endif
+ r = recv(soap->socket, s, (int)n, soap->socket_flags);
+#ifdef PALM
+ /* CycleSyncDisplay(curStatusMsg); */
+#endif
+ if (r >= 0)
+ return (size_t)r;
+ r = soap_socket_errno(soap->socket);
+ if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
+ { soap->errnum = r;
+ return 0;
+ }
+ }
+#ifdef WITH_OPENSSL
+ if (soap->ssl && err == SSL_ERROR_WANT_WRITE)
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5);
+ else
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5);
+#else
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5);
+#endif
+ if (!r && soap->recv_timeout)
+ return 0;
+ if (r < 0)
+ { r = soap->errnum;
+ if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
+ return 0;
+ }
+ if (retries-- <= 0)
+ return 0;
+#ifdef PALM
+ r = soap_socket_errno(soap->socket);
+ if (r != SOAP_EINTR && retries-- <= 0)
+ { soap->errnum = r;
+ return 0;
+ }
+#endif
+ }
+ }
+#ifdef WITH_FASTCGI
+ return fread(s, 1, n, stdin);
+#else
+#ifdef UNDER_CE
+ return fread(s, 1, n, soap->recvfd);
+#else
+#ifdef WMW_RPM_IO
+ if (soap->rpmreqid)
+ r = httpBlockRead(soap->rpmreqid, s, n);
+ else
+#endif
+#ifdef WIN32
+ r = _read(soap->recvfd, s, (unsigned int)n);
+#else
+ r = read(soap->recvfd, s, (unsigned int)n);
+#endif
+ if (r >= 0)
+ return (size_t)r;
+ soap->errnum = soap_errno;
+ return 0;
+#endif
+#endif
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static soap_wchar
+soap_getchunkchar(struct soap *soap)
+{ if (soap->bufidx < soap->buflen)
+ return soap->buf[soap->bufidx++];
+ soap->bufidx = 0;
+ soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, SOAP_BUFLEN);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes from socket %d\n", (unsigned int)soap->buflen, soap->socket));
+ DBGMSG(RECV, soap->buf, soap->buflen);
+ if (soap->buflen)
+ return soap->buf[soap->bufidx++];
+ return EOF;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static int
+soap_isxdigit(int c)
+{ return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_recv_raw(struct soap *soap)
+{ register size_t ret;
+#if !defined(WITH_LEANER) || defined(WITH_ZLIB)
+ register int r;
+#endif
+#ifdef WITH_ZLIB
+ if (soap->mode & SOAP_ENC_ZLIB)
+ { if (soap->d_stream->next_out == Z_NULL)
+ return EOF;
+ if (soap->d_stream->avail_in || !soap->d_stream->avail_out)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n"));
+ soap->d_stream->next_out = (Byte*)soap->buf;
+ soap->d_stream->avail_out = SOAP_BUFLEN;
+ r = inflate(soap->d_stream, Z_NO_FLUSH);
+ if (r == Z_NEED_DICT && soap->z_dict)
+ r = inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len);
+ if (r == Z_OK || r == Z_STREAM_END)
+ { soap->bufidx = 0;
+ ret = soap->buflen = SOAP_BUFLEN - soap->d_stream->avail_out;
+ if (soap->zlib_in == SOAP_ZLIB_GZIP)
+ soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)ret);
+ if (r == Z_STREAM_END)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out));
+ soap->z_ratio_in = (float)soap->d_stream->total_in / (float)soap->d_stream->total_out;
+ soap->d_stream->next_out = Z_NULL;
+ }
+ if (ret)
+ { soap->count += ret;
+ DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- decompressed ----\n"));
+ DBGMSG(RECV, soap->buf, ret);
+ DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n----\n"));
+#ifndef WITH_LEANER
+ if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret)))
+ return soap->error = r;
+#endif
+ return SOAP_OK;
+ }
+ }
+ else if (r != Z_BUF_ERROR)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate error: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
+ soap->d_stream->next_out = Z_NULL;
+ soap->error = SOAP_ZLIB_ERROR;
+ return EOF;
+ }
+ }
+zlib_again:
+ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize)
+ { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN);
+ soap->buflen = soap->z_buflen;
+ }
+ DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- compressed ----\n"));
+ }
+#endif
+#ifndef WITH_NOHTTP
+ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */
+ { for (;;)
+ { register soap_wchar c;
+ char *t, tmp[8];
+ if (soap->chunksize)
+ { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret));
+ DBGMSG(RECV, soap->buf, ret);
+ soap->bufidx = 0;
+ soap->chunksize -= ret;
+ break;
+ }
+ t = tmp;
+ if (!soap->chunkbuflen)
+ { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes (chunked) from socket %d\n", (unsigned int)ret, soap->socket));
+ DBGMSG(RECV, soap->buf, ret);
+ soap->bufidx = 0;
+ if (!ret)
+ return soap->ahead = EOF;
+ }
+ else
+ soap->bufidx = soap->buflen;
+ soap->buflen = soap->chunkbuflen;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk size (idx=%u len=%u)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen));
+ while (!soap_isxdigit((int)(c = soap_getchunkchar(soap))))
+ { if ((int)c == EOF)
+ return soap->ahead = EOF;
+ }
+ do
+ *t++ = (char)c;
+ while (soap_isxdigit((int)(c = soap_getchunkchar(soap))) && t - tmp < 7);
+ while ((int)c != EOF && c != '\n')
+ c = soap_getchunkchar(soap);
+ if ((int)c == EOF)
+ return soap->ahead = EOF;
+ *t = '\0';
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunk size = %s (hex)\n", tmp));
+ soap->chunksize = soap_strtoul(tmp, &t, 16);
+ if (!soap->chunksize)
+ { soap->chunkbuflen = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n"));
+ while ((int)c != EOF && c != '\n')
+ c = soap_getchunkchar(soap);
+ ret = 0;
+ soap->ahead = EOF;
+ break;
+ }
+ soap->buflen = soap->bufidx + soap->chunksize;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving buf len to idx=%u len=%u (%s)\n", (unsigned int)soap->bufidx, (unsigned int)soap->buflen, tmp));
+ if (soap->buflen > soap->chunkbuflen)
+ { soap->buflen = soap->chunkbuflen;
+ soap->chunksize -= soap->buflen - soap->bufidx;
+ soap->chunkbuflen = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Passed end of buffer for chunked HTTP (%u bytes left)\n", (unsigned int)(soap->buflen - soap->bufidx)));
+ }
+ else if (soap->chunkbuflen)
+ soap->chunksize = 0;
+ ret = soap->buflen - soap->bufidx;
+ if (ret)
+ break;
+ }
+ }
+ else
+#endif
+ { soap->bufidx = 0;
+ soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes from socket %d\n", (unsigned int)ret, soap->socket));
+ DBGMSG(RECV, soap->buf, ret);
+ }
+#ifdef WITH_ZLIB
+ if (soap->mode & SOAP_ENC_ZLIB)
+ { memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
+ soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
+ soap->d_stream->avail_in = (unsigned int)ret;
+ soap->d_stream->next_out = (Byte*)soap->buf;
+ soap->d_stream->avail_out = SOAP_BUFLEN;
+ r = inflate(soap->d_stream, Z_NO_FLUSH);
+ if (r == Z_NEED_DICT && soap->z_dict)
+ r = inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len);
+ if (r == Z_OK || r == Z_STREAM_END)
+ { soap->bufidx = 0;
+ soap->z_buflen = soap->buflen;
+ soap->buflen = SOAP_BUFLEN - soap->d_stream->avail_out;
+ if (soap->zlib_in == SOAP_ZLIB_GZIP)
+ soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)soap->buflen));
+ if (ret && !soap->buflen && r != Z_STREAM_END)
+ goto zlib_again;
+ ret = soap->buflen;
+ if (r == Z_STREAM_END)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated total %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out));
+ soap->z_ratio_in = (float)soap->d_stream->total_in / (float)soap->d_stream->total_out;
+ soap->d_stream->next_out = Z_NULL;
+ }
+ DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- decompressed ----\n"));
+ DBGMSG(RECV, soap->buf, ret);
+#ifndef WITH_LEANER
+ if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret)))
+ return soap->error = r;
+#endif
+ }
+ else
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to inflate: (%d) %s\n", r, soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
+ soap->d_stream->next_out = Z_NULL;
+ soap->error = SOAP_ZLIB_ERROR;
+ return EOF;
+ }
+ }
+#endif
+#ifndef WITH_LEANER
+ if (soap->fpreparerecv
+#ifdef WITH_ZLIB
+ && soap->zlib_in == SOAP_ZLIB_NONE
+#endif
+ && (r = soap->fpreparerecv(soap, soap->buf + soap->bufidx, ret)))
+ return soap->error = r;
+#endif
+ soap->count += ret;
+ return !ret;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_recv(struct soap *soap)
+{
+#ifndef WITH_LEANER
+ if (soap->mode & SOAP_ENC_DIME)
+ { if (soap->dime.buflen)
+ { char *s;
+ int i;
+ unsigned char tmp[12];
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME hdr for chunked DIME is in buffer\n"));
+ soap->count += soap->dime.buflen - soap->buflen;
+ soap->buflen = soap->dime.buflen;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Skip padding (%ld bytes)\n", -(long)soap->dime.size&3));
+ for (i = -(long)soap->dime.size&3; i > 0; i--)
+ { soap->bufidx++;
+ if (soap->bufidx >= soap->buflen)
+ if (soap_recv_raw(soap))
+ return EOF;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME hdr for next chunk\n"));
+ s = (char*)tmp;
+ for (i = 12; i > 0; i--)
+ { *s++ = soap->buf[soap->bufidx++];
+ if (soap->bufidx >= soap->buflen)
+ if (soap_recv_raw(soap))
+ return EOF;
+ }
+ soap->dime.flags = tmp[0] & 0x7;
+ soap->dime.size = ((size_t)tmp[8] << 24) | ((size_t)tmp[9] << 16) | ((size_t)tmp[10] << 8) | ((size_t)tmp[11]);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME chunk (%u bytes)\n", (unsigned int)soap->dime.size));
+ if (soap->dime.flags & SOAP_DIME_CF)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "More chunking\n"));
+ soap->dime.chunksize = soap->dime.size;
+ if (soap->buflen - soap->bufidx >= soap->dime.size)
+ { soap->dime.buflen = soap->buflen;
+ soap->buflen = soap->bufidx + soap->dime.chunksize;
+ }
+ else
+ soap->dime.chunksize -= soap->buflen - soap->bufidx;
+ }
+ else
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Last chunk\n"));
+ soap->dime.buflen = 0;
+ soap->dime.chunksize = 0;
+ }
+ soap->count = soap->buflen - soap->bufidx;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%u bytes remaining\n", (unsigned int)soap->count));
+ return SOAP_OK;
+ }
+ if (soap->dime.chunksize)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get next DIME hdr for chunked DIME (%u bytes chunk)\n", (unsigned int)soap->dime.chunksize));
+ if (soap_recv_raw(soap))
+ return EOF;
+ if (soap->buflen - soap->bufidx >= soap->dime.chunksize)
+ { soap->dime.buflen = soap->buflen;
+ soap->count -= soap->buflen - soap->bufidx - soap->dime.chunksize;
+ soap->buflen = soap->bufidx + soap->dime.chunksize;
+ }
+ else
+ soap->dime.chunksize -= soap->buflen - soap->bufidx;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%lu bytes remaining, count=%u\n", (unsigned long)(soap->buflen-soap->bufidx), (unsigned int)soap->count));
+ return SOAP_OK;
+ }
+ }
+#endif
+ return soap_recv_raw(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+soap_wchar
+SOAP_FMAC2
+soap_getchar(struct soap *soap)
+{ register soap_wchar c;
+ c = soap->ahead;
+ if (c)
+ { if (c != EOF)
+ soap->ahead = 0;
+ return c;
+ }
+ return soap_get1(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+const struct soap_code_map*
+SOAP_FMAC2
+soap_code(const struct soap_code_map *code_map, const char *str)
+{ if (code_map && str)
+ { while (code_map->string)
+ { if (!strcmp(str, code_map->string)) /* case sensitive */
+ return code_map;
+ code_map++;
+ }
+ }
+ return NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+long
+SOAP_FMAC2
+soap_code_int(const struct soap_code_map *code_map, const char *str, long other)
+{ if (code_map)
+ { while (code_map->string)
+ { if (!soap_tag_cmp(str, code_map->string)) /* case insensitive */
+ return code_map->code;
+ code_map++;
+ }
+ }
+ return other;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_code_str(const struct soap_code_map *code_map, long code)
+{ if (!code_map)
+ return NULL;
+ while (code_map->code != code && code_map->string)
+ code_map++;
+ return code_map->string;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+long
+SOAP_FMAC2
+soap_code_bits(const struct soap_code_map *code_map, const char *str)
+{ register long bits = 0;
+ if (code_map)
+ { while (str && *str)
+ { const struct soap_code_map *p;
+ for (p = code_map; p->string; p++)
+ { register size_t n = strlen(p->string);
+ if (!strncmp(p->string, str, n) && soap_blank(str[n]))
+ { bits |= p->code;
+ str += n;
+ while (*str > 0 && *str <= 32)
+ str++;
+ break;
+ }
+ }
+ if (!p->string)
+ return 0;
+ }
+ }
+ return bits;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_code_list(struct soap *soap, const struct soap_code_map *code_map, long code)
+{ register char *t = soap->tmpbuf;
+ if (code_map)
+ { while (code_map->string)
+ { if (code_map->code & code)
+ { register const char *s = code_map->string;
+ if (t != soap->tmpbuf)
+ *t++ = ' ';
+ while (*s && t < soap->tmpbuf + sizeof(soap->tmpbuf) - 1)
+ *t++ = *s++;
+ if (t == soap->tmpbuf + sizeof(soap->tmpbuf) - 1)
+ break;
+ }
+ code_map++;
+ }
+ }
+ *t = '\0';
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static soap_wchar
+soap_char(struct soap *soap)
+{ char tmp[8];
+ register int i;
+ register soap_wchar c;
+ register char *s = tmp;
+ for (i = 0; i < 7; i++)
+ { c = soap_get1(soap);
+ if (c == ';' || (int)c == EOF)
+ break;
+ *s++ = (char)c;
+ }
+ *s = '\0';
+ if (*tmp == '#')
+ { if (tmp[1] == 'x' || tmp[1] == 'X')
+ return (soap_wchar)soap_strtol(tmp + 2, NULL, 16);
+ return (soap_wchar)soap_strtol(tmp + 1, NULL, 10);
+ }
+ if (!strcmp(tmp, "lt"))
+ return '<';
+ if (!strcmp(tmp, "gt"))
+ return '>';
+ if (!strcmp(tmp, "amp"))
+ return '&';
+ if (!strcmp(tmp, "quot"))
+ return '"';
+ if (!strcmp(tmp, "apos"))
+ return '\'';
+#ifndef WITH_LEAN
+ return (soap_wchar)soap_code_int(html_entity_codes, tmp, SOAP_UNKNOWN_CHAR);
+#else
+ return SOAP_UNKNOWN_CHAR; /* use this to represent unknown code */
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifdef WITH_LEAN
+#ifndef PALM_1
+soap_wchar
+soap_get0(struct soap *soap)
+{ if (soap->bufidx >= soap->buflen && soap_recv(soap))
+ return EOF;
+ return (unsigned char)soap->buf[soap->bufidx];
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_LEAN
+#ifndef PALM_1
+soap_wchar
+soap_get1(struct soap *soap)
+{ if (soap->bufidx >= soap->buflen && soap_recv(soap))
+ return EOF;
+ return (unsigned char)soap->buf[soap->bufidx++];
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+soap_wchar
+SOAP_FMAC2
+soap_get(struct soap *soap)
+{ register soap_wchar c;
+ c = soap->ahead;
+ if (c)
+ { if ((int)c != EOF)
+ soap->ahead = 0;
+ }
+ else
+ c = soap_get1(soap);
+ while ((int)c != EOF)
+ { if (soap->cdata)
+ { if (c == ']')
+ { c = soap_get1(soap);
+ if (c == ']')
+ { c = soap_get0(soap);
+ if (c == '>')
+ { soap->cdata = 0;
+ soap_get1(soap);
+ c = soap_get1(soap);
+ }
+ else
+ { soap_unget(soap, ']');
+ return ']';
+ }
+ }
+ else
+ { soap_revget1(soap);
+ return ']';
+ }
+ }
+ else
+ return c;
+ }
+ switch (c)
+ { case '<':
+ do c = soap_get1(soap);
+ while (soap_blank(c));
+ if (c == '!' || c == '?' || c == '%')
+ { register int k = 1;
+ if (c == '!')
+ { c = soap_get1(soap);
+ if (c == '[')
+ { do c = soap_get1(soap);
+ while ((int)c != EOF && c != '[');
+ if ((int)c == EOF)
+ break;
+ soap->cdata = 1;
+ c = soap_get1(soap);
+ continue;
+ }
+ if (c == '-' && (c = soap_get1(soap)) == '-')
+ { do
+ { c = soap_get1(soap);
+ if (c == '-' && (c = soap_get1(soap)) == '-')
+ break;
+ } while ((int)c != EOF);
+ }
+ }
+ else if (c == '?')
+ c = soap_get_pi(soap);
+ while ((int)c != EOF)
+ { if (c == '<')
+ k++;
+ else if (c == '>')
+ { if (--k <= 0)
+ break;
+ }
+ c = soap_get1(soap);
+ }
+ if ((int)c == EOF)
+ break;
+ c = soap_get1(soap);
+ continue;
+ }
+ if (c == '/')
+ return SOAP_TT;
+ soap_revget1(soap);
+ return SOAP_LT;
+ case '>':
+ return SOAP_GT;
+ case '"':
+ return SOAP_QT;
+ case '\'':
+ return SOAP_AP;
+ case '&':
+ return soap_char(soap) | 0x80000000;
+ }
+ break;
+ }
+ return c;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static soap_wchar
+soap_get_pi(struct soap *soap)
+{ char buf[64];
+ register char *s = buf;
+ register int i = sizeof(buf);
+ register soap_wchar c = soap_getchar(soap);
+ /* This is a quick way to parse XML PI and we could use a callback instead to
+ * enable applications to intercept processing instructions */
+ while ((int)c != EOF && c != '?')
+ { if (--i > 0)
+ { if (soap_blank(c))
+ c = ' ';
+ *s++ = (char)c;
+ }
+ c = soap_getchar(soap);
+ }
+ *s = '\0';
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "XML PI <?%s?>\n", buf));
+ if (!strncmp(buf, "xml ", 4))
+ { s = strstr(buf, " encoding=");
+ if (s && s[10])
+ { if (!soap_tag_cmp(s + 11, "iso-8859-1*")
+ || !soap_tag_cmp(s + 11, "latin1*"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Switching to latin1 encoding\n"));
+ soap->mode |= SOAP_ENC_LATIN;
+ }
+ else if (!soap_tag_cmp(s + 11, "utf-8*"))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Switching to utf-8 encoding\n"));
+ soap->mode &= ~SOAP_ENC_LATIN;
+ }
+ }
+ }
+ if ((int)c != EOF)
+ c = soap_getchar(soap);
+ return c;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_move(struct soap *soap, long n)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving %ld bytes forward\n", (long)n));
+ for (; n > 0; n--)
+ if ((int)soap_getchar(soap) == EOF)
+ return SOAP_EOF;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+size_t
+SOAP_FMAC2
+soap_tell(struct soap *soap)
+{ return soap->count - soap->buflen + soap->bufidx - (soap->ahead != 0);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_pututf8(struct soap *soap, register unsigned long c)
+{ char tmp[16];
+ if (c < 0x80 && c > 0)
+ { *tmp = (char)c;
+ return soap_send_raw(soap, tmp, 1);
+ }
+#ifndef WITH_LEAN
+ if (c >= 0x80)
+ { register char *t = tmp;
+ if (c < 0x0800)
+ *t++ = (char)(0xC0 | ((c >> 6) & 0x1F));
+ else
+ { if (c < 0x010000)
+ *t++ = (char)(0xE0 | ((c >> 12) & 0x0F));
+ else
+ { if (c < 0x200000)
+ *t++ = (char)(0xF0 | ((c >> 18) & 0x07));
+ else
+ { if (c < 0x04000000)
+ *t++ = (char)(0xF8 | ((c >> 24) & 0x03));
+ else
+ { *t++ = (char)(0xFC | ((c >> 30) & 0x01));
+ *t++ = (char)(0x80 | ((c >> 24) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 18) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 12) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 6) & 0x3F));
+ }
+ *t++ = (char)(0x80 | (c & 0x3F));
+ *t = '\0';
+ }
+#else
+ sprintf(tmp, "&#%lu;", c);
+#endif
+ return soap_send(soap, tmp);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+soap_wchar
+SOAP_FMAC2
+soap_getutf8(struct soap *soap)
+{ register soap_wchar c, c1, c2, c3, c4;
+ c = soap->ahead;
+ if (c > 0x7F)
+ { soap->ahead = 0;
+ return c;
+ }
+ c = soap_get(soap);
+ if (c < 0x80 || (soap->mode & SOAP_ENC_LATIN))
+ return c;
+ c1 = soap_get1(soap);
+ if (c1 < 0x80)
+ { soap_revget1(soap); /* doesn't look like this is UTF8 */
+ return c;
+ }
+ c1 &= 0x3F;
+ if (c < 0xE0)
+ return ((soap_wchar)(c & 0x1F) << 6) | c1;
+ c2 = (soap_wchar)soap_get1(soap) & 0x3F;
+ if (c < 0xF0)
+ return ((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2;
+ c3 = (soap_wchar)soap_get1(soap) & 0x3F;
+ if (c < 0xF8)
+ return ((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3;
+ c4 = (soap_wchar)soap_get1(soap) & 0x3F;
+ if (c < 0xFC)
+ return ((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4;
+ return ((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(soap_get1(soap) & 0x3F);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_puthex(struct soap *soap, const unsigned char *s, int n)
+{ char d[2];
+ register int i;
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { if (!(soap->dom->data = soap_s2hex(soap, s, NULL, n)))
+ return soap->error;
+ return SOAP_OK;
+ }
+#endif
+ for (i = 0; i < n; i++)
+ { register int m = *s++;
+ d[0] = (char)((m >> 4) + (m > 159 ? '7' : '0'));
+ m &= 0x0F;
+ d[1] = (char)(m + (m > 9 ? '7' : '0'));
+ if (soap_send_raw(soap, d, 2))
+ return soap->error;
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+unsigned char*
+SOAP_FMAC2
+soap_gethex(struct soap *soap, int *n)
+{
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { soap->dom->data = soap_string_in(soap, 0, -1, -1);
+ return (unsigned char*)soap_hex2s(soap, soap->dom->data, NULL, 0, n);
+ }
+#endif
+#ifdef WITH_FAST
+ soap->labidx = 0;
+ for (;;)
+ { register char *s;
+ register size_t i, k;
+ if (soap_append_lab(soap, NULL, 0))
+ return NULL;
+ s = soap->labbuf + soap->labidx;
+ k = soap->lablen - soap->labidx;
+ soap->labidx = soap->lablen;
+ for (i = 0; i < k; i++)
+ { register char d1, d2;
+ register soap_wchar c;
+ c = soap_get(soap);
+ if (soap_isxdigit(c))
+ { d1 = (char)c;
+ c = soap_get(soap);
+ if (soap_isxdigit(c))
+ d2 = (char)c;
+ else
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ }
+ else
+ { unsigned char *p;
+ soap_unget(soap, c);
+ if (n)
+ *n = (int)(soap->lablen + i - k);
+ p = (unsigned char*)soap_malloc(soap, soap->lablen + i - k);
+ if (p)
+ memcpy(p, soap->labbuf, soap->lablen + i - k);
+ return p;
+ }
+ *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0');
+ }
+ }
+#else
+ if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (;;)
+ { register int i;
+ register char *s = (char*)soap_push_block(soap, NULL, SOAP_BLKLEN);
+ if (!s)
+ { soap_end_block(soap, NULL);
+ return NULL;
+ }
+ for (i = 0; i < SOAP_BLKLEN; i++)
+ { register char d1, d2;
+ register soap_wchar c = soap_get(soap);
+ if (soap_isxdigit(c))
+ { d1 = (char)c;
+ c = soap_get(soap);
+ if (soap_isxdigit(c))
+ d2 = (char)c;
+ else
+ { soap_end_block(soap, NULL);
+ soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ }
+ else
+ { unsigned char *p;
+ soap_unget(soap, c);
+ if (n)
+ *n = (int)soap_size_block(soap, NULL, i);
+ p = (unsigned char*)soap_save_block(soap, NULL, 0);
+ return p;
+ }
+ *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0');
+ }
+ }
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putbase64(struct soap *soap, const unsigned char *s, int n)
+{ register int i;
+ register unsigned long m;
+ char d[4];
+ if (!s)
+ return SOAP_OK;
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { if (!(soap->dom->data = soap_s2base64(soap, s, NULL, n)))
+ return soap->error;
+ return SOAP_OK;
+ }
+#endif
+ for (; n > 2; n -= 3, s += 3)
+ { m = s[0];
+ m = (m << 8) | s[1];
+ m = (m << 8) | s[2];
+ for (i = 4; i > 0; m >>= 6)
+ d[--i] = soap_base64o[m & 0x3F];
+ if (soap_send_raw(soap, d, 4))
+ return soap->error;
+ }
+ if (n > 0)
+ { m = 0;
+ for (i = 0; i < n; i++)
+ m = (m << 8) | *s++;
+ for (; i < 3; i++)
+ m <<= 8;
+ for (i++; i > 0; m >>= 6)
+ d[--i] = soap_base64o[m & 0x3F];
+ for (i = 3; i > n; i--)
+ d[i] = '=';
+ if (soap_send_raw(soap, d, 4))
+ return soap->error;
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+unsigned char*
+SOAP_FMAC2
+soap_getbase64(struct soap *soap, int *n, int malloc_flag)
+{
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { soap->dom->data = soap_string_in(soap, 0, -1, -1);
+ return (unsigned char*)soap_base642s(soap, soap->dom->data, NULL, 0, n);
+ }
+#endif
+#ifdef WITH_FAST
+ soap->labidx = 0;
+ for (;;)
+ { register size_t i, k;
+ register char *s;
+ if (soap_append_lab(soap, NULL, 2))
+ return NULL;
+ s = soap->labbuf + soap->labidx;
+ k = soap->lablen - soap->labidx;
+ soap->labidx = 3 * (soap->lablen / 3);
+ if (!s)
+ return NULL;
+ if (k > 2)
+ { for (i = 0; i < k - 2; i += 3)
+ { register unsigned long m = 0;
+ register int j = 0;
+ do
+ { register soap_wchar c = soap_get(soap);
+ if (c == '=' || c < 0)
+ { unsigned char *p;
+ switch (j)
+ { case 2:
+ *s++ = (char)((m >> 4) & 0xFF);
+ i++;
+ break;
+ case 3:
+ *s++ = (char)((m >> 10) & 0xFF);
+ *s++ = (char)((m >> 2) & 0xFF);
+ i += 2;
+ }
+ if (n)
+ *n = (int)(soap->lablen + i - k);
+ p = (unsigned char*)soap_malloc(soap, soap->lablen + i - k);
+ if (p)
+ memcpy(p, soap->labbuf, soap->lablen + i - k);
+ if (c >= 0)
+ { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT)
+ ;
+ }
+ soap_unget(soap, c);
+ return p;
+ }
+ c -= '+';
+ if (c >= 0 && c <= 79)
+ { register int b = soap_base64i[c];
+ if (b >= 64)
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ m = (m << 6) + b;
+ j++;
+ }
+ else if (!soap_blank(c + '+'))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ } while (j < 4);
+ *s++ = (char)((m >> 16) & 0xFF);
+ *s++ = (char)((m >> 8) & 0xFF);
+ *s++ = (char)(m & 0xFF);
+ }
+ }
+ }
+#else
+ if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (;;)
+ { register int i;
+ register char *s = (char*)soap_push_block(soap, NULL, 3 * SOAP_BLKLEN); /* must be multiple of 3 */
+ if (!s)
+ { soap_end_block(soap, NULL);
+ return NULL;
+ }
+ for (i = 0; i < SOAP_BLKLEN; i++)
+ { register unsigned long m = 0;
+ register int j = 0;
+ do
+ { register soap_wchar c = soap_get(soap);
+ if (c == '=' || c < 0)
+ { unsigned char *p;
+ i *= 3;
+ switch (j)
+ { case 2:
+ *s++ = (char)((m >> 4) & 0xFF);
+ i++;
+ break;
+ case 3:
+ *s++ = (char)((m >> 10) & 0xFF);
+ *s++ = (char)((m >> 2) & 0xFF);
+ i += 2;
+ }
+ if (n)
+ *n = (int)soap_size_block(soap, NULL, i);
+ p = (unsigned char*)soap_save_block(soap, NULL, 0);
+ if (c >= 0)
+ { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT)
+ ;
+ }
+ soap_unget(soap, c);
+ return p;
+ }
+ c -= '+';
+ if (c >= 0 && c <= 79)
+ { int b = soap_base64i[c];
+ if (b >= 64)
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ m = (m << 6) + b;
+ j++;
+ }
+ else if (!soap_blank(c))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ } while (j < 4);
+ *s++ = (char)((m >> 16) & 0xFF);
+ *s++ = (char)((m >> 8) & 0xFF);
+ *s++ = (char)(m & 0xFF);
+ }
+ }
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_xop_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options)
+{ /* Check MTOM xop:Include element (within hex/base64Binary) */
+ /* TODO: this code to be obsoleted with new import/xop.h conventions */
+ int body = soap->body; /* should save type too? */
+ if (!soap_peek_element(soap))
+ { if (!soap_element_begin_in(soap, "xop:Include", 0, NULL) && *soap->href)
+ { if (soap_dime_forward(soap, ptr, size, id, type, options))
+ return soap->error;
+ }
+ if (soap->body && soap_element_end_in(soap, NULL))
+ return soap->error;
+ }
+ soap->body = body;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_dime_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options)
+{ struct soap_xlist *xp;
+ *ptr = NULL;
+ *size = 0;
+ *id = NULL;
+ *type = NULL;
+ *options = NULL;
+ if (!*soap->href)
+ return SOAP_OK;
+ *id = soap_strdup(soap, soap->href);
+ xp = (struct soap_xlist*)SOAP_MALLOC(soap, sizeof(struct soap_xlist));
+ if (!xp)
+ return soap->error = SOAP_EOM;
+ xp->next = soap->xlist;
+ xp->ptr = ptr;
+ xp->size = size;
+ xp->id = *id;
+ xp->type = type;
+ xp->options = options;
+ soap->xlist = xp;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_strdup(struct soap *soap, const char *s)
+{ char *t = NULL;
+ if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1)))
+ strcpy(t, s);
+ return t;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+wchar_t *
+SOAP_FMAC2
+soap_wstrdup(struct soap *soap, const wchar_t *s)
+{ wchar_t *t = NULL;
+ if (s)
+ { size_t n = 0;
+ while (s[n])
+ n++;
+ if ((t = (wchar_t*)soap_malloc(soap, sizeof(wchar_t)*(n+1))))
+ memcpy(t, s, sizeof(wchar_t)*(n+1));
+ }
+ return t;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap_blist*
+SOAP_FMAC2
+soap_new_block(struct soap *soap)
+{ struct soap_blist *p;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist));
+ if (!(p = (struct soap_blist*)SOAP_MALLOC(soap, sizeof(struct soap_blist))))
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ p->next = soap->blist;
+ p->ptr = NULL;
+ p->size = 0;
+ soap->blist = p;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void*
+SOAP_FMAC2
+soap_push_block(struct soap *soap, struct soap_blist *b, size_t n)
+{ char *p;
+ if (!b)
+ b = soap->blist;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)b->size + (unsigned int)n));
+ if (!(p = (char*)SOAP_MALLOC(soap, n + sizeof(char*) + sizeof(size_t))))
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ *(char**)p = b->ptr;
+ *(size_t*)(p + sizeof(char*)) = n;
+ b->ptr = p;
+ b->size += n;
+ return p + sizeof(char*) + sizeof(size_t);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_pop_block(struct soap *soap, struct soap_blist *b)
+{ char *p;
+ if (!b)
+ b = soap->blist;
+ if (!b->ptr)
+ return;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n"));
+ p = b->ptr;
+ b->size -= *(size_t*)(p + sizeof(char*));
+ b->ptr = *(char**)p;
+ SOAP_FREE(soap, p);
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+static void
+soap_update_ptrs(struct soap *soap, char *start, char *end, char *p1, char *p2)
+{ int i;
+ register struct soap_ilist *ip = NULL;
+ register struct soap_flist *fp = NULL;
+#ifndef WITH_LEANER
+ register struct soap_xlist *xp = NULL;
+#endif
+ register void *p, **q;
+ for (i = 0; i < SOAP_IDHASH; i++)
+ { for (ip = soap->iht[i]; ip; ip = ip->next)
+ { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", ip->id, ip->ptr, (char*)ip->ptr + (p1-p2)));
+ ip->ptr = (char*)ip->ptr + (p1-p2);
+ }
+ for (q = &ip->link; q; q = (void**)p)
+ { p = *q;
+ if (p && (char*)p >= start && (char*)p < end)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p));
+ *q = (char*)p + (p1-p2);
+ }
+ }
+ for (q = &ip->copy; q; q = (void**)p)
+ { p = *q;
+ if (p && (char*)p >= start && (char*)p < end)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy chain update id='%s' %p\n", ip->id, p));
+ *q = (char*)p + (p1-p2);
+ }
+ }
+ for (fp = ip->flist; fp; fp = fp->next)
+ { if ((char*)fp->ptr >= start && (char*)fp->ptr < end)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy list update id='%s' %p\n", ip->id, fp));
+ fp->ptr = (char*)fp->ptr + (p1-p2);
+ }
+ }
+ }
+ }
+#ifndef WITH_LEANER
+ for (xp = soap->xlist; xp; xp = xp->next)
+ { if (xp->ptr && (char*)xp->ptr >= start && (char*)xp->ptr < end)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", xp->id?xp->id:SOAP_STR_EOS, xp->ptr, (char*)xp->ptr + (p1-p2)));
+ xp->ptr = (unsigned char**)((char*)xp->ptr + (p1-p2));
+ xp->size = (int*)((char*)xp->size + (p1-p2));
+ xp->type = (char**)((char*)xp->type + (p1-p2));
+ xp->options = (char**)((char*)xp->options + (p1-p2));
+ }
+ }
+#endif
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+static int
+soap_has_copies(struct soap *soap, register const char *start, register const char *end)
+{ register int i;
+ register struct soap_ilist *ip = NULL;
+ register struct soap_flist *fp = NULL;
+ register const char *p;
+ for (i = 0; i < SOAP_IDHASH; i++)
+ { for (ip = soap->iht[i]; ip; ip = ip->next)
+ { for (p = (const char*)ip->copy; p; p = *(const char**)p)
+ if (p >= start && p < end)
+ return SOAP_ERR;
+ for (fp = ip->flist; fp; fp = fp->next)
+ if ((const char*)fp->ptr >= start && (const char*)fp->ptr < end)
+ return SOAP_ERR;
+ }
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_resolve(struct soap *soap)
+{ register int i;
+ register struct soap_ilist *ip = NULL;
+ register struct soap_flist *fp = NULL;
+ short flag;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n"));
+ for (i = 0; i < SOAP_IDHASH; i++)
+ { for (ip = soap->iht[i]; ip; ip = ip->next)
+ { if (ip->ptr)
+ { register void *p, **q, *r;
+ q = (void**)ip->link;
+ ip->link = NULL;
+ r = ip->ptr;
+ DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s'\n", ip->id));
+ while (q)
+ { p = *q;
+ *q = r;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, r));
+ q = (void**)p;
+ }
+ }
+ else if (*ip->id == '#')
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Missing data for id='%s'\n", ip->id));
+ /* Oracle customization */
+ strncpy(soap->id, ip->id + 1, sizeof(soap->id) - 1);
+ soap->id[sizeof(soap->id) - 1] = '\0';
+ return soap->error = SOAP_MISSING_ID;
+ }
+ }
+ }
+ do
+ { flag = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution phase\n"));
+ for (i = 0; i < SOAP_IDHASH; i++)
+ { for (ip = soap->iht[i]; ip; ip = ip->next)
+ { if (ip->ptr && !soap_has_copies(soap, (const char*)ip->ptr, (const char*)ip->ptr + ip->size))
+ { if (ip->copy)
+ { register void *p, **q = (void**)ip->copy;
+ DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id));
+ ip->copy = NULL;
+ do
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size));
+ p = *q;
+ memcpy(q, ip->ptr, ip->size);
+ q = (void**)p;
+ } while (q);
+ flag = 1;
+ }
+ for (fp = ip->flist; fp; fp = ip->flist)
+ { register unsigned int k = fp->level;
+ register void *p = ip->ptr;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data type=%d location=%p level=%u,%u id='%s'\n", ip->type, p, ip->level, fp->level, ip->id));
+ while (ip->level < k)
+ { register void **q = (void**)soap_malloc(soap, sizeof(void*));
+ if (!q)
+ return soap->error;
+ *q = p;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level, new location=%p holds=%p...\n", q, *q));
+ p = (void*)q;
+ k--;
+ }
+ if (fp->fcopy)
+ fp->fcopy(soap, ip->type, fp->type, fp->ptr, fp->len, p, ip->size);
+ else
+ soap_fcopy(soap, ip->type, fp->type, fp->ptr, fp->len, p, ip->size);
+ ip->flist = fp->next;
+ SOAP_FREE(soap, fp);
+ flag = 1;
+ }
+ }
+ }
+ }
+ } while (flag);
+#ifdef SOAP_DEBUG
+ for (i = 0; i < SOAP_IDHASH; i++)
+ { for (ip = soap->iht[i]; ip; ip = ip->next)
+ { if (ip->copy || ip->flist)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution error: forwarded data for id='%s' could not be propagated, please report this problem to the developers\n", ip->id));
+ }
+ }
+ }
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution done\n"));
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+size_t
+SOAP_FMAC2
+soap_size_block(struct soap *soap, struct soap_blist *b, size_t n)
+{ if (!b)
+ b = soap->blist;
+ if (b->ptr)
+ { b->size -= *(size_t*)(b->ptr + sizeof(char*)) - n;
+ *(size_t*)(b->ptr + sizeof(char*)) = n;
+ }
+ return b->size;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_first_block(struct soap *soap, struct soap_blist *b)
+{ char *p, *q, *r;
+ if (!b)
+ b = soap->blist;
+ p = b->ptr;
+ if (!p)
+ return NULL;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n"));
+ r = NULL;
+ do
+ { q = *(char**)p;
+ *(char**)p = r;
+ r = p;
+ p = q;
+ } while (p);
+ b->ptr = r;
+ return r + sizeof(char*) + sizeof(size_t);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_next_block(struct soap *soap, struct soap_blist *b)
+{ char *p;
+ if (!b)
+ b = soap->blist;
+ p = b->ptr;
+ if (p)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n"));
+ b->ptr = *(char**)p;
+ SOAP_FREE(soap, p);
+ if (b->ptr)
+ return b->ptr + sizeof(char*) + sizeof(size_t);
+ }
+ return NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+size_t
+SOAP_FMAC2
+soap_block_size(struct soap *soap, struct soap_blist *b)
+{ if (!b)
+ b = soap->blist;
+ return *(size_t*)(b->ptr + sizeof(char*));
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_end_block(struct soap *soap, struct soap_blist *b)
+{ char *p, *q;
+ if (!b)
+ b = soap->blist;
+ if (b)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n"));
+ for (p = b->ptr; p; p = q)
+ { q = *(char**)p;
+ SOAP_FREE(soap, p);
+ }
+ if (soap->blist == b)
+ soap->blist = b->next;
+ else
+ { struct soap_blist *bp;
+ for (bp = soap->blist; bp; bp = bp->next)
+ { if (bp->next == b)
+ { bp->next = b->next;
+ break;
+ }
+ }
+ }
+ SOAP_FREE(soap, b);
+ }
+ DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n"));
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_save_block(struct soap *soap, struct soap_blist *b, char *p, int flag)
+{ register size_t n;
+ register char *q, *s;
+ if (!b)
+ b = soap->blist;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)b->size, b->ptr, p));
+ if (b->size)
+ { if (!p)
+ p = (char*)soap_malloc(soap, b->size);
+ if (p)
+ { for (s = p, q = soap_first_block(soap, b); q; q = soap_next_block(soap, b))
+ { n = soap_block_size(soap, b);
+#ifndef WITH_NOIDREF
+ if (flag)
+ soap_update_ptrs(soap, q, q + n, s, q);
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s));
+ memcpy(s, q, n);
+ s += n;
+ }
+ }
+ else
+ soap->error = SOAP_EOM;
+ }
+ soap_end_block(soap, b);
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_putsize(struct soap *soap, const char *type, int size)
+{ return soap_putsizes(soap, type, &size, 1);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_putsizes(struct soap *soap, const char *type, const int *size, int dim)
+{ return soap_putsizesoffsets(soap, type, size, NULL, dim);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim)
+{ int i;
+ if (!type)
+ return NULL;
+ if (soap->version == 2)
+ { sprintf(soap->type, "%s[%d", type, size[0]);
+ for (i = 1; i < dim; i++)
+ sprintf(soap->type + strlen(soap->type), " %d", size[i]);
+ }
+ else
+ { if (offset)
+ { sprintf(soap->type, "%s[%d", type, size[0] + offset[0]);
+ for (i = 1; i < dim; i++)
+ sprintf(soap->type + strlen(soap->type), ",%d", size[i] + offset[i]);
+ }
+ else
+ { sprintf(soap->type, "%s[%d", type, size[0]);
+ for (i = 1; i < dim; i++)
+ sprintf(soap->type + strlen(soap->type), ",%d", size[i]);
+ }
+ strcat(soap->type, "]");
+ }
+ return soap->type;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_putoffset(struct soap *soap, int offset)
+{ return soap_putoffsets(soap, &offset, 1);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_putoffsets(struct soap *soap, const int *offset, int dim)
+{ register int i;
+ sprintf(soap->arrayOffset, "[%d", offset[0]);
+ for (i = 1; i < dim; i++)
+ sprintf(soap->arrayOffset + strlen(soap->arrayOffset), ",%d", offset[i]);
+ strcat(soap->arrayOffset, "]");
+ return soap->arrayOffset;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_size(const int *size, int dim)
+{ register int i, n = size[0];
+ for (i = 1; i < dim; i++)
+ n *= size[i];
+ return n;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getoffsets(const char *attr, const int *size, int *offset, int dim)
+{ register int i, j = 0;
+ if (offset)
+ for (i = 0; i < dim && attr && *attr; i++)
+ { attr++;
+ j *= size[i];
+ j += offset[i] = (int)soap_strtol(attr, NULL, 10);
+ attr = strchr(attr, ',');
+ }
+ else
+ for (i = 0; i < dim && attr && *attr; i++)
+ { attr++;
+ j *= size[i];
+ j += (int)soap_strtol(attr, NULL, 10);
+ attr = strchr(attr, ',');
+ }
+ return j;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getsize(const char *attr1, const char *attr2, int *j)
+{ register int n, k;
+ char *s;
+ *j = 0;
+ if (!*attr1)
+ return -1;
+ if (*attr1 == '[')
+ attr1++;
+ n = 1;
+ for (;;)
+ { k = (int)soap_strtol(attr1, &s, 10);
+ n *= k;
+ if (k < 0 || n > SOAP_MAXARRAYSIZE || s == attr1)
+ return -1;
+ attr1 = strchr(s, ',');
+ if (!attr1)
+ attr1 = strchr(s, ' ');
+ if (attr2 && *attr2)
+ { attr2++;
+ *j *= k;
+ k = (int)soap_strtol(attr2, &s, 10);
+ *j += k;
+ if (k < 0)
+ return -1;
+ attr2 = s;
+ }
+ if (!attr1)
+ break;
+ attr1++;
+ }
+ return n - *j;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getsizes(const char *attr, int *size, int dim)
+{ register int i, k, n;
+ if (!*attr)
+ return -1;
+ i = (int)strlen(attr);
+ n = 1;
+ do
+ { for (i = i-1; i >= 0; i--)
+ if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ')
+ break;
+ k = (int)soap_strtol(attr + i + 1, NULL, 10);
+ n *= size[--dim] = k;
+ if (k < 0 || n > SOAP_MAXARRAYSIZE)
+ return -1;
+ } while (i >= 0 && attr[i] != '[');
+ return n;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getposition(const char *attr, int *pos)
+{ register int i, n;
+ if (!*attr)
+ return -1;
+ n = 0;
+ i = 1;
+ do
+ { pos[n++] = (int)soap_strtol(attr + i, NULL, 10);
+ while (attr[i] && attr[i] != ',' && attr[i] != ']')
+ i++;
+ if (attr[i] == ',')
+ i++;
+ } while (n < SOAP_MAXDIMS && attr[i] && attr[i] != ']');
+ return n;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+struct soap_nlist *
+SOAP_FMAC2
+soap_push_namespace(struct soap *soap, const char *id, const char *ns)
+{ register struct soap_nlist *np;
+ register struct Namespace *p;
+ register short i = -1;
+ register size_t n, k;
+ n = strlen(id);
+ k = strlen(ns) + 1;
+ p = soap->local_namespaces;
+ if (p)
+ { for (i = 0; p->id; p++, i++)
+ { if (p->ns && !strcmp(ns, p->ns))
+ { if (p->out)
+ { SOAP_FREE(soap, p->out);
+ p->out = NULL;
+ }
+ break;
+ }
+ if (p->out)
+ { if (!strcmp(ns, p->out))
+ break;
+ }
+ else if (p->in)
+ { if (!soap_tag_cmp(ns, p->in))
+ { if ((p->out = (char*)SOAP_MALLOC(soap, k)))
+ strcpy(p->out, ns);
+ break;
+ }
+ }
+ }
+ if (!p || !p->id)
+ i = -1;
+ }
+ if (i >= 0)
+ k = 0;
+ np = (struct soap_nlist*)SOAP_MALLOC(soap, sizeof(struct soap_nlist) + n + k);
+ if (!np)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ np->next = soap->nlist;
+ soap->nlist = np;
+ np->level = soap->level;
+ np->index = i;
+ strcpy(np->id, id);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns));
+ if (i < 0)
+ { np->ns = strcpy(np->id + n + 1, ns);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns));
+ }
+ else
+ { np->ns = NULL;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push OK ('%s' matches '%s' in namespace table)\n", id, p->id));
+ }
+ return np;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_pop_namespace(struct soap *soap)
+{ register struct soap_nlist *np, *nq;
+ for (np = soap->nlist; np && np->level >= soap->level; np = nq)
+ { nq = np->next;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop namespace binding (level=%u) '%s'\n", soap->level, np->id));
+ SOAP_FREE(soap, np);
+ }
+ soap->nlist = np;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_match_namespace(struct soap *soap, const char *id1, const char *id2, size_t n1, size_t n2)
+{ register struct soap_nlist *np = soap->nlist;
+ while (np && (strncmp(np->id, id1, n1) || np->id[n1]))
+ np = np->next;
+ if (np)
+ { if (!(soap->mode & SOAP_XML_IGNORENS))
+ if (np->index < 0
+ || (soap->local_namespaces[np->index].id
+ && (strncmp(soap->local_namespaces[np->index].id, id2, n2)
+ || soap->local_namespaces[np->index].id[n2])))
+ return SOAP_NAMESPACE;
+ return SOAP_OK;
+ }
+ if (n1 == 0)
+ return SOAP_NAMESPACE;
+ if ((n1 == 3 && n1 == n2 && !strncmp(id1, "xml", 3) && !strncmp(id1, id2, 3))
+ || (soap->mode & SOAP_XML_IGNORENS))
+ return SOAP_OK;
+ return soap->error = SOAP_SYNTAX_ERROR;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_current_namespace(struct soap *soap, const char *tag)
+{ register struct soap_nlist *np;
+ register const char *s;
+ if (!tag || !strncmp(tag, "xml", 3))
+ return NULL;
+ np = soap->nlist;
+ if (!(s = strchr(tag, ':')))
+ { while (np && *np->id) /* find default namespace, if present */
+ np = np->next;
+ }
+ else
+ { while (np && (strncmp(np->id, tag, s - tag) || np->id[s - tag]))
+ np = np->next;
+ if (!np)
+ soap->error = SOAP_NAMESPACE;
+ }
+ if (np)
+ { if (np->index >= 0)
+ return soap->namespaces[np->index].ns;
+ if (np->ns)
+ return soap_strdup(soap, np->ns);
+ }
+ return NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_tag_cmp(const char *s, const char *t)
+{ for (;;)
+ { register int c1 = *s;
+ register int c2 = *t;
+ if (!c1 || c1 == '"')
+ break;
+ if (c2 != '-')
+ { if (c1 != c2)
+ { if (c1 >= 'A' && c1 <= 'Z')
+ c1 += 'a' - 'A';
+ if (c2 >= 'A' && c2 <= 'Z')
+ c2 += 'a' - 'A';
+ }
+ if (c1 != c2)
+ { if (c2 != '*')
+ return 1;
+ c2 = *++t;
+ if (!c2)
+ return 0;
+ if (c2 >= 'A' && c2 <= 'Z')
+ c2 += 'a' - 'A';
+ for (;;)
+ { c1 = *s;
+ if (!c1 || c1 == '"')
+ break;
+ if (c1 >= 'A' && c1 <= 'Z')
+ c1 += 'a' - 'A';
+ if (c1 == c2 && !soap_tag_cmp(s + 1, t + 1))
+ return 0;
+ s++;
+ }
+ break;
+ }
+ }
+ s++;
+ t++;
+ }
+ if (*t == '*' && !t[1])
+ return 0;
+ return *t;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_match_tag(struct soap *soap, const char *tag1, const char *tag2)
+{ register const char *s, *t;
+ register int err;
+ if (!tag1 || !tag2 || !*tag2)
+ return SOAP_OK;
+ s = strchr(tag1, ':');
+ t = strchr(tag2, ':');
+ if (t)
+ { if (s)
+ { if (t[1] && SOAP_STRCMP(s + 1, t + 1))
+ return SOAP_TAG_MISMATCH;
+ if (t != tag2 && (err = soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2)))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2));
+ if (err == SOAP_NAMESPACE)
+ return SOAP_TAG_MISMATCH;
+ return err;
+ }
+ }
+ else if (SOAP_STRCMP(tag1, t + 1))
+ { return SOAP_TAG_MISMATCH;
+ }
+ else if (t != tag2 && (err = soap_match_namespace(soap, tag1, tag2, 0, t - tag2)))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2));
+ if (err == SOAP_NAMESPACE)
+ return SOAP_TAG_MISMATCH;
+ return err;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags and (default) namespaces match: '%s' '%s'\n", tag1, tag2));
+ return SOAP_OK;
+ }
+ if (s)
+ { if (SOAP_STRCMP(s + 1, tag2))
+ return SOAP_TAG_MISMATCH;
+ }
+ else if (SOAP_STRCMP(tag1, tag2))
+ return SOAP_TAG_MISMATCH;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags match: '%s' '%s'\n", tag1, tag2));
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_match_array(struct soap *soap, const char *type)
+{ if (*soap->arrayType)
+ if (soap_match_tag(soap, soap->arrayType, type)
+ && soap_match_tag(soap, soap->arrayType, "xsd:anyType")
+ && soap_match_tag(soap, soap->arrayType, "xsd:ur-type")
+ )
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array type mismatch: '%s' '%s'\n", soap->arrayType, type));
+ return SOAP_TAG_MISMATCH;
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************\
+ *
+ * SSL/TLS
+ *
+\******************************************************************************/
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_rand()
+{ unsigned char buf[4];
+ if (!soap_ssl_init_done)
+ soap_ssl_init();
+ RAND_pseudo_bytes(buf, 4);
+ return *(int*)buf;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid)
+{ int err;
+ soap->keyfile = keyfile;
+ soap->password = password;
+ soap->cafile = cafile;
+ soap->capath = capath;
+ soap->crlfile = NULL;
+ soap->dhfile = dhfile;
+ soap->randfile = randfile;
+ soap->ssl_flags = flags | (dhfile == NULL ? SOAP_SSL_RSA : 0);
+ if (!(err = soap->fsslauth(soap)))
+ { if (sid)
+ SSL_CTX_set_session_id_context(soap->ctx, (unsigned char*)sid, (unsigned int)strlen(sid));
+ else
+ SSL_CTX_set_session_cache_mode(soap->ctx, SSL_SESS_CACHE_OFF);
+ }
+ return err;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *randfile)
+{ soap->keyfile = keyfile;
+ soap->password = password;
+ soap->cafile = cafile;
+ soap->capath = capath;
+ soap->dhfile = NULL;
+ soap->ssl_flags = flags;
+ soap->randfile = randfile;
+ soap->fsslverify = (flags & SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE) == 0 ? ssl_verify_callback : ssl_verify_callback_allow_expired_certificate;
+ return soap->fsslauth(soap);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_ssl_init()
+{ /* Note: for MT systems, the main program MUST call soap_ssl_init() before any threads are started */
+ if (!soap_ssl_init_done)
+ { soap_ssl_init_done = 1;
+ SSL_library_init();
+#ifndef WITH_LEAN
+ SSL_load_error_strings();
+#endif
+ if (!RAND_load_file("/dev/urandom", 1024))
+ { char buf[1024];
+ RAND_seed(buf, sizeof(buf));
+ while (!RAND_status())
+ { int r = rand();
+ RAND_seed(&r, sizeof(int));
+ }
+ }
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_1
+SOAP_FMAC1
+const char *
+SOAP_FMAC2
+soap_ssl_error(struct soap *soap, int ret)
+{ int err = SSL_get_error(soap->ssl, ret);
+ const char *msg = soap_code_str(h_ssl_error_codes, err);
+ size_t msgbufsize = sizeof(soap->msgbuf);
+ if (msg)
+ { /* Oracle customization */
+ strncpy(soap->msgbuf, msg, msgbufsize - 1);
+ soap->msgbuf[msgbufsize - 1] = '\0';
+ }
+ else
+ return ERR_error_string(err, soap->msgbuf);
+ if (ERR_peek_error())
+ { unsigned long r;
+ /* Oracle customization */
+ if (strlen(soap->msgbuf) < (msgbufsize-1))
+ strcat(soap->msgbuf, "\n");
+ else
+ soap->msgbuf[msgbufsize - 2] = '\n';
+ while ((r = ERR_get_error()))
+ ERR_error_string_n(r, soap->msgbuf + strlen(soap->msgbuf), sizeof(soap->msgbuf) - strlen(soap->msgbuf));
+ }
+ else
+ { switch (ret)
+ { case 0:
+ {
+ /* Oracle customization -- display SSL error code and string at the end */
+ int myerrno = errno;
+ unsigned long ec = ERR_get_error();
+ sprintf(soap->msgbuf,
+ "EOF was observed that violates the protocol. The client probably provided invalid authentication information. SSL error code is %s. ",
+ msg);
+ if (ec != 0)
+ {
+ /* display the next error string in the error queue */
+ ERR_error_string_n(ec, soap->msgbuf + strlen(soap->msgbuf),
+ sizeof(soap->msgbuf) - strlen(soap->msgbuf));
+ if (sizeof(soap->msgbuf) - strlen(soap->msgbuf) > 2)
+ {
+ strcat(soap->msgbuf, ". ");
+ }
+ }
+ if (myerrno != 0)
+ {
+ /* display system error too */
+ char *mystrerror = strerror(myerrno);
+ if (strlen(mystrerror)
+ < (sizeof(soap->msgbuf) - strlen(soap->msgbuf)))
+ {
+ strncat(soap->msgbuf + strlen(soap->msgbuf), mystrerror,
+ strlen(mystrerror));
+ }
+ else
+ {
+ strncat(soap->msgbuf + strlen(soap->msgbuf), mystrerror,
+ (sizeof(soap->msgbuf) - strlen(soap->msgbuf)));
+ }
+ soap->msgbuf[sizeof(soap->msgbuf) - 1] = '\0';
+ }
+ }
+ break;
+ case -1:
+ sprintf(soap->msgbuf, "Error observed by underlying BIO: %s", strerror(errno));
+ break;
+ }
+ }
+ return soap->msgbuf;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_1
+static int
+ssl_password(char *buf, int num, int rwflag, void *userdata)
+{ if (num < (int)strlen((char*)userdata) + 1)
+ return 0;
+ return (int)strlen(strcpy(buf, (char*)userdata));
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_1
+/*
+static int
+*/
+int
+ssl_auth_init(struct soap *soap)
+{ long flags;
+ int mode;
+ if (!soap_ssl_init_done)
+ soap_ssl_init();
+ ERR_clear_error();
+ if (!soap->ctx)
+ { if (!(soap->ctx = SSL_CTX_new(SSLv23_method())))
+ return soap_set_receiver_error(soap, "SSL error", "Can't setup context", SOAP_SSL_ERROR);
+ /* The following alters the behavior of SSL read/write: */
+#if 0
+ SSL_CTX_set_mode(soap->ctx, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_AUTO_RETRY);
+#endif
+ }
+ //
+ // Oracle customization
+ //
+ // added SSL_CTX_set_cipher_list call to restrict the cipher suite to RSA-2048/AES
+ // TLS_RSA_WITH_AES_256_CBC_SHA is defined in RFC 3268
+ // also see http://www.openssl.org/docs/apps/ciphers.html
+ //
+ if (!SSL_CTX_set_cipher_list(soap->ctx, "AES256-SHA"))
+ return soap_set_receiver_error(soap, "SSL error", "Cannot set cipher suite", SOAP_SSL_ERROR);
+ if (soap->randfile)
+ { if (!RAND_load_file(soap->randfile, -1))
+ return soap_set_receiver_error(soap, "SSL error", "Can't load randomness", SOAP_SSL_ERROR);
+ }
+ if (soap->cafile || soap->capath)
+ { if (!SSL_CTX_load_verify_locations(soap->ctx, soap->cafile, soap->capath))
+ return soap_set_receiver_error(soap, "SSL error", "Can't read CA file and directory", SOAP_SSL_ERROR);
+ if (soap->cafile && (soap->ssl_flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION))
+ SSL_CTX_set_client_CA_list(soap->ctx, SSL_load_client_CA_file(soap->cafile));
+ }
+ if (!(soap->ssl_flags & SOAP_SSL_NO_DEFAULT_CA_PATH))
+ { if (!SSL_CTX_set_default_verify_paths(soap->ctx))
+ return soap_set_receiver_error(soap, "SSL error", "Can't read default CA file and/or directory", SOAP_SSL_ERROR);
+ }
+/* This code assumes a typical scenario, see alternative code below */
+ if (soap->keyfile)
+ { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile))
+ return soap_set_receiver_error(soap, "SSL error", "Can't read certificate key file", SOAP_SSL_ERROR);
+ if (soap->password)
+ { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password);
+ SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password);
+ }
+ if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM))
+ return soap_set_receiver_error(soap, "SSL error", "Can't read key file", SOAP_SSL_ERROR);
+ }
+/* Suggested alternative approach to check the key file for certs (cafile=NULL):*/
+#if 0
+ if (soap->password)
+ { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password);
+ SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password);
+ }
+ if (!soap->cafile || !SSL_CTX_use_certificate_chain_file(soap->ctx, soap->cafile))
+ { if (soap->keyfile)
+ { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile))
+ return soap_set_receiver_error(soap, "SSL error", "Can't read certificate or key file", SOAP_SSL_ERROR);
+ if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM))
+ return soap_set_receiver_error(soap, "SSL error", "Can't read key file", SOAP_SSL_ERROR);
+ }
+ }
+#endif
+ if ((soap->ssl_flags & SOAP_SSL_RSA))
+ {
+ /*
+ Oracle customization for OpenSSL 0.9.8 removal of deprecated function usage: RSA_generate_key
+ */
+#ifdef OPENSSL_NO_DEPRECATED
+ RSA *rsa = RSA_new();
+ if (!rsa)
+ {
+ return soap_set_receiver_error(soap, "SSL error", "Can't allocate RSA struct", SOAP_SSL_ERROR);
+ }
+
+ BIGNUM *e = BN_new();
+ if (!e)
+ {
+ RSA_free(rsa);
+ return soap_set_receiver_error(soap, "SSL error", "Can't allocate BIGNUM", SOAP_SSL_ERROR);
+ }
+ if (!BN_set_word(e, RSA_F4 ))
+ {
+ RSA_free(rsa);
+ BN_free(e);
+ return soap_set_receiver_error(soap, "SSL error", "Can't set BIGNUM value", SOAP_SSL_ERROR);
+ }
+
+#if OPENSSL_VERSION_NUMBER > 0x00908000L
+ if (!RSA_generate_key_ex(rsa, 1024, e, NULL))
+#else
+ if (( rsa = RSA_generate_key(1024, RSA_F4, NULL, NULL)) == NULL )
+#endif
+ {
+ RSA_free(rsa);
+ BN_free(e);
+ return soap_set_receiver_error(soap, "SSL error", "Can't set RSA key", SOAP_SSL_ERROR);
+ }
+
+#else
+ RSA *rsa = RSA_generate_key(1024, RSA_F4, NULL, NULL);
+#endif
+ if (!SSL_CTX_set_tmp_rsa(soap->ctx, rsa))
+ { if (rsa)
+ RSA_free(rsa);
+/*
+ Oracle customization for OpenSSL 0.9.8 removal of deprecated function usage: RSA_generate_key
+*/
+#ifdef OPENSSL_NO_DEPRECATED
+ BN_free(e);
+#endif
+ return soap_set_receiver_error(soap, "SSL error", "Can't set RSA key", SOAP_SSL_ERROR);
+ }
+ RSA_free(rsa);
+/*
+ Oracle customization for OpenSSL 0.9.8 removal of deprecated function usage: RSA_generate_key
+*/
+#ifdef OPENSSL_NO_DEPRECATED
+ BN_free(e);
+#endif
+ }
+ else if (soap->dhfile)
+ {
+ DH *dh = 0;
+#ifdef OPENSSL_NO_DEPRECATED
+ DH dhrec;
+#endif
+ char *s;
+ int n = (int)soap_strtoul(soap->dhfile, &s, 10);
+ /* if dhfile is numeric, treat it as a key length to generate DH params which can take a while */
+ if (n >= 512 && s && *s == '\0') {
+#if !defined(OPENSSL_NO_DEPRECATED) || OPENSSL_VERSION_NUMBER < 0x00908000L
+ dh = DH_generate_parameters(n, 2/*or 5*/, NULL, NULL);
+#else
+ if (DH_generate_parameters_ex(&dhrec, n, 2/*or 5*/, NULL) == 0)
+ dh = &dhrec;
+ else
+ return soap_set_receiver_error(soap, "SSL error", "Can't compute DH params", SOAP_SSL_ERROR);
+#endif
+ }
+ else
+ { BIO *bio;
+ bio = BIO_new_file(soap->dhfile, "r");
+ if (!bio)
+ return soap_set_receiver_error(soap, "SSL error", "Can't read DH file", SOAP_SSL_ERROR);
+ dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
+ BIO_free(bio);
+ }
+ if (!dh || DH_check(dh, &n) != 1 || SSL_CTX_set_tmp_dh(soap->ctx, dh) < 0)
+ {
+#ifndef OPENSSL_NO_DEPRECATED
+ if (dh)
+ DH_free(dh);
+#endif
+ return soap_set_receiver_error(soap, "SSL error", "Can't set DH parameters", SOAP_SSL_ERROR);
+ }
+#ifndef OPENSSL_NO_DEPRECATED
+ DH_free(dh);
+#endif
+ }
+
+ //
+ // Oracle customization
+ //
+ // Added SSL_OP_NO_SSLv3 to force use of TLS
+ // Added SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG to prevent forced downgrade
+ // of security level
+
+ flags = ((SSL_OP_ALL & ~SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
+
+ flags = (SSL_OP_ALL | SSL_OP_NO_SSLv2);
+ if ((soap->ssl_flags & SOAP_SSLv3))
+ flags |= SSL_OP_NO_TLSv1;
+ if ((soap->ssl_flags & SOAP_TLSv1))
+ flags |= SSL_OP_NO_SSLv3;
+#ifdef SSL_OP_NO_TICKET
+ /* TLS extension is enabled by default in OPENSSL v0.9.8k
+ Disable it by adding SSL_OP_NO_TICKET */
+ flags |= SSL_OP_NO_TICKET;
+#endif
+ SSL_CTX_set_options(soap->ctx, flags);
+ if ((soap->ssl_flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION))
+ mode = (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
+ else if ((soap->ssl_flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION))
+ mode = SSL_VERIFY_PEER;
+ else
+ mode = SSL_VERIFY_NONE;
+ SSL_CTX_set_verify(soap->ctx, mode, soap->fsslverify);
+#if (OPENSSL_VERSION_NUMBER < 0x00905100L)
+ SSL_CTX_set_verify_depth(soap->ctx, 1);
+#else
+ SSL_CTX_set_verify_depth(soap->ctx, 9);
+#endif
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_1
+static int
+ssl_verify_callback(int ok, X509_STORE_CTX *store)
+{
+#ifdef SOAP_DEBUG
+ if (!ok)
+ { char data[256];
+ X509 *cert = X509_STORE_CTX_get_current_cert(store);
+ fprintf(stderr, "SSL verify error or warning with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(X509_STORE_CTX_get_error(store)));
+ X509_NAME_oneline(X509_get_issuer_name(cert), data, sizeof(data));
+ fprintf(stderr, "certificate issuer %s\n", data);
+ X509_NAME_oneline(X509_get_subject_name(cert), data, sizeof(data));
+ fprintf(stderr, "certificate subject %s\n", data);
+ }
+#endif
+ /* Note: return 1 to continue, but unsafe progress will be terminated by SSL */
+ return ok;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef PALM_1
+static int
+ssl_verify_callback_allow_expired_certificate(int ok, X509_STORE_CTX *store)
+{ ok = ssl_verify_callback(ok, store);
+ if (ok == 0 && X509_STORE_CTX_get_error(store) == X509_V_ERR_CERT_HAS_EXPIRED)
+ {
+#ifdef SOAP_DEBUG
+ fprintf(stderr, "ignoring certificate expiration\n");
+#endif
+ X509_STORE_CTX_set_error(store, X509_V_OK);
+ ok = 1;
+ }
+ /* Note: return 1 to continue, but unsafe progress will be terminated by SSL */
+ return ok;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_OPENSSL
+#ifndef WITH_NOIO
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_ssl_accept(struct soap *soap)
+{ BIO *bio;
+ int retries, r, s;
+ if (!soap_valid_socket(soap->socket))
+ return soap_set_receiver_error(soap, "SSL error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR);
+ if (!soap->ctx && (soap->error = soap->fsslauth(soap)))
+ return SOAP_SSL_ERROR;
+ if (!soap->ssl)
+ { soap->ssl = SSL_new(soap->ctx);
+ if (!soap->ssl)
+ return soap_set_receiver_error(soap, "SSL error", "SSL_new() failed in soap_ssl_accept()", SOAP_SSL_ERROR);
+ }
+ else
+ SSL_clear(soap->ssl);
+ soap->imode |= SOAP_ENC_SSL;
+ soap->omode |= SOAP_ENC_SSL;
+ /* Set SSL sockets to non-blocking */
+ SOAP_SOCKNONBLOCK(soap->socket)
+ bio = BIO_new_socket((int)soap->socket, BIO_NOCLOSE);
+ SSL_set_bio(soap->ssl, bio, bio);
+ retries = 100; /* SSL_accept timeout: 10 sec retries, 100 times 0.1 sec */
+#if defined(WITH_OPENSSL) && defined(KMS_SERVER)
+ /* Oracle customization for Ultra 2 KMS Server */
+ if (soap->ssl_accept_timeout > 0 )
+ {
+ retries = 10 * soap->ssl_accept_timeout;
+ }
+#endif
+
+while ((r = SSL_accept(soap->ssl)) <= 0)
+ { int err = SSL_get_error(soap->ssl, r);
+ if (err == SSL_ERROR_WANT_ACCEPT || err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
+ { if (err == SSL_ERROR_WANT_READ)
+ s = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000);
+ else
+ s = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000);
+ if (s < 0 && soap->errnum != SOAP_EINTR)
+ break;
+ }
+ else
+ { soap->errnum = soap_socket_errno(soap->socket);
+ break;
+ }
+ if (retries-- <= 0)
+ break;
+ }
+ if (r <= 0)
+ { soap_set_receiver_error(soap, soap_ssl_error(soap, r), "SSL_accept() failed in soap_ssl_accept()", SOAP_SSL_ERROR);
+ soap_closesock(soap);
+ return SOAP_SSL_ERROR;
+ }
+ if ((soap->ssl_flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION))
+ { X509 *peer;
+ int err;
+ if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK)
+ { soap_closesock(soap);
+ return soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate presented by peer cannot be verified in soap_ssl_accept()", SOAP_SSL_ERROR);
+ }
+ peer = SSL_get_peer_certificate(soap->ssl);
+ if (!peer)
+ { soap_closesock(soap);
+ return soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in soap_ssl_accept()", SOAP_SSL_ERROR);
+ }
+ X509_free(peer);
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+#endif
+
+/******************************************************************************\
+ *
+ * TCP/UDP [SSL/TLS] IPv4 and IPv6
+ *
+\******************************************************************************/
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+tcp_init(struct soap *soap)
+{ soap->errmode = 1;
+#ifdef WIN32
+ if (tcp_done)
+ return 0;
+ else
+ { WSADATA w;
+ if (WSAStartup(MAKEWORD(1, 1), &w))
+ return -1;
+ tcp_done = 1;
+ }
+#endif
+ return 0;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static const char*
+tcp_error(struct soap *soap)
+{ register const char *msg = NULL;
+ switch (soap->errmode)
+ { case 0:
+ msg = soap_strerror(soap);
+ break;
+ case 1:
+ msg = "WSAStartup failed";
+ break;
+ case 2:
+ {
+#ifndef WITH_LEAN
+ msg = soap_code_str(h_error_codes, soap->errnum);
+ if (!msg)
+#endif
+ { sprintf(soap->msgbuf, "TCP/UDP IP error %d", soap->errnum);
+ msg = soap->msgbuf;
+ }
+ }
+ }
+ return msg;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_IPV6
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr)
+{ soap_int32 iadd = -1;
+ struct hostent hostent, *host = &hostent;
+#ifdef VXWORKS
+ int hostint;
+ /* inet_addr(), and hostGetByName() expect "char *"; addr is a "const char *". */
+ iadd = inet_addr((char*)addr);
+#else
+#if defined(_AIX43) || ((defined(TRU64) || defined(HP_UX)) && defined(HAVE_GETHOSTBYNAME_R))
+ struct hostent_data ht_data;
+#endif
+#ifdef AS400
+ iadd = inet_addr((void*)addr);
+#else
+ iadd = inet_addr(addr);
+#endif
+#endif
+ if (iadd != -1)
+ { memcpy(inaddr, &iadd, sizeof(iadd));
+ return SOAP_OK;
+ }
+#if defined(__GLIBC__) || (defined(HAVE_GETHOSTBYNAME_R) && (defined(FREEBSD) || defined(__FreeBSD__)))
+ if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host, &soap->errnum) < 0)
+ host = NULL;
+#elif defined(_AIX43) || ((defined(TRU64) || defined(HP_UX)) && defined(HAVE_GETHOSTBYNAME_R))
+ memset((void*)&ht_data, 0, sizeof(ht_data));
+ if (gethostbyname_r(addr, &hostent, &ht_data) < 0)
+ { host = NULL;
+ soap->errnum = h_errno;
+ }
+#elif defined(HAVE_GETHOSTBYNAME_R)
+ host = gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &soap->errnum);
+#elif defined(VXWORKS)
+ /* If the DNS resolver library resolvLib has been configured in the vxWorks
+ * image, a query for the host IP address is sent to the DNS server, if the
+ * name was not found in the local host table. */
+ hostint = hostGetByName((char*)addr);
+ if (hostint == ERROR)
+ { host = NULL;
+ soap->errnum = soap_errno;
+ }
+#else
+#ifdef AS400
+ if (!(host = gethostbyname((void*)addr)))
+ soap->errnum = h_errno;
+#else
+ if (!(host = gethostbyname(addr)))
+ soap->errnum = h_errno;
+#endif
+#endif
+ if (!host)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Host name not found\n"));
+ return SOAP_ERR;
+ }
+#ifdef VXWORKS
+ inaddr->s_addr = hostint;
+#else
+ memcpy(inaddr, host->h_addr, host->h_length);
+#endif
+ return SOAP_OK;
+}
+#endif
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static SOAP_SOCKET
+tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port)
+{
+#ifdef WITH_IPV6
+ struct addrinfo hints, *res, *ressave;
+#endif
+ SOAP_SOCKET fd;
+ int err = 0;
+#ifndef WITH_LEAN
+ int len = SOAP_BUFLEN;
+ int set = 1;
+#endif
+#if !defined(WITH_LEAN) || defined(WITH_OPENSSL)
+ int retries;
+#endif
+ if (soap_valid_socket(soap->socket))
+ soap->fclosesocket(soap, soap->socket);
+ soap->socket = SOAP_INVALID_SOCKET;
+ if (tcp_init(soap))
+ { soap->errnum = 0;
+ soap_set_sender_error(soap, tcp_error(soap), "TCP init failed in tcp_connect()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ soap->errmode = 0;
+#ifdef WITH_IPV6
+ memset((void*)&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ hints.ai_socktype = SOCK_DGRAM;
+ else
+#endif
+ hints.ai_socktype = SOCK_STREAM;
+ soap->errmode = 2;
+ res = NULL;
+ if (soap->proxy_host)
+ err = getaddrinfo(soap->proxy_host, soap_int2s(soap, soap->proxy_port), &hints, &res);
+ else
+ err = getaddrinfo(host, soap_int2s(soap, port), &hints, &res);
+ /* Oracle customization: check err before using res */
+ if (err || (res==NULL))
+ { soap_set_sender_error(soap, SOAP_GAI_STRERROR(err), "getaddrinfo failed in tcp_connect()", SOAP_TCP_ERROR);
+ if (res)
+ {
+ freeaddrinfo(res);
+ }
+ return SOAP_INVALID_SOCKET;
+ }
+ ressave = res;
+again:
+ fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ soap->errmode = 0;
+#else
+#ifndef WITH_LEAN
+again:
+#endif
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ else
+#endif
+ fd = socket(AF_INET, SOCK_STREAM, 0);
+#endif
+ if (!soap_valid_socket(fd))
+ {
+#ifdef WITH_IPV6
+ if (res->ai_next)
+ { res = res->ai_next;
+ goto again;
+ }
+#endif
+ soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "socket failed in tcp_connect()", SOAP_TCP_ERROR);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#ifdef SOCKET_CLOSE_ON_EXEC
+#ifdef WIN32
+#ifndef UNDER_CE
+ SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0);
+#endif
+#else
+ fcntl(fd, F_SETFD, 1);
+#endif
+#endif
+#ifndef WITH_LEAN
+ if (soap->connect_flags == SO_LINGER)
+ { struct linger linger;
+ memset((void*)&linger, 0, sizeof(linger));
+ linger.l_onoff = 1;
+ linger.l_linger = soap->linger_time;
+ if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ else if (soap->connect_flags && setsockopt(fd, SOL_SOCKET, soap->connect_flags, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ if ((soap->keep_alive || soap->tcp_keep_alive) && setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#ifdef TCP_KEEPIDLE
+ if (soap->tcp_keep_idle && setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_KEEPIDLE, (char*)&(soap->tcp_keep_idle), sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPIDLE failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, (SOAP_SOCKET)fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#ifdef TCP_KEEPINTVL
+ if (soap->tcp_keep_intvl && setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_KEEPINTVL, (char*)&(soap->tcp_keep_intvl), sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPINTVL failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, (SOAP_SOCKET)fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#ifdef TCP_KEEPCNT
+ if (soap->tcp_keep_cnt && setsockopt((SOAP_SOCKET)fd, IPPROTO_TCP, TCP_KEEPCNT, (char*)&(soap->tcp_keep_cnt), sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPCNT failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, (SOAP_SOCKET)fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#ifdef TCP_NODELAY
+ if (!(soap->omode & SOAP_IO_UDP) && setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#ifdef WITH_IPV6
+ if ((soap->omode & SOAP_IO_UDP) && soap->ipv6_multicast_if)
+ { struct sockaddr_in6 *in6addr = (struct sockaddr_in6*)res->ai_addr;
+ in6addr->sin6_scope_id = soap->ipv6_multicast_if;
+ }
+#endif
+#ifdef IP_MULTICAST_TTL
+ if ((soap->omode & SOAP_IO_UDP) && soap->ipv4_multicast_if && !soap->ipv6_multicast_if)
+ { if (soap->ipv4_multicast_ttl > 0)
+ { char ttl = (char)(soap->ipv4_multicast_ttl);
+ if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ttl, sizeof(ttl)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_TTL failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+#ifndef WINDOWS
+ if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+#else
+#ifndef IP_MULTICAST_IF
+#define IP_MULTICAST_IF 2
+#endif
+ if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr)))
+ { soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+ }
+#endif
+#endif
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Opening socket %d to host='%s' port=%d\n", fd, host, port));
+#ifndef WITH_IPV6
+ soap->peerlen = sizeof(soap->peer);
+ memset((void*)&soap->peer, 0, sizeof(soap->peer));
+ soap->peer.sin_family = AF_INET;
+ soap->errmode = 2;
+ if (soap->proxy_host)
+ { if (soap->fresolve(soap, soap->proxy_host, &soap->peer.sin_addr))
+ { soap_set_sender_error(soap, tcp_error(soap), "get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+ soap->peer.sin_port = htons((short)soap->proxy_port);
+ }
+ else
+ { if (soap->fresolve(soap, host, &soap->peer.sin_addr))
+ { soap_set_sender_error(soap, tcp_error(soap), "get host by name failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+ soap->peer.sin_port = htons((short)port);
+ }
+ soap->errmode = 0;
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ return fd;
+#endif
+#else
+ if ((soap->omode & SOAP_IO_UDP))
+ { memcpy(&soap->peer, res->ai_addr, res->ai_addrlen);
+ soap->peerlen = res->ai_addrlen;
+ freeaddrinfo(ressave);
+ return fd;
+ }
+#endif
+#ifndef WITH_LEAN
+ if (soap->connect_timeout)
+ SOAP_SOCKNONBLOCK(fd)
+ else
+ SOAP_SOCKBLOCK(fd)
+ retries = 10;
+#endif
+ for (;;)
+ {
+#ifdef WITH_IPV6
+ if (connect(fd, res->ai_addr, (int)res->ai_addrlen))
+#else
+ if (connect(fd, (struct sockaddr*)&soap->peer, sizeof(soap->peer)))
+#endif
+ { err = soap_socket_errno(fd);
+#ifndef WITH_LEAN
+ if (err == SOAP_EADDRINUSE)
+ { soap->fclosesocket(soap, fd);
+ if (retries-- > 0)
+ goto again;
+ }
+ else if (soap->connect_timeout && (err == SOAP_EINPROGRESS || err == SOAP_EAGAIN || err == SOAP_EWOULDBLOCK))
+ {
+ SOAP_SOCKLEN_T k;
+ for (;;)
+ { register int r;
+ r = tcp_select(soap, fd, SOAP_TCP_SELECT_SND, soap->connect_timeout);
+ if (r > 0)
+ break;
+ if (!r)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n"));
+ soap_set_sender_error(soap, "Timeout", "connect failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ r = soap->errnum;
+ if (r != SOAP_EINTR)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n"));
+ soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ k = (SOAP_SOCKLEN_T)sizeof(soap->errnum);
+ if (!getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &k) && !soap->errnum) /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */
+ break;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n"));
+ if (!soap->errnum)
+ soap->errnum = soap_socket_errno(fd);
+ soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#ifdef WITH_IPV6
+ if (res->ai_next)
+ { res = res->ai_next;
+ soap->fclosesocket(soap, fd);
+ goto again;
+ }
+#endif
+ if (err && err != SOAP_EINTR)
+ { soap->errnum = err;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n"));
+ soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+#ifdef WITH_IPV6
+ freeaddrinfo(ressave);
+#endif
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ else
+ break;
+ }
+#ifdef WITH_IPV6
+ soap->peerlen = 0; /* IPv6: already connected so use send() */
+ freeaddrinfo(ressave);
+#endif
+ if (soap->recv_timeout || soap->send_timeout)
+ SOAP_SOCKNONBLOCK(fd)
+ else
+ SOAP_SOCKBLOCK(fd)
+ soap->socket = fd;
+ soap->imode &= ~SOAP_ENC_SSL;
+ soap->omode &= ~SOAP_ENC_SSL;
+ if (!soap_tag_cmp(endpoint, "https:*"))
+ {
+#ifdef WITH_OPENSSL
+ BIO *bio;
+ int r;
+ if (soap->proxy_host)
+ { soap_mode m = soap->mode; /* preserve settings */
+ soap_mode om = soap->omode; /* make sure we only parse HTTP */
+ size_t n = soap->count; /* save the content length */
+ const char *userid, *passwd;
+ soap->omode &= ~SOAP_ENC; /* mask IO and ENC */
+ soap->omode |= SOAP_IO_BUFFER;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connecting to %s proxy server\n", soap->proxy_http_version));
+ sprintf(soap->tmpbuf, "CONNECT %s:%d HTTP/%s", host, port, soap->proxy_http_version);
+ if (soap_begin_send(soap)
+ || (soap->error = soap->fposthdr(soap, soap->tmpbuf, NULL)))
+ { soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+#ifndef WITH_LEAN
+ if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761)
+ { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd);
+ strcpy(soap->tmpbuf, "Basic ");
+ soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262));
+ if ((soap->error = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf)))
+ { soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ //
+ // Oracle customization
+ // TODO: returning soap->error may also be a bug
+ //
+ return soap->error;
+ }
+ }
+#endif
+ if ((soap->error = soap->fposthdr(soap, NULL, NULL))
+ || soap_flush(soap))
+ { soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ soap->omode = om;
+ om = soap->imode;
+ soap->imode &= ~SOAP_ENC; /* mask IO and ENC */
+ userid = soap->userid; /* preserve */
+ passwd = soap->passwd; /* preserve */
+ if ((soap->error = soap->fparse(soap)))
+ { soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ soap->userid = userid; /* restore */
+ soap->passwd = passwd; /* restore */
+ soap->imode = om; /* restore */
+ soap->count = n; /* restore */
+ if (soap_begin_send(soap))
+ { soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (endpoint)
+ strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint)-1); /* restore */
+ soap->mode = m;
+ }
+ if (!soap->ctx && (soap->error = soap->fsslauth(soap)))
+ { soap_set_sender_error(soap, "SSL error", "SSL authentication failed in tcp_connect(): check password, key file, and ca file.", SOAP_SSL_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ if (!soap->ssl)
+ { soap->ssl = SSL_new(soap->ctx);
+ if (!soap->ssl)
+ { soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ soap->error = SOAP_SSL_ERROR;
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ else
+ SSL_clear(soap->ssl);
+ if (soap->session)
+ { if (!strcmp(soap->session_host, host) && soap->session_port == port)
+ SSL_set_session(soap->ssl, soap->session);
+ SSL_SESSION_free(soap->session);
+ soap->session = NULL;
+ }
+ soap->imode |= SOAP_ENC_SSL;
+ soap->omode |= SOAP_ENC_SSL;
+ bio = BIO_new_socket((int)fd, BIO_NOCLOSE);
+ SSL_set_bio(soap->ssl, bio, bio);
+ retries = 0;
+#ifndef WITH_LEAN
+ /* Connect timeout: set SSL sockets to non-blocking */
+ if (soap->connect_timeout)
+ { SOAP_SOCKNONBLOCK(fd)
+ retries = 10*soap->connect_timeout;
+ }
+ else
+ SOAP_SOCKBLOCK(fd)
+#endif
+ //
+ // Oracle customization
+ //
+ // Clear error queue of any errors remaining from a previous operation
+ ERR_clear_error();
+
+ if (retries <= 0)
+ retries = 100; /* SSL connect timeout: 10 sec retries, 100 x 0.1 sec */
+ /* Try connecting until success or timeout (when nonblocking) */
+ do
+ { if ((r = SSL_connect(soap->ssl)) <= 0)
+ { int err = SSL_get_error(soap->ssl, r);
+ if (err == SSL_ERROR_WANT_CONNECT || err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
+ { register int s;
+ if (err == SSL_ERROR_WANT_READ)
+ s = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000);
+ else
+ s = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000);
+ if (s < 0 && soap->errnum != SOAP_EINTR)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL_connect/select error in tcp_connect\n"));
+ soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ if (s == 0 && retries-- <= 0)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL connect timeout\n"));
+ soap_set_sender_error(soap, "Timeout", "SSL connect failed in tcp_connect()", SOAP_TCP_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ else
+ { soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL_connect error in tcp_connect()", SOAP_SSL_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ } while (!SSL_is_init_finished(soap->ssl));
+ /* Set SSL sockets to nonblocking */
+ SOAP_SOCKNONBLOCK(fd)
+ /* Check server credentials when required */
+ if ((soap->ssl_flags & SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION))
+ { int err;
+ if ((err = SSL_get_verify_result(soap->ssl)) != X509_V_OK)
+ { soap_set_sender_error(soap, X509_verify_cert_error_string(err), "SSL certificate presented by peer cannot be verified in tcp_connect()", SOAP_SSL_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ if (!(soap->ssl_flags & SOAP_SSL_SKIP_HOST_CHECK))
+ { /* Oracle customization: X509_NAME *subj; */
+ int ext_count;
+ int ok = 0;
+ X509 *peer;
+ peer = SSL_get_peer_certificate(soap->ssl);
+ if (!peer)
+ { soap_set_sender_error(soap, "SSL error", "No SSL certificate was presented by the peer in tcp_connect()", SOAP_SSL_ERROR);
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ return SOAP_INVALID_SOCKET;
+ }
+ ext_count = X509_get_ext_count(peer);
+ if (ext_count > 0)
+ { int i;
+ for (i = 0; i < ext_count; i++)
+ { X509_EXTENSION *ext = X509_get_ext(peer, i);
+ const char *ext_str = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext)));
+ if (ext_str && !strcmp(ext_str, "subjectAltName"))
+ { X509V3_EXT_METHOD *meth = (X509V3_EXT_METHOD*)X509V3_EXT_get(ext);
+ void *ext_data;
+#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL)
+ const unsigned char *data;
+#else
+ unsigned char *data;
+#endif
+ STACK_OF(CONF_VALUE) *val;
+ int j;
+ if (!meth)
+ break;
+ data = ext->value->data;
+#if (OPENSSL_VERSION_NUMBER > 0x00907000L)
+ if (meth->it)
+ ext_data = ASN1_item_d2i(NULL, &data, ext->value->length, ASN1_ITEM_ptr(meth->it));
+ else
+ { /* OpenSSL not perfectly portable at this point (?):
+ Some compilers appear to prefer
+ meth->d2i(NULL, (const unsigned char**)&data, ...
+ and others prefer
+ meth->d2i(NULL, &data, ext->value->length);
+ */
+ ext_data = meth->d2i(NULL, &data, ext->value->length);
+ }
+#else
+ ext_data = meth->d2i(NULL, &data, ext->value->length);
+#endif
+ if (ext_data)
+ { val = meth->i2v(meth, ext_data, NULL);
+ if (val)
+ { for (j = 0; j < sk_CONF_VALUE_num(val); j++)
+ { CONF_VALUE *nval = sk_CONF_VALUE_value(val, j);
+ if (nval && !strcmp(nval->name, "DNS") && !strcmp(nval->value, host))
+ { ok = 1;
+ break;
+ }
+ }
+ sk_CONF_VALUE_pop_free(val, X509V3_conf_free);
+ }
+#if (OPENSSL_VERSION_NUMBER > 0x00907000L)
+ if (meth->it)
+ ASN1_item_free((ASN1_VALUE*)ext_data, ASN1_ITEM_ptr(meth->it));
+ else
+ meth->ext_free(ext_data);
+#else
+ meth->ext_free(ext_data);
+#endif
+ }
+ }
+ if (ok)
+ break;
+ }
+ }
+ //
+ // Oracle customization
+ //
+ // the certificate subject name is an entity name, not a DNS name
+ //
+ /*
+ if (!ok && (subj = X509_get_subject_name(peer)))
+ { int i = -1;
+ do
+ { ASN1_STRING *name;
+ i = X509_NAME_get_index_by_NID(subj, NID_commonName, i);
+ if (i == -1)
+ break;
+ name = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(subj, i));
+ if (name)
+ { if (!soap_tag_cmp(host, (const char*)M_ASN1_STRING_data(name)))
+ ok = 1;
+ else
+ { unsigned char *tmp = NULL;
+ ASN1_STRING_to_UTF8(&tmp, name);
+ if (tmp)
+ { if (!soap_tag_cmp(host, (const char*)tmp))
+ ok = 1;
+ OPENSSL_free(tmp);
+ }
+ }
+ }
+ } while (!ok);
+ }
+ */
+ X509_free(peer);
+ /*
+ if (!ok)
+ { soap_set_sender_error(soap, "SSL error", "SSL certificate host name mismatch in tcp_connect()", SOAP_SSL_ERROR);
+ soap->fclosesocket(soap, fd);
+ return SOAP_INVALID_SOCKET;
+ }
+ */
+ }
+ }
+#ifdef SOAP_DEBUG
+ //
+ // Oracle customization for debug
+ //
+ if ( SSL_session_reused( soap->ssl ) == 1)
+ {
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL session reused\n"));
+ }
+ else
+ {
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL session negotiated\n"));
+ }
+#endif
+#else
+ soap->fclosesocket(soap, fd);
+ soap->socket = SOAP_INVALID_SOCKET; /* Oracle customization */
+ soap->error = SOAP_SSL_ERROR;
+ return SOAP_INVALID_SOCKET;
+#endif
+ }
+ return fd;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+tcp_select(struct soap *soap, SOAP_SOCKET s, int flags, int timeout)
+{ register int r;
+ struct timeval tv;
+ fd_set fd[3], *rfd, *sfd, *efd;
+ soap->errnum = 0;
+#ifndef WIN32
+ /* if fd max set size exceeded, use poll() when available */
+#if defined(__QNX__) || defined(QNX) /* select() is not MT safe on some QNX */
+ if (1)
+#else
+ if ((int)s >= (int)FD_SETSIZE)
+#endif
+#ifdef HAVE_POLL
+ { struct pollfd pollfd;
+ int retries = 0;
+ pollfd.fd = (int)s;
+ pollfd.events = 0;
+ if (flags & SOAP_TCP_SELECT_RCV)
+ pollfd.events |= POLLIN;
+ if (flags & SOAP_TCP_SELECT_SND)
+ pollfd.events |= POLLOUT;
+ if (flags & SOAP_TCP_SELECT_ERR)
+ pollfd.events |= POLLERR;
+ if (timeout < 0)
+ timeout /= -1000; /* -usec -> ms */
+ else if (timeout <= 1000000) /* avoid overflow */
+ timeout *= 1000; /* sec -> ms */
+ else
+ { retries = timeout / 1000000;
+ timeout = 1000000000;
+ }
+ do r = poll(&pollfd, 1, timeout);
+ while (r == 0 && retries--);
+ if (r > 0)
+ { r = 0;
+ if ((flags & SOAP_TCP_SELECT_RCV) && (pollfd.revents & POLLIN))
+ r |= SOAP_TCP_SELECT_RCV;
+ if ((flags & SOAP_TCP_SELECT_SND) && (pollfd.revents & POLLOUT))
+ r |= SOAP_TCP_SELECT_SND;
+ if ((flags & SOAP_TCP_SELECT_ERR) && (pollfd.revents & POLLERR))
+ r |= SOAP_TCP_SELECT_ERR;
+ }
+ else if (r < 0)
+ soap->errnum = soap_socket_errno(s);
+ return r;
+ }
+#else
+ { soap->error = SOAP_FD_EXCEEDED;
+ return -1;
+ }
+#endif
+#endif
+ rfd = sfd = efd = NULL;
+ if (flags & SOAP_TCP_SELECT_RCV)
+ { rfd = &fd[0];
+ FD_ZERO(rfd);
+ FD_SET(s, rfd);
+ }
+ if (flags & SOAP_TCP_SELECT_SND)
+ { sfd = &fd[1];
+ FD_ZERO(sfd);
+ FD_SET(s, sfd);
+ }
+ if (flags & SOAP_TCP_SELECT_ERR)
+ { efd = &fd[2];
+ FD_ZERO(efd);
+ FD_SET(s, efd);
+ }
+ if (timeout >= 0)
+ { tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+ }
+ else
+ { tv.tv_sec = -timeout / 1000000;
+ tv.tv_usec = -timeout % 1000000;
+ }
+ r = select((int)s + 1, rfd, sfd, efd, &tv);
+ if (r > 0)
+ { r = 0;
+ if ((flags & SOAP_TCP_SELECT_RCV) && FD_ISSET(s, rfd))
+ r |= SOAP_TCP_SELECT_RCV;
+ if ((flags & SOAP_TCP_SELECT_SND) && FD_ISSET(s, sfd))
+ r |= SOAP_TCP_SELECT_SND;
+ if ((flags & SOAP_TCP_SELECT_ERR) && FD_ISSET(s, efd))
+ r |= SOAP_TCP_SELECT_ERR;
+ }
+ else if (r < 0)
+ soap->errnum = soap_socket_errno(s);
+ return r;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static SOAP_SOCKET
+tcp_accept(struct soap *soap, SOAP_SOCKET s, struct sockaddr *a, int *n)
+{ SOAP_SOCKET fd;
+ fd = accept(s, a, (SOAP_SOCKLEN_T*)n); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */
+#ifdef SOCKET_CLOSE_ON_EXEC
+#ifdef WIN32
+#ifndef UNDER_CE
+ SetHandleInformation((HANDLE)fd, HANDLE_FLAG_INHERIT, 0);
+#endif
+#else
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
+#endif
+ return fd;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+tcp_disconnect(struct soap *soap)
+{
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ { int r, s = 0;
+ if (soap->session)
+ { SSL_SESSION_free(soap->session);
+ soap->session = NULL;
+ }
+ if (*soap->host)
+ { soap->session = SSL_get1_session(soap->ssl);
+ if (soap->session)
+ { strcpy(soap->session_host, soap->host);
+ soap->session_port = soap->port;
+ }
+ }
+ r = SSL_shutdown(soap->ssl);
+ /* SSL shutdown does not work when reads are pending */
+ while (SSL_want_read(soap->ssl))
+ { SSL_read(soap->ssl, NULL, 0);
+ if (soap_socket_errno(soap->socket) != SOAP_EAGAIN)
+ { r = SSL_shutdown(soap->ssl);
+ break;
+ }
+ }
+ if (r == 0)
+ { if (soap_valid_socket(soap->socket))
+ { if (!soap->fshutdownsocket(soap, soap->socket, 1))
+ {
+#ifndef WITH_LEAN
+ /*
+ wait up to 10 seconds for close_notify to be sent by peer (if peer not
+ present, this avoids calling SSL_shutdown() which has a lengthy return
+ timeout)
+ */
+ r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, 10);
+ if (r <= 0 && soap->errnum != SOAP_EINTR)
+ { soap->errnum = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connection lost...\n"));
+ soap->fclosesocket(soap, soap->socket);
+ soap->socket = SOAP_INVALID_SOCKET;
+ ERR_remove_state(0);
+ return SOAP_OK;
+ }
+#else
+ r = SSL_shutdown(soap->ssl);
+#endif
+ }
+ }
+ }
+ if (r != 1)
+ { s = ERR_get_error();
+ if (s)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Shutdown failed: %d\n", SSL_get_error(soap->ssl, r)));
+ if (soap_valid_socket(soap->socket) && !(soap->omode & SOAP_IO_UDP))
+ { soap->fclosesocket(soap, soap->socket);
+ soap->socket = SOAP_INVALID_SOCKET;
+ }
+ }
+ }
+ SSL_free(soap->ssl);
+ soap->ssl = NULL;
+ if (s)
+ return SOAP_SSL_ERROR;
+ ERR_remove_state(0);
+ }
+#endif
+ if (soap_valid_socket(soap->socket) && !(soap->omode & SOAP_IO_UDP))
+ { soap->fshutdownsocket(soap, soap->socket, 2);
+ soap->fclosesocket(soap, soap->socket);
+ soap->socket = SOAP_INVALID_SOCKET;
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+tcp_closesocket(struct soap *soap, SOAP_SOCKET fd)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Close socket %d\n", (int)fd));
+ return soap_closesocket(fd);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static int
+tcp_shutdownsocket(struct soap *soap, SOAP_SOCKET fd, int how)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Shutdown socket %d how=%d\n", (int)fd, how));
+ return shutdown(fd, how);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+SOAP_FMAC1
+SOAP_SOCKET
+SOAP_FMAC2
+soap_bind(struct soap *soap, const char *host, int port, int backlog)
+{
+#ifdef WITH_IPV6
+ struct addrinfo *addrinfo = NULL;
+ struct addrinfo hints;
+ struct addrinfo res;
+ int err;
+#ifdef IPV6_V6ONLY
+ int unset = 0;
+#ifdef SOL_IP
+ int level = SOL_IP;
+#else
+ int level = IPPROTO_IPV6;
+#endif
+#endif
+#endif
+#ifndef WITH_LEAN
+ int len = SOAP_BUFLEN;
+ int set = 1;
+#endif
+ if (soap_valid_socket(soap->master))
+ { soap->fclosesocket(soap, soap->master);
+ soap->master = SOAP_INVALID_SOCKET;
+ }
+ soap->socket = SOAP_INVALID_SOCKET;
+ soap->errmode = 1;
+ if (tcp_init(soap))
+ { soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#ifdef WITH_IPV6
+ memset((void*)&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ hints.ai_socktype = SOCK_DGRAM;
+ else
+#endif
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE;
+ soap->errmode = 2;
+ /* Oracle customization: check err before using addrinfo */
+ err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo);
+ if (err || !addrinfo)
+ { soap_set_receiver_error(soap, SOAP_GAI_STRERROR(err), "getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR);
+ if (addrinfo)
+ {
+ freeaddrinfo(addrinfo);
+ }
+ return SOAP_INVALID_SOCKET;
+ }
+ res = *addrinfo;
+ memcpy(&soap->peer, addrinfo->ai_addr, addrinfo->ai_addrlen);
+ soap->peerlen = addrinfo->ai_addrlen;
+ res.ai_addr = (struct sockaddr*)&soap->peer;
+ res.ai_addrlen = soap->peerlen;
+ freeaddrinfo(addrinfo);
+ soap->master = (int)socket(res.ai_family, res.ai_socktype, res.ai_protocol);
+#else
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ soap->master = (int)socket(AF_INET, SOCK_DGRAM, 0);
+ else
+#endif
+ soap->master = (int)socket(AF_INET, SOCK_STREAM, 0);
+#endif
+ soap->errmode = 0;
+ if (!soap_valid_socket(soap->master))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "socket failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ soap->socket = soap->master;
+#endif
+#ifdef SOCKET_CLOSE_ON_EXEC
+#ifdef WIN32
+#ifndef UNDER_CE
+ SetHandleInformation((HANDLE)soap->master, HANDLE_FLAG_INHERIT, 0);
+#endif
+#else
+ fcntl(soap->master, F_SETFD, 1);
+#endif
+#endif
+#ifndef WITH_LEAN
+ if (soap->bind_flags && setsockopt(soap->master, SOL_SOCKET, soap->bind_flags, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (setsockopt(soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (setsockopt(soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#ifdef TCP_NODELAY
+ if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->master, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#endif
+#ifdef WITH_IPV6
+#ifdef IPV6_V6ONLY
+ if (setsockopt(soap->master, level, IPV6_V6ONLY, (char*)&unset, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->master);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+ soap->errmode = 0;
+ if (bind(soap->master, res.ai_addr, (int)res.ai_addrlen))
+ { soap->errnum = soap_socket_errno(soap->master);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n"));
+ soap_closesock(soap);
+ soap_set_receiver_error(soap, tcp_error(soap), "bind failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#else
+ soap->peerlen = sizeof(soap->peer);
+ memset((void*)&soap->peer, 0, sizeof(soap->peer));
+ soap->peer.sin_family = AF_INET;
+ soap->errmode = 2;
+ if (host)
+ { if (soap->fresolve(soap, host, &soap->peer.sin_addr))
+ { soap_set_receiver_error(soap, tcp_error(soap), "get host by name failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ else
+ soap->peer.sin_addr.s_addr = htonl(INADDR_ANY);
+ soap->peer.sin_port = htons((short)port);
+ soap->errmode = 0;
+ if (bind(soap->master, (struct sockaddr*)&soap->peer, (int)soap->peerlen))
+ { soap->errnum = soap_socket_errno(soap->master);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n"));
+ soap_closesock(soap);
+ soap_set_receiver_error(soap, tcp_error(soap), "bind failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+ if (!(soap->omode & SOAP_IO_UDP) && listen(soap->master, backlog))
+ { soap->errnum = soap_socket_errno(soap->master);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n"));
+ soap_closesock(soap);
+ soap_set_receiver_error(soap, tcp_error(soap), "listen failed in soap_bind()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ return soap->master;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_poll(struct soap *soap)
+{
+#ifndef WITH_LEAN
+ register int r;
+ if (soap_valid_socket(soap->socket))
+ { r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ALL, 0);
+ if (r > 0 && (r & SOAP_TCP_SELECT_ERR))
+ r = -1;
+ }
+ else if (soap_valid_socket(soap->master))
+ r = tcp_select(soap, soap->master, SOAP_TCP_SELECT_SND, 0);
+ else
+ return SOAP_OK;
+ if (r > 0)
+ {
+#ifdef WITH_OPENSSL
+ if (soap->imode & SOAP_ENC_SSL)
+ {
+ if (soap_valid_socket(soap->socket)
+ && (r & SOAP_TCP_SELECT_SND)
+ && (!(r & SOAP_TCP_SELECT_RCV)
+ || SSL_peek(soap->ssl, soap->tmpbuf, 1) > 0))
+ return SOAP_OK;
+ }
+ else
+#endif
+ if (soap_valid_socket(soap->socket)
+ && (r & SOAP_TCP_SELECT_SND)
+ && (!(r & SOAP_TCP_SELECT_RCV)
+ || recv(soap->socket, soap->tmpbuf, 1, MSG_PEEK) > 0))
+ return SOAP_OK;
+ }
+ else if (r < 0)
+ { if ((soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) && soap_socket_errno(soap->master) != SOAP_EINTR)
+ { soap_set_receiver_error(soap, tcp_error(soap), "select failed in soap_poll()", SOAP_TCP_ERROR);
+ return soap->error = SOAP_TCP_ERROR;
+ }
+ }
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Polling: other end down on socket=%d select=%d\n", soap->socket, r));
+ return SOAP_EOF;
+#else
+ return SOAP_OK;
+#endif
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+SOAP_FMAC1
+SOAP_SOCKET
+SOAP_FMAC2
+soap_accept(struct soap *soap)
+{ int n = (int)sizeof(soap->peer);
+#ifndef WITH_LEAN
+ int len = SOAP_BUFLEN;
+ int set = 1;
+#endif
+ soap->error = SOAP_OK;
+#ifndef WITH_LEAN
+ if ((soap->omode & SOAP_IO_UDP))
+ return soap->socket = soap->master;
+#endif
+ memset((void*)&soap->peer, 0, sizeof(soap->peer));
+ soap->socket = SOAP_INVALID_SOCKET;
+ soap->errmode = 0;
+ soap->keep_alive = 0;
+ if (soap_valid_socket(soap->master))
+ { register int err;
+ for (;;)
+ { if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout)
+ { for (;;)
+ { register int r;
+ r = tcp_select(soap, soap->master, SOAP_TCP_SELECT_ALL, soap->accept_timeout ? soap->accept_timeout : 60);
+ if (r > 0)
+ break;
+ if (!r && soap->accept_timeout)
+ { soap_set_receiver_error(soap, "Timeout", "accept failed in soap_accept()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (r < 0)
+ { r = soap->errnum;
+ if (r != SOAP_EINTR)
+ { soap_closesock(soap);
+ soap_set_sender_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ }
+ }
+ if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout)
+ SOAP_SOCKNONBLOCK(soap->master)
+ else
+ SOAP_SOCKBLOCK(soap->master)
+ soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&soap->peer, &n);
+ soap->peerlen = (size_t)n;
+ if (soap_valid_socket(soap->socket))
+ {
+#ifdef WITH_IPV6
+/* Use soap->host to store the numeric form of the remote host */
+ getnameinfo((struct sockaddr*)&soap->peer, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d from %s\n", soap->socket, soap->host));
+ //
+ // Oracle customization
+ //
+ // bug fix: save off the remote host
+ strcpy(soap->session_host, soap->host);
+ soap->ip = 0; /* info stored in soap->peer and soap->host */
+ soap->port = 0; /* info stored in soap->peer and soap->host */
+#else
+ soap->ip = ntohl(soap->peer.sin_addr.s_addr);
+ soap->port = (int)ntohs(soap->peer.sin_port); /* does not return port number on some systems */
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket %d at port %d from IP %d.%d.%d.%d\n", soap->socket, soap->port, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF));
+#endif
+#ifndef WITH_LEAN
+ if (soap->accept_flags == SO_LINGER)
+ { struct linger linger;
+ memset((void*)&linger, 0, sizeof(linger));
+ linger.l_onoff = 1;
+ linger.l_linger = soap->linger_time;
+ if (setsockopt(soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger)))
+ { soap->errnum = soap_socket_errno(soap->socket);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ else if (soap->accept_flags && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->socket);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->socket);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->socket);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+ if (setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->socket);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+#ifdef TCP_NODELAY
+ if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
+ { soap->errnum = soap_socket_errno(soap->socket);
+ soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+#endif
+#endif
+ soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0);
+ return soap->socket;
+ }
+ err = soap_socket_errno(soap->socket);
+ if (err != 0 && err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK)
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host));
+ soap->errnum = err;
+ soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR);
+ soap_closesock(soap);
+ return SOAP_INVALID_SOCKET;
+ }
+ }
+ }
+ else
+ { soap->errnum = 0;
+ soap_set_receiver_error(soap, tcp_error(soap), "no master socket in soap_accept()", SOAP_TCP_ERROR);
+ return SOAP_INVALID_SOCKET;
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_closesock(struct soap *soap)
+{ register int status = soap->error;
+#ifndef WITH_LEANER
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+#endif
+ if (soap->fdisconnect && (soap->error = soap->fdisconnect(soap)))
+ return soap->error;
+ if (status == SOAP_EOF || status == SOAP_TCP_ERROR || status == SOAP_SSL_ERROR || !soap->keep_alive)
+ { if (soap->fclose && (soap->error = soap->fclose(soap)))
+ return soap->error;
+ soap->keep_alive = 0;
+ }
+#ifdef WITH_ZLIB
+ if (soap->zlib_state == SOAP_ZLIB_DEFLATE)
+ deflateEnd(soap->d_stream);
+ else if (soap->zlib_state == SOAP_ZLIB_INFLATE)
+ inflateEnd(soap->d_stream);
+ soap->zlib_state = SOAP_ZLIB_NONE;
+#endif
+ return soap->error = status;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_cleanup(struct soap *soap)
+{ soap_done(soap);
+#ifdef WIN32
+ if (!tcp_done)
+ return;
+ tcp_done = 0;
+ WSACleanup();
+#endif
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_done(struct soap *soap)
+{
+#ifdef SOAP_DEBUG
+ int i;
+#endif
+ if (soap_check_state(soap))
+ return;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Done with context\n"));
+ soap_free_temp(soap);
+ while (soap->clist)
+ { struct soap_clist *p = soap->clist->next;
+ SOAP_FREE(soap, soap->clist);
+ soap->clist = p;
+ }
+ if (soap->state == SOAP_INIT)
+ soap->omode &= ~SOAP_IO_UDP; /* to force close the socket */
+ soap->keep_alive = 0; /* to force close the socket */
+ soap_closesock(soap);
+#ifdef WITH_COOKIES
+ soap_free_cookies(soap);
+#endif
+ while (soap->plugins)
+ { register struct soap_plugin *p = soap->plugins->next;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Removing plugin '%s'\n", soap->plugins->id));
+ if (soap->plugins->fcopy || soap->state == SOAP_INIT)
+ soap->plugins->fdelete(soap, soap->plugins);
+ SOAP_FREE(soap, soap->plugins);
+ soap->plugins = p;
+ }
+ soap->fplugin = fplugin;
+ soap->fmalloc = NULL;
+#ifndef WITH_NOHTTP
+ soap->fpost = http_post;
+ soap->fget = http_get;
+ soap->fput = http_405;
+ soap->fdel = http_405;
+ soap->fhead = http_405;
+ soap->fform = NULL;
+ soap->fposthdr = http_post_header;
+ soap->fresponse = http_response;
+ soap->fparse = http_parse;
+ soap->fparsehdr = http_parse_header;
+#endif
+ soap->fheader = NULL;
+#ifndef WITH_NOIO
+#ifndef WITH_IPV6
+ soap->fresolve = tcp_gethost;
+#else
+ soap->fresolve = NULL;
+#endif
+ soap->faccept = tcp_accept;
+ soap->fopen = tcp_connect;
+ soap->fclose = tcp_disconnect;
+ soap->fclosesocket = tcp_closesocket;
+ soap->fshutdownsocket = tcp_shutdownsocket;
+ soap->fsend = fsend;
+ soap->frecv = frecv;
+ soap->fpoll = soap_poll;
+#else
+ soap->fopen = NULL;
+ soap->fclose = NULL;
+ soap->fpoll = NULL;
+#endif
+#ifndef WITH_LEANER
+ soap->fprepareinitsend = NULL;
+ soap->fprepareinitrecv = NULL;
+ soap->fpreparesend = NULL;
+ soap->fpreparerecv = NULL;
+ soap->fpreparefinalsend = NULL;
+ soap->fpreparefinalrecv = NULL;
+#endif
+ soap->fseterror = NULL;
+ soap->fignore = NULL;
+ soap->fserveloop = NULL;
+#ifdef WITH_OPENSSL
+ if (soap->session)
+ { SSL_SESSION_free(soap->session);
+ soap->session = NULL;
+ }
+#endif
+ if (soap->state == SOAP_INIT)
+ { if (soap_valid_socket(soap->master))
+ { soap->fclosesocket(soap, soap->master);
+ soap->master = SOAP_INVALID_SOCKET;
+ }
+ }
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ { SSL_free(soap->ssl);
+ soap->ssl = NULL;
+ }
+ if (soap->state == SOAP_INIT)
+ { if (soap->ctx)
+ { SSL_CTX_free(soap->ctx);
+ soap->ctx = NULL;
+ }
+ }
+#endif
+#ifdef WITH_OPENSSL
+ ERR_remove_state(0);
+#endif
+#ifdef WITH_C_LOCALE
+ freelocale(soap->c_locale);
+#endif
+#ifdef WITH_ZLIB
+ if (soap->d_stream)
+ { SOAP_FREE(soap, (void*)soap->d_stream);
+ soap->d_stream = NULL;
+ }
+ if (soap->z_buf)
+ { SOAP_FREE(soap, (void*)soap->z_buf);
+ soap->z_buf = NULL;
+ }
+#endif
+#ifdef SOAP_DEBUG
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free logfiles\n"));
+ for (i = 0; i < SOAP_MAXLOGS; i++)
+ { if (soap->logfile[i])
+ { SOAP_FREE(soap, (void*)soap->logfile[i]);
+ soap->logfile[i] = NULL;
+ }
+ soap_close_logfile(soap, i);
+ }
+ soap->state = SOAP_NONE;
+#endif
+#ifdef SOAP_MEM_DEBUG
+ soap_free_mht(soap);
+#endif
+}
+#endif
+
+/******************************************************************************\
+ *
+ * HTTP
+ *
+\******************************************************************************/
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_parse(struct soap *soap)
+{ char header[SOAP_HDRLEN], *s;
+ unsigned short httpcmd = 0, status = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for HTTP request/response...\n"));
+ *soap->endpoint = '\0';
+ soap->length = 0;
+ soap->userid = NULL;
+ soap->passwd = NULL;
+ soap->action = NULL;
+ soap->authrealm = NULL;
+ soap->proxy_from = NULL;
+ soap->http_content = NULL;
+ soap->status = 0;
+ do
+ { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf)))
+ { if (soap->error == SOAP_EOF)
+ return SOAP_EOF;
+ return soap->error = 414;
+ }
+ if ((s = strchr(soap->msgbuf, ' ')))
+ { soap->status = (unsigned short)soap_strtoul(s, &s, 10);
+ if (!soap_blank(*s))
+ soap->status = 0;
+ }
+ else
+ soap->status = 0;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf));
+ for (;;)
+ { if (soap_getline(soap, header, SOAP_HDRLEN))
+ { if (soap->error == SOAP_EOF)
+ { soap->error = SOAP_OK;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "EOF in HTTP header, continue anyway\n"));
+ break;
+ }
+ return soap->error;
+ }
+ if (!*header)
+ break;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header));
+ s = strchr(header, ':');
+ if (s)
+ { char *t;
+ *s = '\0';
+ do s++;
+ while (*s && *s <= 32);
+ if (*s == '"')
+ s++;
+ t = s + strlen(s) - 1;
+ while (t > s && *t <= 32)
+ t--;
+ if (t >= s && *t == '"')
+ t--;
+ t[1] = '\0';
+ if ((soap->error = soap->fparsehdr(soap, header, s)))
+ { if (soap->error < SOAP_STOP)
+ return soap->error;
+ status = soap->error;
+ soap->error = SOAP_OK;
+ }
+ }
+ }
+ } while (soap->status == 100);
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing, status = %d\n", soap->status));
+ s = strstr(soap->msgbuf, "HTTP/");
+ if (s && s[7] != '1')
+ { if (soap->keep_alive == 1)
+ soap->keep_alive = 0;
+ if (soap->status == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* soap->status == 0 for HTTP request */
+ { soap->imode |= SOAP_IO_CHUNK;
+ soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE;
+ }
+ }
+ if (soap->keep_alive < 0)
+ soap->keep_alive = 1;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive));
+ if (soap->status == 0)
+ { size_t l = 0;
+ if (s)
+ { if (!strncmp(soap->msgbuf, "POST ", l = 5))
+ httpcmd = 1;
+ else if (!strncmp(soap->msgbuf, "GET ", l = 4))
+ httpcmd = 2;
+ else if (!strncmp(soap->msgbuf, "PUT ", l = 4))
+ httpcmd = 3;
+ else if (!strncmp(soap->msgbuf, "DELETE ", l = 7))
+ httpcmd = 4;
+ else if (!strncmp(soap->msgbuf, "HEAD ", l = 5))
+ httpcmd = 5;
+ }
+ if (s && httpcmd)
+ { size_t m = strlen(soap->endpoint);
+ size_t n = m + (s - soap->msgbuf) - l - 1;
+ if (m > n)
+ m = n;
+ if (n >= sizeof(soap->endpoint))
+ n = sizeof(soap->endpoint) - 1;
+ strncpy(soap->path, soap->msgbuf + l, n - m);
+ soap->path[n - m] = '\0';
+ strcat(soap->endpoint, soap->path);
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint));
+ if (httpcmd > 1)
+ { switch (httpcmd)
+ { case 2: soap->error = soap->fget(soap); break;
+ case 3: soap->error = soap->fput(soap); break;
+ case 4: soap->error = soap->fdel(soap); break;
+ case 5: soap->error = soap->fhead(soap); break;
+ default: soap->error = 405; break;
+ }
+ if (soap->error == SOAP_OK)
+ soap->error = SOAP_STOP; /* prevents further processing */
+ return soap->error;
+ }
+ if (status)
+ return soap->error = status;
+ }
+ else if (status)
+ return soap->error = status;
+ else if (s)
+ return soap->error = 405;
+ }
+ /* Status OK (HTTP 200) */
+ if (soap->status == 0 || soap->status == 200)
+ return SOAP_OK;
+ /* Status 201 (Created), 202 (Accepted), ... and HTTP 400 and 500 errors
+ may not have a body. When content length, content type, or chunking is
+ used assume there is a message to parse, either XML or HTTP.
+ This version allows parsing of content when length=0:
+ if (soap->length > 0 || soap->http_content || (soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
+ */
+ if (soap->length > 0 || (soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
+ { if (((soap->status > 200 && soap->status <= 299) || soap->status == 400 || soap->status == 500))
+ return SOAP_OK;
+ /* force close afterwards in soap_closesock() */
+ soap->keep_alive = 0;
+ /* read HTTP body for error details */
+ s = soap_get_http_body(soap);
+ if (s)
+ return soap_set_receiver_error(soap, soap->msgbuf, s, soap->status);
+ }
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP error %d\n", soap->status));
+ return soap_set_receiver_error(soap, "HTTP Error", soap->msgbuf, soap->status);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_parse_header(struct soap *soap, const char *key, const char *val)
+{ if (!soap_tag_cmp(key, "Host"))
+ {
+#ifdef WITH_OPENSSL
+ if (soap->imode & SOAP_ENC_SSL)
+ strcpy(soap->endpoint, "https://");
+ else
+#endif
+ strcpy(soap->endpoint, "http://");
+ strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8);
+ soap->endpoint[sizeof(soap->endpoint) - 1] = '\0';
+ }
+#ifndef WITH_LEANER
+ else if (!soap_tag_cmp(key, "Content-Type"))
+ { const char *action;
+ soap->http_content = soap_strdup(soap, val);
+ if (soap_get_header_attribute(soap, val, "application/dime"))
+ soap->imode |= SOAP_ENC_DIME;
+ else if (soap_get_header_attribute(soap, val, "multipart/related")
+ || soap_get_header_attribute(soap, val, "multipart/form-data"))
+ { soap->mime.boundary = soap_strdup(soap, soap_get_header_attribute(soap, val, "boundary"));
+ soap->mime.start = soap_strdup(soap, soap_get_header_attribute(soap, val, "start"));
+ soap->imode |= SOAP_ENC_MIME;
+ }
+ action = soap_get_header_attribute(soap, val, "action");
+ if (action)
+ { if (*action == '"')
+ { soap->action = soap_strdup(soap, action + 1);
+ soap->action[strlen(soap->action) - 1] = '\0';
+ }
+ else
+ soap->action = soap_strdup(soap, action);
+ }
+ }
+#endif
+ else if (!soap_tag_cmp(key, "Content-Length"))
+ { soap->length = soap_strtoul(val, NULL, 10);
+ }
+ else if (!soap_tag_cmp(key, "Content-Encoding"))
+ { if (!soap_tag_cmp(val, "deflate"))
+#ifdef WITH_ZLIB
+ soap->zlib_in = SOAP_ZLIB_DEFLATE;
+#else
+ return SOAP_ZLIB_ERROR;
+#endif
+ else if (!soap_tag_cmp(val, "gzip"))
+#ifdef WITH_GZIP
+ soap->zlib_in = SOAP_ZLIB_GZIP;
+#else
+ return SOAP_ZLIB_ERROR;
+#endif
+ }
+#ifdef WITH_ZLIB
+ else if (!soap_tag_cmp(key, "Accept-Encoding"))
+ {
+#ifdef WITH_GZIP
+ if (strchr(val, '*') || soap_get_header_attribute(soap, val, "gzip"))
+ soap->zlib_out = SOAP_ZLIB_GZIP;
+ else
+#endif
+ if (strchr(val, '*') || soap_get_header_attribute(soap, val, "deflate"))
+ soap->zlib_out = SOAP_ZLIB_DEFLATE;
+ else
+ soap->zlib_out = SOAP_ZLIB_NONE;
+ }
+#endif
+ else if (!soap_tag_cmp(key, "Transfer-Encoding"))
+ { soap->imode &= ~SOAP_IO;
+ if (!soap_tag_cmp(val, "chunked"))
+ soap->imode |= SOAP_IO_CHUNK;
+ }
+ else if (!soap_tag_cmp(key, "Connection"))
+ { if (!soap_tag_cmp(val, "keep-alive"))
+ soap->keep_alive = -soap->keep_alive;
+ else if (!soap_tag_cmp(val, "close"))
+ soap->keep_alive = 0;
+ }
+#ifndef WITH_LEAN
+ else if (!soap_tag_cmp(key, "Authorization"))
+ { if (!soap_tag_cmp(val, "Basic *"))
+ { int n;
+ char *s;
+ soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n);
+ soap->tmpbuf[n] = '\0';
+ if ((s = strchr(soap->tmpbuf, ':')))
+ { *s = '\0';
+ soap->userid = soap_strdup(soap, soap->tmpbuf);
+ soap->passwd = soap_strdup(soap, s + 1);
+ }
+ }
+ }
+ else if (!soap_tag_cmp(key, "WWW-Authenticate"))
+ { soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val + 6, "realm"));
+ }
+ else if (!soap_tag_cmp(key, "Expect"))
+ { if (!soap_tag_cmp(val, "100-continue"))
+ { if ((soap->error = soap->fposthdr(soap, "HTTP/1.1 100 Continue", NULL))
+ || (soap->error = soap->fposthdr(soap, NULL, NULL)))
+ return soap->error;
+ }
+ }
+#endif
+ else if (!soap_tag_cmp(key, "SOAPAction"))
+ { if (*val == '"')
+ { soap->action = soap_strdup(soap, val + 1);
+ soap->action[strlen(soap->action) - 1] = '\0';
+ }
+ else
+ soap->action = soap_strdup(soap, val);
+ }
+ else if (!soap_tag_cmp(key, "Location"))
+ { strncpy(soap->endpoint, val, sizeof(soap->endpoint));
+ soap->endpoint[sizeof(soap->endpoint) - 1] = '\0';
+ }
+ else if (!soap_tag_cmp(key, "X-Forwarded-For"))
+ { soap->proxy_from = soap_strdup(soap, val);
+ }
+#ifdef WITH_COOKIES
+ else if (!soap_tag_cmp(key, "Cookie")
+ || !soap_tag_cmp(key, "Cookie2")
+ || !soap_tag_cmp(key, "Set-Cookie")
+ || !soap_tag_cmp(key, "Set-Cookie2"))
+ { soap_getcookies(soap, val);
+ }
+#endif
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#if !defined(WITH_NOHTTP) || !defined(WITH_LEANER)
+#ifndef PALM_1
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_get_header_attribute(struct soap *soap, const char *line, const char *key)
+{ register const char *s = line;
+ if (s)
+ { while (*s)
+ { register short flag;
+ s = soap_decode_key(soap->tmpbuf, sizeof(soap->tmpbuf), s);
+ flag = soap_tag_cmp(soap->tmpbuf, key);
+ s = soap_decode_val(soap->tmpbuf, sizeof(soap->tmpbuf), s);
+ if (!flag)
+ return soap->tmpbuf;
+ }
+ }
+ return NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#if !defined(WITH_NOHTTP) || !defined(WITH_LEANER)
+#ifndef PALM_1
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_decode_key(char *buf, size_t len, const char *val)
+{ return soap_decode(buf, len, val, "=,;");
+}
+#endif
+#endif
+
+/******************************************************************************/
+#if !defined(WITH_NOHTTP) || !defined(WITH_LEANER)
+#ifndef PALM_1
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_decode_val(char *buf, size_t len, const char *val)
+{ if (*val != '=')
+ { *buf = '\0';
+ return val;
+ }
+ return soap_decode(buf, len, val + 1, ",;");
+}
+#endif
+#endif
+
+/******************************************************************************/
+#if !defined(WITH_NOHTTP) || !defined(WITH_LEANER)
+#ifndef PALM_1
+static const char*
+soap_decode(char *buf, size_t len, const char *val, const char *sep)
+{ const char *s;
+ char *t = buf;
+ for (s = val; *s; s++)
+ if (*s != ' ' && *s != '\t' && !strchr(sep, *s))
+ break;
+ if (*s == '"')
+ { s++;
+ while (*s && *s != '"' && --len)
+ *t++ = *s++;
+ }
+ else
+ { while (*s && !soap_blank(*s) && !strchr(sep, *s) && --len)
+ { if (*s == '%')
+ { *t++ = ((s[1] >= 'A' ? (s[1] & 0x7) + 9 : s[1] - '0') << 4)
+ + (s[2] >= 'A' ? (s[2] & 0x7) + 9 : s[2] - '0');
+ s += 3;
+ }
+ else
+ *t++ = *s++;
+ }
+ }
+ *t = '\0';
+ while (*s && !strchr(sep, *s))
+ s++;
+ return s;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static const char*
+http_error(struct soap *soap, int status)
+{ register const char *msg = SOAP_STR_EOS;
+#ifndef WITH_LEAN
+ msg = soap_code_str(h_http_error_codes, status);
+ if (!msg)
+ msg = SOAP_STR_EOS;
+#endif
+ return msg;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_get(struct soap *soap)
+{ return SOAP_GET_METHOD;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_405(struct soap *soap)
+{ return 405;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count)
+{ register const char *s;
+ register int err;
+ if (soap->status == SOAP_GET)
+ s = "GET";
+ else
+ s = "POST";
+#ifdef PALM
+ if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8))
+#else
+ if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6)))
+#endif
+ return SOAP_OK;
+ if (strlen(endpoint) + strlen(soap->http_version) > sizeof(soap->tmpbuf) - 80)
+ return soap->error = SOAP_EOM;
+ if (soap->proxy_host && soap_tag_cmp(endpoint, "https:*"))
+ sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version);
+ else
+ sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, (*path == '/' ? path + 1 : path), soap->http_version);
+ if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
+ return err;
+#ifdef WITH_OPENSSL
+ if ((soap->ssl && soap->port != 443) || (!soap->ssl && soap->port != 80))
+ sprintf(soap->tmpbuf, "%s:%d", host, port);
+ else
+ strcpy(soap->tmpbuf, host);
+#else
+ if (port != 80)
+ sprintf(soap->tmpbuf, "%s:%d", host, port);
+ else
+ { /* Oracle customization */
+ strncpy(soap->tmpbuf, host, sizeof(soap->tmpbuf) - 1);
+ soap->tmpbuf[sizeof(soap->tmpbuf) - 1] = '\0';
+ }
+#endif
+// Oracle customization
+ if ((err = soap->fposthdr(soap, "Host", soap->tmpbuf))
+ || (err = soap->fposthdr(soap, "User-Agent", "SunKMS gSOAP/2.7.17"))
+ || (err = soap_puthttphdr(soap, SOAP_OK, count)))
+ return err;
+#ifdef WITH_ZLIB
+#ifdef WITH_GZIP
+ if ((err = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate")))
+#else
+ if ((err = soap->fposthdr(soap, "Accept-Encoding", "deflate")))
+#endif
+ return err;
+#endif
+#ifndef WITH_LEAN
+ if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761)
+ { sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd);
+ strcpy(soap->tmpbuf, "Basic ");
+ soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262));
+ if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf)))
+ return err;
+ }
+ if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761)
+ { sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd);
+ strcpy(soap->tmpbuf, "Basic ");
+ soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262));
+ if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf)))
+ return err;
+ }
+#endif
+#ifdef WITH_COOKIES
+#ifdef WITH_OPENSSL
+ if (soap_putcookies(soap, host, path, soap->ssl != NULL))
+ return soap->error;
+#else
+ if (soap_putcookies(soap, host, path, 0))
+ return soap->error;
+#endif
+#endif
+ if (soap->status != SOAP_GET && (soap->version == 1 || (action && *action)))
+ { sprintf(soap->tmpbuf, "\"%s\"", action && strlen(action) < sizeof(soap->tmpbuf) - 3 ? action : SOAP_STR_EOS);
+ if ((err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf)))
+ return err;
+ }
+ return soap->fposthdr(soap, NULL, NULL);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_send_header(struct soap *soap, const char *s)
+{ register const char *t;
+ do
+ { t = strchr(s, '\n'); /* disallow \n in HTTP headers */
+ if (!t)
+ t = s + strlen(s);
+ if (soap_send_raw(soap, s, t - s))
+ return soap->error;
+ s = t + 1;
+ } while (*t);
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_post_header(struct soap *soap, const char *key, const char *val)
+{ if (key)
+ { if (http_send_header(soap, key))
+ return soap->error;
+ if (val && (soap_send_raw(soap, ": ", 2) || http_send_header(soap, val)))
+ return soap->error;
+ }
+ return soap_send_raw(soap, "\r\n", 2);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+static int
+http_response(struct soap *soap, int status, size_t count)
+{ register int err;
+#ifdef WMW_RPM_IO
+ if (soap->rpmreqid)
+ httpOutputEnable(soap->rpmreqid);
+#endif
+ if (strlen(soap->http_version) > 4)
+ return soap->error = SOAP_EOM;
+ if (!status || status == SOAP_HTML || status == SOAP_FILE)
+ { const char *s;
+ if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK))
+ s = "200 OK";
+ else
+ s = "202 ACCEPTED";
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Status = %s\n", s));
+#ifdef WMW_RPM_IO
+ if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */
+#else
+ if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application (socket) or CGI (stdin/out)? */
+#endif
+ { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s);
+ if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
+ return err;
+ }
+ else if ((err = soap->fposthdr(soap, "Status", s))) /* CGI header */
+ return err;
+ }
+ else if (status >= 200 && status < 600)
+ { sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status));
+ if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
+ return err;
+#ifndef WITH_LEAN
+ if (status == 401)
+ { sprintf(soap->tmpbuf, "Basic realm=\"%s\"", (soap->authrealm && strlen(soap->authrealm) < sizeof(soap->tmpbuf) - 14) ? soap->authrealm : "gSOAP Web Service");
+ if ((err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf)))
+ return err;
+ }
+ else if ((status >= 301 && status <= 303) || status == 307)
+ { if ((err = soap->fposthdr(soap, "Location", soap->endpoint)))
+ return err;
+ }
+#endif
+ }
+ else
+ { const char *s = *soap_faultcode(soap);
+ if (status >= SOAP_GET_METHOD && status <= SOAP_HTTP_METHOD)
+ s = "405 Method Not Allowed";
+ else if (soap->version == 2 && (!s || !strcmp(s, "SOAP-ENV:Sender")))
+ s = "400 Bad Request";
+ else
+ s = "500 Internal Server Error";
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error %s (status=%d)\n", s, status));
+#ifdef WMW_RPM_IO
+ if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */
+#else
+ if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */
+#endif
+ { sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s);
+ if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
+ return err;
+ }
+ else if ((err = soap->fposthdr(soap, "Status", s))) /* CGI */
+ return err;
+ }
+ if ((err = soap->fposthdr(soap, "Server", "gSOAP/2.7"))
+ || (err = soap_puthttphdr(soap, status, count)))
+ return err;
+#ifdef WITH_COOKIES
+ if (soap_putsetcookies(soap))
+ return soap->error;
+#endif
+ return soap->fposthdr(soap, NULL, NULL);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_response(struct soap *soap, int status)
+{ register size_t count;
+ if (!(soap->omode & (SOAP_ENC_XML | SOAP_IO_STORE /* this tests for chunking too */))
+ && (status == SOAP_HTML || status == SOAP_FILE))
+ soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE;
+ soap->status = status;
+ count = soap_count_attachments(soap);
+ if (soap_begin_send(soap))
+ return soap->error;
+#ifndef WITH_NOHTTP
+ if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML))
+ { register int n = soap->mode;
+ soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB);
+ if ((n & SOAP_IO) != SOAP_IO_FLUSH)
+ soap->mode |= SOAP_IO_BUFFER;
+ if ((soap->error = soap->fresponse(soap, status, count)))
+ return soap->error;
+#ifndef WITH_LEANER
+ if ((n & SOAP_IO) == SOAP_IO_CHUNK)
+ { if (soap_flush(soap))
+ return soap->error;
+ }
+#endif
+ soap->mode = n;
+ }
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************\
+ *
+ * HTTP Cookies
+ *
+\******************************************************************************/
+
+#ifdef WITH_COOKIES
+/******************************************************************************/
+SOAP_FMAC1
+size_t
+SOAP_FMAC2
+soap_encode_cookie(const char *s, char *t, size_t len)
+{ register int c;
+ register size_t n = len;
+ while ((c = *s++) && --n > 0)
+ { if (c > ' ' && c < 128 && !strchr("()<>@,;:\\\"/[]?={}#!$&'*+", c))
+ *t++ = c;
+ else if (n > 2)
+ { *t++ = '%';
+ *t++ = (c >> 4) + (c > 159 ? '7' : '0');
+ c &= 0xF;
+ *t++ = c + (c > 9 ? '7' : '0');
+ n -= 2;
+ }
+ else
+ break;
+ }
+ *t = '\0';
+ return len - n;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+struct soap_cookie*
+SOAP_FMAC2
+soap_cookie(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ if (!domain)
+ domain = soap->cookie_domain;
+ if (!path)
+ path = soap->cookie_path;
+ if (!path)
+ path = SOAP_STR_EOS;
+ else if (*path == '/')
+ path++;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Search cookie %s domain=%s path=%s\n", name, domain?domain:"(null)", path?path:"(null)"));
+ for (p = soap->cookies; p; p = p->next)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie in database: %s=%s domain=%s path=%s env=%hd\n", p->name, p->value?p->value:"(null)", p->domain?p->domain:"(null)", p->path?p->path:"(null)", p->env));
+ if (!strcmp(p->name, name)
+ && p->domain
+ && p->path
+ && !strcmp(p->domain, domain)
+ && (!*p->path || !strncmp(p->path, path, strlen(p->path))))
+ break;
+ }
+ return p;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+struct soap_cookie*
+SOAP_FMAC2
+soap_set_cookie(struct soap *soap, const char *name, const char *value, const char *domain, const char *path)
+{ struct soap_cookie **p, *q;
+ int n;
+ if (!domain)
+ domain = soap->cookie_domain;
+ if (!path)
+ path = soap->cookie_path;
+ if (!path)
+ path = SOAP_STR_EOS;
+ else if (*path == '/')
+ path++;
+ q = soap_cookie(soap, name, domain, path);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set %scookie: %s=%s domain=%s path=%s\n", q ? SOAP_STR_EOS : "new ", name, value?value:"(null)", domain?domain:"(null)", path?path:"(null)"));
+ if (!q)
+ { if ((q = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie))))
+ { if ((q->name = (char*)SOAP_MALLOC(soap, strlen(name)+1)))
+ strcpy(q->name, name);
+ q->value = NULL;
+ q->domain = NULL;
+ q->path = NULL;
+ q->expire = 0;
+ q->maxage = -1;
+ q->version = 1;
+ q->secure = 0;
+ q->modified = 0;
+ for (p = &soap->cookies, n = soap->cookie_max; *p && n; p = &(*p)->next, n--)
+ if (!strcmp((*p)->name, name) && (*p)->path && path && strcmp((*p)->path, path) < 0)
+ break;
+ if (n)
+ { q->next = *p;
+ *p = q;
+ }
+ else
+ { SOAP_FREE(soap, q->name);
+ SOAP_FREE(soap, q);
+ q = NULL;
+ }
+ }
+ }
+ else
+ q->modified = 1;
+ if (q)
+ { if (q->value)
+ { if (!value || strcmp(value, q->value))
+ { SOAP_FREE(soap, q->value);
+ q->value = NULL;
+ }
+ }
+ if (value && *value && !q->value && (q->value = (char*)SOAP_MALLOC(soap, strlen(value)+1)))
+ strcpy(q->value, value);
+ if (q->domain)
+ { if (!domain || strcmp(domain, q->domain))
+ { SOAP_FREE(soap, q->domain);
+ q->domain = NULL;
+ }
+ }
+ if (domain && !q->domain && (q->domain = (char*)SOAP_MALLOC(soap, strlen(domain)+1)))
+ strcpy(q->domain, domain);
+ if (q->path)
+ { if (!path || strncmp(path, q->path, strlen(q->path)))
+ { SOAP_FREE(soap, q->path);
+ q->path = NULL;
+ }
+ }
+ if (path && !q->path && (q->path = (char*)SOAP_MALLOC(soap, strlen(path)+1)))
+ strcpy(q->path, path);
+ q->session = 1;
+ q->env = 0;
+ }
+ return q;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie **p, *q;
+ if (!domain)
+ domain = soap->cookie_domain;
+ if (!domain)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error in clear cookie %s: cookie domain not set\n", name?name:"(null)"));
+ return;
+ }
+ if (!path)
+ path = soap->cookie_path;
+ if (!path)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error in clear cookie %s: cookie path not set\n", name?name:"(null)"));
+ return;
+ }
+ if (*path == '/')
+ path++;
+ for (p = &soap->cookies, q = *p; q; q = *p)
+ { if (!strcmp(q->name, name) && !strcmp(q->domain, domain) && !strncmp(q->path, path, strlen(q->path)))
+ { if (q->value)
+ SOAP_FREE(soap, q->value);
+ if (q->domain)
+ SOAP_FREE(soap, q->domain);
+ if (q->path)
+ SOAP_FREE(soap, q->path);
+ *p = q->next;
+ SOAP_FREE(soap, q);
+ }
+ else
+ p = &q->next;
+ }
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ if ((p = soap_cookie(soap, name, domain, path)))
+ return p->value;
+ return NULL;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_env_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ if ((p = soap_cookie(soap, name, domain, path)) && p->env)
+ return p->value;
+ return NULL;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+time_t
+SOAP_FMAC2
+soap_cookie_expire(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ if ((p = soap_cookie(soap, name, domain, path)))
+ return p->expire;
+ return -1;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie expiration max-age %ld: %s domain=%s path=%s\n", expire, name, domain?domain:"(null)", path?path:"(null)"));
+ if ((p = soap_cookie(soap, name, domain, path)))
+ { p->maxage = expire;
+ p->modified = 1;
+ return SOAP_OK;
+ }
+ return SOAP_ERR;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ if ((p = soap_cookie(soap, name, domain, path)))
+ { p->session = 1;
+ p->modified = 1;
+ return SOAP_OK;
+ }
+ return SOAP_ERR;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path)
+{ struct soap_cookie *p;
+ if ((p = soap_cookie(soap, name, domain, path)))
+ { p->session = 0;
+ p->modified = 1;
+ return SOAP_OK;
+ }
+ return SOAP_ERR;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putsetcookies(struct soap *soap)
+{ struct soap_cookie *p;
+ char *s, tmp[4096];
+ const char *t;
+ for (p = soap->cookies; p; p = p->next)
+ {
+ if (p->modified
+#ifdef WITH_OPENSSL
+ || (!p->env && !soap->ssl == !p->secure)
+#endif
+ )
+ { s = tmp;
+ if (p->name)
+ s += soap_encode_cookie(p->name, s, tmp-s+4064);
+ if (p->value && *p->value)
+ { *s++ = '=';
+ s += soap_encode_cookie(p->value, s, tmp-s+4064);
+ }
+ if (p->domain && (int)strlen(p->domain) < tmp-s+4064)
+ { strcpy(s, ";Domain=");
+ strcat(s, p->domain);
+ }
+ else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < tmp-s+4064)
+ { strcpy(s, ";Domain=");
+ strcat(s, soap->cookie_domain);
+ }
+ strcat(s, ";Path=/");
+ s += strlen(s);
+ if (p->path)
+ t = p->path;
+ else
+ t = soap->cookie_path;
+ if (t)
+ { if (*t == '/')
+ t++;
+ if ((int)strlen(t) < tmp-s+4064)
+ { if (strchr(t, '%')) /* already URL encoded? */
+ { strcpy(s, t);
+ s += strlen(s);
+ }
+ else
+ s += soap_encode_cookie(t, s, tmp-s+4064);
+ }
+ }
+ if (p->version > 0 && s-tmp < 4060)
+ { sprintf(s, ";Version=%u", p->version);
+ s += strlen(s);
+ }
+ if (p->maxage >= 0 && s-tmp < 4060)
+ { sprintf(s, ";Max-Age=%ld", p->maxage);
+ s += strlen(s);
+ }
+ if (s-tmp < 4073
+ && (p->secure
+#ifdef WITH_OPENSSL
+ || soap->ssl
+#endif
+ ))
+ strcpy(s, ";Secure");
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set-Cookie: %s\n", tmp));
+ if ((soap->error = soap->fposthdr(soap, "Set-Cookie", tmp)))
+ return soap->error;
+ }
+ }
+ return SOAP_OK;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putcookies(struct soap *soap, const char *domain, const char *path, int secure)
+{ struct soap_cookie **p, *q;
+ unsigned int version = 0;
+ time_t now = time(NULL);
+ char *s, tmp[4096];
+ p = &soap->cookies;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending cookies for domain=%s path=%s\n", domain, path));
+ if (*path == '/')
+ path++;
+ while ((q = *p))
+ { if (q->expire && now > q->expire)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie %s expired\n", q->name));
+ SOAP_FREE(soap, q->name);
+ if (q->value)
+ SOAP_FREE(soap, q->value);
+ if (q->domain)
+ SOAP_FREE(soap, q->domain);
+ if (q->path)
+ SOAP_FREE(soap, q->path);
+ *p = q->next;
+ SOAP_FREE(soap, q);
+ }
+ else
+ { int flag;
+ char *t = q->domain;
+ size_t n = 0;
+ if (!t)
+ flag = 1;
+ else
+ { const char *r = strchr(t, ':');
+ if (r)
+ n = r - t;
+ else
+ n = strlen(t);
+ flag = !strncmp(t, domain, n);
+ }
+ /* domain-level cookies, cannot compile when WITH_NOIO set */
+#ifndef WITH_NOIO
+ if (!flag)
+ { struct hostent *hostent = gethostbyname((char*)domain);
+ if (hostent)
+ { const char *r = strchr(hostent->h_name, '.');
+ if (!r)
+ r = hostent->h_name;
+ flag = !strncmp(t, r, n);
+ }
+ }
+#endif
+ if (flag
+ && (!q->path || !strncmp(q->path, path, strlen(q->path)))
+ && (!q->secure || secure))
+ { s = tmp;
+ if (q->version != version)
+ { sprintf(s, "$Version=%u;", q->version);
+ version = q->version;
+ }
+ if (q->name)
+ s += soap_encode_cookie(q->name, s, tmp-s+4080);
+ if (q->value && *q->value)
+ { *s++ = '=';
+ s += soap_encode_cookie(q->value, s, tmp-s+4080);
+ }
+ if (q->path && *q->path && (int)strlen(q->path) < tmp-s+4080)
+ { sprintf(s, ";$Path=\"/%s\"", (*q->path == '/' ? q->path + 1 : q->path));
+ s += strlen(s);
+ }
+ if (q->domain && (int)strlen(q->domain) < tmp-s+4080)
+ sprintf(s, ";$Domain=\"%s\"", q->domain);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp));
+ if ((soap->error = soap->fposthdr(soap, "Cookie", tmp)))
+ return soap->error;
+ }
+ p = &q->next;
+ }
+ }
+ return SOAP_OK;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_getcookies(struct soap *soap, const char *val)
+{ struct soap_cookie *p = NULL, *q;
+ const char *s;
+ char *t, tmp[4096]; /* cookie size is up to 4096 bytes [RFC2109] */
+ char *domain = NULL;
+ char *path = NULL;
+ unsigned int version = 0;
+ time_t now = time(NULL);
+ if (!val)
+ return;
+ s = val;
+ while (*s)
+ { s = soap_decode_key(tmp, sizeof(tmp), s);
+ if (!soap_tag_cmp(tmp, "$Version"))
+ { if ((s = soap_decode_val(tmp, sizeof(tmp), s)))
+ { if (p)
+ p->version = (int)soap_strtol(tmp, NULL, 10);
+ else
+ version = (int)soap_strtol(tmp, NULL, 10);
+ }
+ }
+ else if (!soap_tag_cmp(tmp, "$Path"))
+ { s = soap_decode_val(tmp, sizeof(tmp), s);
+ if (*tmp)
+ { if ((t = (char*)SOAP_MALLOC(soap, strlen(tmp)+1)))
+ strcpy(t, tmp);
+ }
+ else
+ t = NULL;
+ if (p)
+ { if (p->path)
+ SOAP_FREE(soap, p->path);
+ p->path = t;
+ }
+ else
+ { if (path)
+ SOAP_FREE(soap, path);
+ path = t;
+ }
+ }
+ else if (!soap_tag_cmp(tmp, "$Domain"))
+ { s = soap_decode_val(tmp, sizeof(tmp), s);
+ if (*tmp)
+ { if ((t = (char*)SOAP_MALLOC(soap, strlen(tmp)+1)))
+ strcpy(t, tmp);
+ }
+ else
+ t = NULL;
+ if (p)
+ { if (p->domain)
+ SOAP_FREE(soap, p->domain);
+ p->domain = t;
+ }
+ else
+ { if (domain)
+ SOAP_FREE(soap, domain);
+ domain = t;
+ }
+ }
+ else if (p && !soap_tag_cmp(tmp, "Path"))
+ { if (p->path)
+ SOAP_FREE(soap, p->path);
+ s = soap_decode_val(tmp, sizeof(tmp), s);
+ if (*tmp)
+ { if ((p->path = (char*)SOAP_MALLOC(soap, strlen(tmp)+1)))
+ strcpy(p->path, tmp);
+ }
+ else
+ p->path = NULL;
+ }
+ else if (p && !soap_tag_cmp(tmp, "Domain"))
+ { if (p->domain)
+ SOAP_FREE(soap, p->domain);
+ s = soap_decode_val(tmp, sizeof(tmp), s);
+ if (*tmp)
+ { if ((p->domain = (char*)SOAP_MALLOC(soap, strlen(tmp)+1)))
+ strcpy(p->domain, tmp);
+ }
+ else
+ p->domain = NULL;
+ }
+ else if (p && !soap_tag_cmp(tmp, "Version"))
+ { s = soap_decode_val(tmp, sizeof(tmp), s);
+ p->version = (unsigned int)soap_strtoul(tmp, NULL, 10);
+ }
+ else if (p && !soap_tag_cmp(tmp, "Max-Age"))
+ { s = soap_decode_val(tmp, sizeof(tmp), s);
+ p->expire = now + soap_strtol(tmp, NULL, 10);
+ }
+ else if (p && !soap_tag_cmp(tmp, "Expires"))
+ { struct tm T;
+ char a[3];
+ static const char mns[] = "anebarprayunulugepctovec";
+ s = soap_decode_val(tmp, sizeof(tmp), s);
+ if (strlen(tmp) > 20)
+ { memset((void*)&T, 0, sizeof(T));
+ a[0] = tmp[4];
+ a[1] = tmp[5];
+ a[2] = '\0';
+ T.tm_mday = (int)soap_strtol(a, NULL, 10);
+ a[0] = tmp[8];
+ a[1] = tmp[9];
+ T.tm_mon = (int)(strstr(mns, a) - mns) / 2;
+ a[0] = tmp[11];
+ a[1] = tmp[12];
+ T.tm_year = 100 + (int)soap_strtol(a, NULL, 10);
+ a[0] = tmp[13];
+ a[1] = tmp[14];
+ T.tm_hour = (int)soap_strtol(a, NULL, 10);
+ a[0] = tmp[16];
+ a[1] = tmp[17];
+ T.tm_min = (int)soap_strtol(a, NULL, 10);
+ a[0] = tmp[19];
+ a[1] = tmp[20];
+ T.tm_sec = (int)soap_strtol(a, NULL, 10);
+ p->expire = soap_timegm(&T);
+ }
+ }
+ else if (p && !soap_tag_cmp(tmp, "Secure"))
+ p->secure = 1;
+ else
+ { if (p)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"(null)", p->domain?p->domain:"(null)", p->path?p->path:"(null)", p->expire, p->secure));
+ if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path)))
+ { q->version = p->version;
+ q->expire = p->expire;
+ q->secure = p->secure;
+ q->env = 1;
+ }
+ if (p->name)
+ SOAP_FREE(soap, p->name);
+ if (p->value)
+ SOAP_FREE(soap, p->value);
+ if (p->domain)
+ SOAP_FREE(soap, p->domain);
+ if (p->path)
+ SOAP_FREE(soap, p->path);
+ SOAP_FREE(soap, p);
+ }
+ if ((p = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie))))
+ { p->name = (char*)SOAP_MALLOC(soap, strlen(tmp)+1);
+ strcpy(p->name, tmp);
+ s = soap_decode_val(tmp, sizeof(tmp), s);
+ if (*tmp)
+ { p->value = (char*)SOAP_MALLOC(soap, strlen(tmp)+1);
+ strcpy(p->value, tmp);
+ }
+ else
+ p->value = NULL;
+ if (domain)
+ p->domain = domain;
+ else if (*soap->host)
+ { p->domain = (char*)SOAP_MALLOC(soap, strlen(soap->host)+1);
+ strcpy(p->domain, soap->host);
+ }
+ else
+ p->domain = NULL;
+ if (path)
+ p->path = path;
+ else if (soap->path && *soap->path)
+ { p->path = (char*)SOAP_MALLOC(soap, strlen(soap->path)+1);
+ strcpy(p->path, soap->path);
+ }
+ else
+ { p->path = (char*)SOAP_MALLOC(soap, 2);
+ strcpy(p->path, "/");
+ }
+ p->expire = 0;
+ p->secure = 0;
+ p->version = version;
+ }
+ }
+ }
+ if (p)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie %s=%s domain=%s path=%s expire=%ld secure=%d\n", p->name, p->value?p->value:"(null)", p->domain?p->domain:"(null)", p->path?p->path:"(null)", p->expire, p->secure));
+ if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path)))
+ { q->version = p->version;
+ q->expire = p->expire;
+ q->secure = p->secure;
+ q->env = 1;
+ }
+ if (p->name)
+ SOAP_FREE(soap, p->name);
+ if (p->value)
+ SOAP_FREE(soap, p->value);
+ if (p->domain)
+ SOAP_FREE(soap, p->domain);
+ if (p->path)
+ SOAP_FREE(soap, p->path);
+ SOAP_FREE(soap, p);
+ }
+ if (domain)
+ SOAP_FREE(soap, domain);
+ if (path)
+ SOAP_FREE(soap, path);
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getenv_cookies(struct soap *soap)
+{ struct soap_cookie *p;
+ const char *s;
+ char key[4096], val[4096]; /* cookie size is up to 4096 bytes [RFC2109] */
+ if (!(s = getenv("HTTP_COOKIE")))
+ return SOAP_ERR;
+ do
+ { s = soap_decode_key(key, sizeof(key), s);
+ s = soap_decode_val(val, sizeof(val), s);
+ p = soap_set_cookie(soap, key, val, NULL, NULL);
+ if (p)
+ p->env = 1;
+ } while (*s);
+ return SOAP_OK;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+struct soap_cookie*
+SOAP_FMAC2
+soap_copy_cookies(struct soap *copy, const struct soap *soap)
+{ struct soap_cookie *p, **q, *r;
+ q = &r;
+ for (p = soap->cookies; p; p = p->next)
+ { if (!(*q = (struct soap_cookie*)SOAP_MALLOC(copy, sizeof(struct soap_cookie))))
+ return r;
+ **q = *p;
+ if (p->name)
+ { if (((*q)->name = (char*)SOAP_MALLOC(copy, strlen(p->name)+1)))
+ strcpy((*q)->name, p->name);
+ }
+ if (p->value)
+ { if (((*q)->value = (char*)SOAP_MALLOC(copy, strlen(p->value)+1)))
+ strcpy((*q)->value, p->value);
+ }
+ if (p->domain)
+ { if (((*q)->domain = (char*)SOAP_MALLOC(copy, strlen(p->domain)+1)))
+ strcpy((*q)->domain, p->domain);
+ }
+ if (p->path)
+ { if (((*q)->path = (char*)SOAP_MALLOC(copy, strlen(p->path)+1)))
+ strcpy((*q)->path, p->path);
+ }
+ q = &(*q)->next;
+ }
+ *q = NULL;
+ return r;
+}
+
+/******************************************************************************/
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_free_cookies(struct soap *soap)
+{ struct soap_cookie *p;
+ for (p = soap->cookies; p; p = soap->cookies)
+ { soap->cookies = p->next;
+ SOAP_FREE(soap, p->name);
+ if (p->value)
+ SOAP_FREE(soap, p->value);
+ if (p->domain)
+ SOAP_FREE(soap, p->domain);
+ if (p->path)
+ SOAP_FREE(soap, p->path);
+ SOAP_FREE(soap, p);
+ }
+}
+
+/******************************************************************************/
+#endif /* WITH_COOKIES */
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+size_t
+SOAP_FMAC2
+soap_hash(register const char *s)
+{ register size_t h = 0;
+ while (*s)
+ h = 65599*h + *s++;
+ return h % SOAP_IDHASH;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+static void
+soap_init_pht(struct soap *soap)
+{ register int i;
+ soap->pblk = NULL;
+ soap->pidx = 0;
+ for (i = 0; i < (int)SOAP_PTRHASH; i++)
+ soap->pht[i] = NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap*
+SOAP_FMAC2
+soap_new1(soap_mode mode)
+{ return soap_new2(mode, mode);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap*
+SOAP_FMAC2
+soap_new()
+{ return soap_new2(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap*
+SOAP_FMAC2
+soap_new2(soap_mode imode, soap_mode omode)
+{ struct soap *soap = (struct soap*)malloc(sizeof(struct soap));
+ if (soap)
+ soap_init2(soap, imode, omode);
+ return soap;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_free(struct soap *soap)
+{ soap_done(soap);
+ free(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_del(struct soap *soap)
+{ free(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+static void
+soap_free_pht(struct soap *soap)
+{ register struct soap_pblk *pb, *next;
+ register int i;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free pointer hashtable\n"));
+ for (pb = soap->pblk; pb; pb = next)
+ { next = pb->next;
+ SOAP_FREE(soap, pb);
+ }
+ soap->pblk = NULL;
+ soap->pidx = 0;
+ for (i = 0; i < (int)SOAP_PTRHASH; i++)
+ soap->pht[i] = NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type)
+{ register int i;
+ struct soap_plist *pp;
+ if (soap->version == 2)
+ soap->encoding = 1;
+ if (a)
+ i = soap_array_pointer_lookup(soap, p, a, n, type, &pp);
+ else
+ i = soap_pointer_lookup(soap, p, type, &pp);
+ if (i)
+ { if (soap_is_embedded(soap, pp)
+ || soap_is_single(soap, pp))
+ return 0;
+ soap_set_embedded(soap, pp);
+ }
+ return i;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plist **ppp)
+{ register struct soap_plist *pp;
+ *ppp = NULL;
+ if (p)
+ { for (pp = soap->pht[soap_hash_ptr(p)]; pp; pp = pp->next)
+ { if (pp->ptr == p && pp->type == type)
+ { *ppp = pp;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d id=%d\n", p, type, pp->id));
+ return pp->id;
+ }
+ }
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup location=%p type=%d: not found\n", p, type));
+ return 0;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
+{ register size_t h;
+ register struct soap_plist *pp;
+ if (!soap->pblk || soap->pidx >= SOAP_PTRBLK)
+ { register struct soap_pblk *pb = (struct soap_pblk*)SOAP_MALLOC(soap, sizeof(struct soap_pblk));
+ if (!pb)
+ { soap->error = SOAP_EOM;
+ return 0;
+ }
+ pb->next = soap->pblk;
+ soap->pblk = pb;
+ soap->pidx = 0;
+ }
+ *ppp = pp = &soap->pblk->plist[soap->pidx++];
+ if (a)
+ h = soap_hash_ptr(a->__ptr);
+ else
+ h = soap_hash_ptr(p);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%d dim=%d type=%d id=%d\n", p, a?a->__ptr:NULL, a?a->__size:0, n, type, soap->idnum+1));
+ pp->next = soap->pht[h];
+ pp->type = type;
+ pp->mark1 = 0;
+ pp->mark2 = 0;
+ pp->ptr = p;
+ pp->array = a;
+ soap->pht[h] = pp;
+ pp->id = ++soap->idnum;
+ return pp->id;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
+{ register struct soap_plist *pp;
+ *ppp = NULL;
+ if (!p || !a->__ptr)
+ return 0;
+ for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next)
+ { if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr)
+ { register int i;
+ for (i = 0; i < n; i++)
+ if (((const int*)&pp->array->__size)[i] != ((const int*)&a->__size)[i])
+ break;
+ if (i == n)
+ { *ppp = pp;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id));
+ return pp->id;
+ }
+ }
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type));
+ return 0;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_begin_count(struct soap *soap)
+{ soap_free_ns(soap);
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_ENC_DIME) || (soap->omode & SOAP_ENC_DIME))
+ soap->mode = soap->omode | SOAP_IO_LENGTH | SOAP_ENC_DIME;
+ else
+#endif
+ { soap->mode = soap->omode;
+ if ((soap->mode & SOAP_IO_UDP))
+ soap->mode |= SOAP_ENC_XML;
+ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE
+ || (((soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_ENC_XML))
+#ifndef WITH_LEANER
+ && !soap->fpreparesend
+#endif
+ ))
+ soap->mode &= ~SOAP_IO_LENGTH;
+ else
+ soap->mode |= SOAP_IO_LENGTH;
+ }
+#ifdef WITH_ZLIB
+ if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH)
+ { if (!(soap->mode & SOAP_ENC_DIME))
+ soap->mode &= ~SOAP_IO_LENGTH;
+ if (soap->mode & SOAP_ENC_XML)
+ soap->mode |= SOAP_IO_BUFFER;
+ else
+ soap->mode |= SOAP_IO_STORE;
+ }
+#endif
+ if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH))
+ soap->mode |= SOAP_XML_TREE;
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_ENC_MTOM) && (soap->mode & SOAP_ENC_DIME))
+ soap->mode |= SOAP_ENC_MIME;
+ else if (!(soap->mode & SOAP_ENC_MIME))
+ soap->mode &= ~SOAP_ENC_MTOM;
+ if (soap->mode & SOAP_ENC_MIME)
+ soap_select_mime_boundary(soap);
+ soap->dime.list = soap->dime.last; /* keep track of last DIME attachment */
+#endif
+ soap->count = 0;
+ soap->ns = 0;
+ soap->null = 0;
+ soap->position = 0;
+ soap->mustUnderstand = 0;
+ soap->encoding = 0;
+ soap->part = SOAP_BEGIN;
+ soap->idnum = 0;
+ soap_clr_attr(soap);
+ soap_set_local_namespaces(soap);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, (unsigned int)soap->mode, (unsigned long)soap->count));
+#ifndef WITH_LEANER
+ soap->dime.count = 0; /* count # of attachments */
+ soap->dime.size = 0; /* accumulate total size of attachments */
+ if (soap->fprepareinitsend && (soap->mode & SOAP_IO) != SOAP_IO_STORE)
+ return soap->error = soap->fprepareinitsend(soap);
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_end_count(struct soap *soap)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of count phase\n"));
+#ifndef WITH_LEANER
+ if (soap->fpreparefinalsend && (soap->mode & SOAP_IO_LENGTH))
+ return soap->error = soap->fpreparefinalsend(soap);
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_begin_send(struct soap *soap)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for output\n"));
+ soap_free_ns(soap);
+ soap->error = SOAP_OK;
+ soap->mode = soap->omode | (soap->mode & (SOAP_IO_LENGTH | SOAP_ENC_DIME));
+#ifdef WITH_ZLIB
+ if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH)
+ { if (soap->mode & SOAP_ENC_XML)
+ soap->mode |= SOAP_IO_BUFFER;
+ else
+ soap->mode |= SOAP_IO_STORE;
+ }
+#endif
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_IO_UDP))
+ { soap->mode |= SOAP_ENC_XML;
+ if (soap->count > SOAP_BUFLEN)
+ return soap->error = SOAP_UDP_ERROR;
+ }
+#endif
+ if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket))
+ { if (soap->count || (soap->mode & SOAP_IO_LENGTH) || (soap->mode & SOAP_ENC_XML))
+ soap->mode |= SOAP_IO_BUFFER;
+ else
+ soap->mode |= SOAP_IO_STORE;
+ }
+ soap->mode &= ~SOAP_IO_LENGTH;
+ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
+ if (soap_new_block(soap) == NULL)
+ return soap->error;
+ if (!(soap->mode & SOAP_IO_KEEPALIVE))
+ soap->keep_alive = 0;
+ if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH))
+ soap->mode |= SOAP_XML_TREE;
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_ENC_MTOM) && (soap->mode & SOAP_ENC_DIME))
+ { soap->mode |= SOAP_ENC_MIME;
+ soap->mode &= ~SOAP_ENC_DIME;
+ }
+ else if (!(soap->mode & SOAP_ENC_MIME))
+ soap->mode &= ~SOAP_ENC_MTOM;
+ if (soap->mode & SOAP_ENC_MIME)
+ soap_select_mime_boundary(soap);
+#ifdef WIN32
+#ifndef UNDER_CE
+#ifndef WITH_FASTCGI
+ if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */
+#ifdef __BORLANDC__
+ setmode(soap->sendfd, _O_BINARY);
+#else
+ _setmode(soap->sendfd, _O_BINARY);
+#endif
+#endif
+#endif
+#endif
+#endif
+ if (soap->mode & SOAP_IO)
+ { soap->bufidx = 0;
+ soap->buflen = 0;
+ }
+ soap->chunksize = 0;
+ soap->ns = 0;
+ soap->null = 0;
+ soap->position = 0;
+ soap->mustUnderstand = 0;
+ soap->encoding = 0;
+ soap->idnum = 0;
+ soap->level = 0;
+ soap_clr_attr(soap);
+ soap_set_local_namespaces(soap);
+#ifdef WITH_ZLIB
+ soap->z_ratio_out = 1.0;
+ if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE)
+ { if (!soap->z_buf)
+ soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
+ soap->d_stream->next_out = (Byte*)soap->z_buf;
+ soap->d_stream->avail_out = SOAP_BUFLEN;
+#ifdef WITH_GZIP
+ if (soap->zlib_out != SOAP_ZLIB_DEFLATE)
+ { memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10);
+ soap->d_stream->next_out = (Byte*)soap->z_buf + 10;
+ soap->d_stream->avail_out = SOAP_BUFLEN - 10;
+ soap->z_crc = crc32(0L, NULL, 0);
+ soap->zlib_out = SOAP_ZLIB_GZIP;
+ if (soap->z_dict)
+ *((Byte*)soap->z_buf + 2) = 0xff;
+ if (deflateInit2(soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ else
+#endif
+ if (deflateInit(soap->d_stream, soap->z_level) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ if (soap->z_dict)
+ { if (deflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n"));
+ soap->zlib_state = SOAP_ZLIB_DEFLATE;
+ }
+#endif
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ ERR_clear_error();
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count));
+ soap->part = SOAP_BEGIN;
+#ifndef WITH_LEANER
+ if (soap->fprepareinitsend && (soap->mode & SOAP_IO) == SOAP_IO_STORE)
+ soap->fprepareinitsend(soap);
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_embedded(struct soap *soap, const void *p, int t)
+{ struct soap_plist *pp;
+ if (soap_pointer_lookup(soap, p, t, &pp))
+ { pp->mark1 = 1;
+ pp->mark2 = 1;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded %p type=%d mark set to 1\n", p, t));
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_reference(struct soap *soap, const void *p, int t)
+{ struct soap_plist *pp;
+ if (!p || (soap->mode & SOAP_XML_TREE))
+ return 1;
+ if (soap_pointer_lookup(soap, p, t, &pp))
+ { if (pp->mark1 == 0)
+ { pp->mark1 = 2;
+ pp->mark2 = 2;
+ }
+ }
+ else if (soap_pointer_enter(soap, p, NULL, 0, t, &pp))
+ { pp->mark1 = 0;
+ pp->mark2 = 0;
+ }
+ else
+ return 1;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reference %p type=%d (%d %d)\n", p, t, (int)pp->mark1, (int)pp->mark2));
+ return pp->mark1;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_array_reference(struct soap *soap, const void *p, const struct soap_array *a, int n, int t)
+{ register int i;
+ struct soap_plist *pp;
+ if (!p || !a->__ptr)
+ return 1;
+ i = soap_array_pointer_lookup(soap, p, a, n, t, &pp);
+ if (i)
+ { if (pp->mark1 == 0)
+ { pp->mark1 = 2;
+ pp->mark2 = 2;
+ }
+ }
+ else if (!soap_pointer_enter(soap, p, a, n, t, &pp))
+ return 1;
+ else
+ { pp->mark1 = 0;
+ pp->mark2 = 0;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p dim=%d type=%d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2));
+ return pp->mark1;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_embedded_id(struct soap *soap, int id, const void *p, int t)
+{ struct soap_plist *pp = NULL;
+ if (soap->mode & SOAP_XML_TREE)
+ return id;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id %p type=%d id=%d\n", p, t, id));
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH) && soap->part != SOAP_IN_HEADER)
+ { if (id < 0)
+ { id = soap_pointer_lookup(soap, p, t, &pp);
+ if (id)
+ { if (soap->mode & SOAP_IO_LENGTH)
+ pp->mark1 = 2;
+ else
+ pp->mark2 = 2;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id multiref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2));
+ }
+ return -1;
+ }
+ return id;
+ }
+ if (id < 0)
+ id = soap_pointer_lookup(soap, p, t, &pp);
+ else if (id && !soap_pointer_lookup(soap, p, t, &pp))
+ return 0;
+ if (id && pp)
+ { if (soap->mode & SOAP_IO_LENGTH)
+ pp->mark1 = 1;
+ else
+ pp->mark2 = 1;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id embedded ref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2));
+ }
+ return id;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_is_embedded(struct soap *soap, struct soap_plist *pp)
+{ if (!pp)
+ return 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Is embedded? %d %d\n", (int)pp->mark1, (int)pp->mark2));
+ if (soap->version == 1 && soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH) && soap->part != SOAP_IN_HEADER)
+ { if (soap->mode & SOAP_IO_LENGTH)
+ return pp->mark1 != 0;
+ return pp->mark2 != 0;
+ }
+ if (soap->mode & SOAP_IO_LENGTH)
+ return pp->mark1 == 1;
+ return pp->mark2 == 1;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_is_single(struct soap *soap, struct soap_plist *pp)
+{ if (soap->part == SOAP_IN_HEADER)
+ return 1;
+ if (!pp)
+ return 0;
+ if (soap->mode & SOAP_IO_LENGTH)
+ return pp->mark1 == 0;
+ return pp->mark2 == 0;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_embedded(struct soap *soap, struct soap_plist *pp)
+{ if (!pp)
+ return;
+ if (soap->mode & SOAP_IO_LENGTH)
+ pp->mark1 = 1;
+ else
+ pp->mark2 = 1;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, const char *aid, const char *atype, const char *aoptions, int n, const char *type, int t)
+{
+#ifndef WITH_NOIDREF
+ struct soap_plist *pp = NULL; /* Oracle customization */
+ int i;
+ if (!p || !a->__ptr || (!aid && !atype))
+ return soap_element_id(soap, tag, id, p, a, n, type, t);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid?aid:SOAP_STR_EOS, id, atype?atype:SOAP_STR_EOS));
+ i = soap_array_pointer_lookup(soap, p, a, n, t, &pp);
+ if (!i)
+ { i = soap_pointer_enter(soap, p, a, n, t, &pp);
+ if (!i)
+ { soap->error = SOAP_EOM;
+ return -1;
+ }
+ }
+ if (id <= 0)
+ id = i;
+ if (!aid)
+ { sprintf(soap->tmpbuf, soap->dime_id_format, id);
+ aid = soap_strdup(soap, soap->tmpbuf);
+ }
+ /* Add MTOM xop:Include element when necessary */
+ /* TODO: this code to be obsoleted with new import/xop.h conventions */
+ if ((soap->mode & SOAP_ENC_MTOM) && strcmp(tag, "xop:Include"))
+ { if (soap_element_begin_out(soap, tag, 0, type)
+ || soap_element_href(soap, "xop:Include", 0, "xmlns:xop=\"http://www.w3.org/2004/08/xop/include\" href", aid)
+ || soap_element_end_out(soap, tag))
+ return soap->error;
+ }
+ else if (soap_element_href(soap, tag, 0, "href", aid))
+ return soap->error;
+ if (soap->mode & SOAP_IO_LENGTH)
+ { if (pp && (pp->mark1 != 3)) /* Oracle customization */
+ { struct soap_multipart *content;
+ if (soap->mode & SOAP_ENC_MTOM)
+ content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, (char*)a->__ptr, a->__size);
+ else
+ content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a->__ptr, a->__size);
+ if (!content)
+ { soap->error = SOAP_EOM;
+ return -1;
+ }
+ if (!strncmp(aid, "cid:", 4)) /* RFC 2111 */
+ { if (soap->mode & SOAP_ENC_MTOM)
+ { char *s = (char*)soap_malloc(soap, strlen(aid) - 1);
+ if (s)
+ { *s = '<';
+ strcpy(s + 1, aid + 4);
+ strcat(s, ">");
+ content->id = s;
+ }
+ }
+ else
+ content->id = aid + 4;
+ }
+ else
+ content->id = aid;
+ content->type = atype;
+ content->options = aoptions;
+ content->encoding = SOAP_MIME_BINARY;
+ pp->mark1 = 3;
+ }
+ }
+ else if (pp) /* Oracle customization */
+ pp->mark2 = 3;
+#endif
+ return -1;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+static void
+soap_init_iht(struct soap *soap)
+{ register int i;
+ for (i = 0; i < SOAP_IDHASH; i++)
+ soap->iht[i] = NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_1
+static void
+soap_free_iht(struct soap *soap)
+{ register int i;
+ register struct soap_ilist *ip = NULL, *p = NULL;
+ register struct soap_flist *fp = NULL, *fq = NULL;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free ID hashtable\n"));
+ for (i = 0; i < SOAP_IDHASH; i++)
+ { for (ip = soap->iht[i]; ip; ip = p)
+ { for (fp = ip->flist; fp; fp = fq)
+ { fq = fp->next;
+ SOAP_FREE(soap, fp);
+ }
+ p = ip->next;
+ SOAP_FREE(soap, ip);
+ }
+ soap->iht[i] = NULL;
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+struct soap_ilist *
+SOAP_FMAC2
+soap_lookup(struct soap *soap, const char *id)
+{ register struct soap_ilist *ip = NULL;
+ for (ip = soap->iht[soap_hash(id)]; ip; ip = ip->next)
+ if (!strcmp(ip->id, id))
+ return ip;
+ return NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+struct soap_ilist *
+SOAP_FMAC2
+soap_enter(struct soap *soap, const char *id)
+{ register size_t h;
+ register struct soap_ilist *ip;
+ ip = (struct soap_ilist*)SOAP_MALLOC(soap, sizeof(struct soap_ilist) + strlen(id));
+ if (ip)
+ { h = soap_hash(id);
+ strcpy(ip->id, id);
+ ip->next = soap->iht[h];
+ soap->iht[h] = ip;
+ }
+ return ip;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void*
+SOAP_FMAC2
+soap_malloc(struct soap *soap, size_t n)
+{ register char *p;
+ if (!n)
+ return (void*)SOAP_NON_NULL;
+ if (!soap)
+ return SOAP_MALLOC(soap, n);
+ if (soap->fmalloc)
+ p = (char*)soap->fmalloc(soap, n);
+ else
+ { n += sizeof(short);
+ n += (-(long)n) & (sizeof(void*)-1); /* align at 4-, 8- or 16-byte boundary */
+ if (!(p = (char*)SOAP_MALLOC(soap, n + sizeof(void*) + sizeof(size_t))))
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ /* set the canary to detect corruption */
+ *(unsigned short*)(p + n - sizeof(unsigned short)) = (unsigned short)SOAP_CANARY;
+ /* keep chain of alloced cells for destruction */
+ *(void**)(p + n) = soap->alist;
+ *(size_t*)(p + n + sizeof(void*)) = n;
+ soap->alist = p + n;
+ }
+ soap->alloced = 1;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_MEM_DEBUG
+static void
+soap_init_mht(struct soap *soap)
+{ register int i;
+ for (i = 0; i < (int)SOAP_PTRHASH; i++)
+ soap->mht[i] = NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_MEM_DEBUG
+static void
+soap_free_mht(struct soap *soap)
+{ register int i;
+ register struct soap_mlist *mp, *mq;
+ for (i = 0; i < (int)SOAP_PTRHASH; i++)
+ { for (mp = soap->mht[i]; mp; mp = mq)
+ { mq = mp->next;
+ if (mp->live)
+ {
+ fprintf(stderr, "%s(%d): malloc() = %p not freed (memory leak or forgot to call soap_end()?)\n", mp->file, mp->line, mp->ptr);
+#ifndef WIN32
+ (void) printstack( 2 ); /* Oracle customization */
+#endif
+ }
+ free(mp);
+ }
+ soap->mht[i] = NULL;
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_MEM_DEBUG
+SOAP_FMAC1
+void*
+SOAP_FMAC2
+soap_track_malloc(struct soap *soap, const char *file, int line, size_t size)
+{ register void *p = malloc(size);
+ if (soap)
+ { register size_t h = soap_hash_ptr(p);
+ register struct soap_mlist *mp = (struct soap_mlist*)malloc(sizeof(struct soap_mlist));
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): malloc(%lu) = %p\n", file, line, (unsigned long)size, p));
+ mp->next = soap->mht[h];
+ mp->ptr = p;
+ mp->file = file;
+ mp->line = line;
+ mp->live = 1;
+ soap->mht[h] = mp;
+ }
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_MEM_DEBUG
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_track_free(struct soap *soap, const char *file, int line, void *p)
+{ register size_t h = soap_hash_ptr(p);
+ register struct soap_mlist *mp;
+ for (mp = soap->mht[h]; mp; mp = mp->next)
+ if (mp->ptr == p)
+ break;
+ if (mp)
+ { if (mp->live)
+ { free(p);
+ if (soap->fdebug[SOAP_INDEX_TEST])
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): free(%p)\n", file, line, p));
+ }
+ mp->live = 0;
+ }
+ else
+ fprintf(stderr, "%s(%d): free(%p) double free of pointer malloced at %s(%d)\n", file, line, p, mp->file, mp->line);
+ }
+ else
+ fprintf(stderr, "%s(%d): free(%p) pointer not malloced\n", file, line, p);
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_MEM_DEBUG
+static void
+soap_track_unlink(struct soap *soap, const void *p)
+{ register size_t h = soap_hash_ptr(p);
+ register struct soap_mlist *mp;
+ for (mp = soap->mht[h]; mp; mp = mp->next)
+ if (mp->ptr == p)
+ break;
+ if (mp)
+ mp->live = 0;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_dealloc(struct soap *soap, void *p)
+{ if (soap_check_state(soap))
+ return;
+ if (p)
+ { register char **q;
+ for (q = (char**)&soap->alist; *q; q = *(char***)q)
+ {
+ if (*(unsigned short*)(char*)(*q - sizeof(unsigned short)) != (unsigned short)SOAP_CANARY)
+ {
+#ifdef SOAP_MEM_DEBUG
+ fprintf(stderr, "Data corruption in dynamic allocation (see logs)\n");
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Data corruption:\n"));
+ DBGHEX(TEST, *q - 200, 200);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\n"));
+ soap->error = SOAP_MOE;
+ return;
+ }
+ if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*))))
+ { *q = **(char***)q;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Freed data at %p\n", p));
+ SOAP_FREE(soap, p);
+ return;
+ }
+ }
+ soap_delete(soap, p);
+ }
+ else
+ { register char *q;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free all soap_malloc() data\n"));
+ while (soap->alist)
+ { q = (char*)soap->alist;
+ if (*(unsigned short*)(char*)(q - sizeof(unsigned short)) != (unsigned short)SOAP_CANARY)
+ {
+#ifdef SOAP_MEM_DEBUG
+ fprintf(stderr, "Data corruption in dynamic allocation (see logs)\n");
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Data corruption:\n"));
+ DBGHEX(TEST, q - 200, 200);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\n"));
+ soap->error = SOAP_MOE;
+ return;
+ }
+ soap->alist = *(void**)q;
+ q -= *(size_t*)(q + sizeof(void*));
+ SOAP_FREE(soap, q);
+ }
+ /* we must assume these were deallocated: */
+ soap->action = NULL;
+ soap->fault = NULL;
+ soap->header = NULL;
+ soap->userid = NULL;
+ soap->passwd = NULL;
+ soap->authrealm = NULL;
+ soap->http_content = NULL;
+#ifndef WITH_LEANER
+ soap_clr_mime(soap);
+#endif
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_delete(struct soap *soap, void *p)
+{ register struct soap_clist **cp;
+ if (soap_check_state(soap))
+ return;
+ cp = &soap->clist;
+ if (p)
+ { while (*cp)
+ { if (p == (*cp)->ptr)
+ { register struct soap_clist *q = *cp;
+ *cp = q->next;
+ if (q->fdelete(q))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: deletion callback failed for object type %d\n", q->ptr, q->type));
+#ifdef SOAP_MEM_DEBUG
+ fprintf(stderr, "new(object type = %d) = %p not freed: deletion callback failed\n", q->type, q->ptr);
+#endif
+ }
+ SOAP_FREE(soap, q);
+ return;
+ }
+ cp = &(*cp)->next;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: address not in list\n", p));
+ }
+ else
+ { while (*cp)
+ { register struct soap_clist *q = *cp;
+ *cp = q->next;
+ if (q->fdelete(q))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: deletion callback failed for object type %d\n", q->ptr, q->type));
+#ifdef SOAP_MEM_DEBUG
+ fprintf(stderr, "new(object type = %d) = %p not freed: deletion callback failed\n", q->type, q->ptr);
+#endif
+ }
+ SOAP_FREE(soap, q);
+ }
+ }
+ soap->fault = NULL; /* this was possibly deallocated */
+ soap->header = NULL; /* this was possibly deallocated */
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_delegate_deletion(struct soap *soap, struct soap *soap_to)
+{ register struct soap_clist *cp;
+ register char **q;
+#ifdef SOAP_MEM_DEBUG
+ register void *p;
+ register struct soap_mlist **mp, *mq;
+ size_t h;
+#endif
+ for (q = (char**)&soap->alist; *q; q = *(char***)q)
+ {
+ if (*(unsigned short*)(char*)(*q - sizeof(unsigned short)) != (unsigned short)SOAP_CANARY)
+ {
+#ifdef SOAP_MEM_DEBUG
+ fprintf(stderr, "Data corruption in dynamic allocation (see logs)\n");
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Data corruption:\n"));
+ DBGHEX(TEST, *q - 200, 200);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\n"));
+ soap->error = SOAP_MOE;
+ return;
+ }
+#ifdef SOAP_MEM_DEBUG
+ p = (void*)(*q - *(size_t*)(*q + sizeof(void*)));
+ h = soap_hash_ptr(p);
+ for (mp = &soap->mht[h]; *mp; mp = &(*mp)->next)
+ { if ((*mp)->ptr == p)
+ { mq = *mp;
+ *mp = mq->next;
+ mq->next = soap_to->mht[h];
+ soap_to->mht[h] = mq;
+ break;
+ }
+ }
+#endif
+ }
+ *q = (char*)soap_to->alist;
+ soap_to->alist = soap->alist;
+ soap->alist = NULL;
+ cp = soap_to->clist;
+ if (cp)
+ { while (cp->next)
+ cp = cp->next;
+ cp->next = soap->clist;
+ }
+ else
+ soap_to->clist = soap->clist;
+ soap->clist = NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+struct soap_clist *
+SOAP_FMAC2
+soap_link(struct soap *soap, void *p, int t, int n, int (*fdelete)(struct soap_clist*))
+{ register struct soap_clist *cp;
+ if ((cp = (struct soap_clist*)SOAP_MALLOC(soap, sizeof(struct soap_clist))))
+ { cp->next = soap->clist;
+ cp->type = t;
+ cp->size = n;
+ cp->ptr = p;
+ cp->fdelete = fdelete;
+ soap->clist = cp;
+ }
+ return cp;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_unlink(struct soap *soap, const void *p)
+{ register char **q;
+ register struct soap_clist **cp;
+ if (!soap || !p)
+ return;
+ for (q = (char**)&soap->alist; *q; q = *(char***)q)
+ { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*))))
+ { *q = **(char***)q;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p));
+#ifdef SOAP_MEM_DEBUG
+ soap_track_unlink(soap, p);
+#endif
+ return;
+ }
+ }
+ for (cp = &soap->clist; *cp; cp = &(*cp)->next)
+ { if (p == (*cp)->ptr)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked class instance %p\n", p));
+ q = (char**)*cp;
+ *cp = (*cp)->next;
+ SOAP_FREE(soap, q);
+ return;
+ }
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_lookup_type(struct soap *soap, const char *id)
+{ register struct soap_ilist *ip;
+ if (id && *id)
+ { ip = soap_lookup(soap, id);
+ if (ip)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup id='%s' type=%d\n", id, ip->type));
+ return ip->type;
+ }
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "lookup type id='%s' NOT FOUND! Need to get it from xsi:type\n", id));
+ return 0;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+void*
+SOAP_FMAC2
+soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k)
+{ struct soap_ilist *ip;
+ void **q;
+ if (!p || !id || !*id)
+ return p;
+ ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */
+ if (!ip)
+ { if (!(ip = soap_enter(soap, id))) /* new hash table entry for string id */
+ return NULL;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' type=%d %p (%u bytes)\n", id, t, p, (unsigned int)n));
+ ip->type = t;
+ ip->size = n;
+ ip->link = p;
+ ip->copy = NULL;
+ ip->flist = NULL;
+ ip->ptr = NULL;
+ ip->level = k;
+ *p = NULL;
+ }
+ else if (ip->ptr)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type=%d location=%p (%u bytes)\n", id, t, ip->ptr, (unsigned int)n));
+ if (ip->type != t)
+ {
+ /* Oracle customization */
+ strncpy(soap->id, id, sizeof(soap->id) - 1);
+ soap->id[sizeof(soap->id) - 1] = '\0';
+ soap->error = SOAP_HREF;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility: href='%s' id-type=%d href-type=%d\n", id, ip->type, t));
+ return NULL;
+ }
+ while (ip->level < k)
+ { q = (void**)soap_malloc(soap, sizeof(void*));
+ if (!q)
+ return NULL;
+ *p = (void*)q;
+ p = q;
+ k--;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n"));
+ }
+ *p = ip->ptr;
+ }
+ else if (ip->level > k)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id));
+ while (ip->level > k)
+ { void *s, **r = &ip->link;
+ q = (void**)ip->link;
+ while (q)
+ { *r = (void*)soap_malloc(soap, sizeof(void*));
+ if (!*r)
+ return NULL;
+ s = *q;
+ *q = *r;
+ r = (void**)*r;
+ q = (void**)s;
+ }
+ *r = NULL;
+ ip->size = n;
+ ip->copy = NULL;
+ ip->level = ip->level - 1;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n"));
+ }
+ q = (void**)ip->link;
+ ip->link = p;
+ *p = (void*)q;
+ }
+ else
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' type=%d location=%p (%u bytes)\n", id, t, p, (unsigned int)n));
+ while (ip->level < k)
+ { q = (void**)soap_malloc(soap, sizeof(void*));
+ if (!q)
+ return NULL;
+ *p = q;
+ p = q;
+ k--;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n"));
+ }
+ q = (void**)ip->link;
+ ip->link = p;
+ *p = (void*)q;
+ }
+ return p;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIDREF
+#ifndef PALM_2
+SOAP_FMAC1
+void*
+SOAP_FMAC2
+soap_id_forward(struct soap *soap, const char *href, void *p, size_t len, int st, int tt, size_t n, unsigned int k, void (*fcopy)(struct soap*, int, int, void*, size_t, const void*, size_t))
+{ struct soap_ilist *ip;
+ if (!p || !href || !*href)
+ return p;
+ ip = soap_lookup(soap, href); /* lookup pointer to hash table entry for string id */
+ if (!ip)
+ { if (!(ip = soap_enter(soap, href))) /* new hash table entry for string id */
+ return NULL;
+ ip->type = st;
+ ip->size = n;
+ ip->link = NULL;
+ ip->copy = NULL;
+ ip->ptr = NULL;
+ ip->level = 0;
+ ip->flist = NULL;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry href='%s' type=%d size=%lu level=%d location=%p\n", href, st, (unsigned long)n, k, p));
+ }
+ else if (ip->type != st || (ip->level == k && ip->size != n))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", href, ip->type, (unsigned long)ip->size, k, st, (unsigned long)n));
+ /* Oracle customization */
+ strncpy(soap->id, href, sizeof(soap->id) - 1);
+ soap->id[sizeof(soap->id) - 1] = '\0';
+ soap->error = SOAP_HREF;
+ return NULL;
+ }
+ if (fcopy || n < sizeof(void*) || *href != '#')
+ { register struct soap_flist *fp = (struct soap_flist*)SOAP_MALLOC(soap, sizeof(struct soap_flist));
+ if (!fp)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ fp->next = ip->flist;
+ fp->type = tt;
+ fp->ptr = p;
+ fp->level = k;
+ fp->len = len;
+ if (fcopy)
+ fp->fcopy = fcopy;
+ else
+ fp->fcopy = soap_fcopy;
+ ip->flist = fp;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding type=%d (target type=%d) size=%lu location=%p level=%u len=%lu href='%s'\n", st, tt, (unsigned long)n, p, k, (unsigned long)len, href));
+ }
+ else
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type=%d href='%s'\n", p, st, href));
+ *(void**)p = ip->copy;
+ ip->copy = p;
+ }
+ return p;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void*
+SOAP_FMAC2
+soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*))
+{
+#ifndef WITH_NOIDREF
+ struct soap_ilist *ip;
+#endif
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d loc=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k));
+ soap->alloced = 0;
+ if (!p)
+ { if (finstantiate)
+ p = finstantiate(soap, t, type, arrayType, &n);
+ else
+ p = soap_malloc(soap, n);
+ if (p)
+ soap->alloced = 1;
+ }
+#ifndef WITH_NOIDREF
+ if (!id || !*id)
+#endif
+ return p;
+#ifndef WITH_NOIDREF
+ ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Lookup entry id='%s for location=%p'\n", id, p));
+ if (!ip)
+ { if (!(ip = soap_enter(soap, id))) /* new hash table entry for string id */
+ return NULL;
+ ip->type = t;
+ ip->link = NULL;
+ ip->copy = NULL;
+ ip->flist = NULL;
+ ip->size = n;
+ ip->ptr = p;
+ ip->level = k;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%lu level=%u location=%p\n", id, t, (unsigned long)n, k, p));
+ }
+ else if ((ip->type != t || (ip->level == k && ip->size != n)) && (ip->copy || ip->flist))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", id, ip->type, (unsigned long)ip->size, k, t, (unsigned long)n));
+ /* Oracle customization */
+ strncpy(soap->id, id, sizeof(soap->id) - 1);
+ soap->id[sizeof(soap->id) - 1] = '\0';
+ soap->error = SOAP_HREF;
+ return NULL;
+ }
+ else if (ip->ptr)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Multiply defined id='%s'\n", id));
+ /* Oracle customization */
+ strncpy(soap->id, id, sizeof(soap->id) - 1);
+ soap->id[sizeof(soap->id) - 1] = '\0';
+ soap->error = SOAP_DUPLICATE_ID;
+ return NULL;
+ }
+ else
+ { ip->size = n;
+ ip->ptr = p;
+ ip->level = k;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update entry id='%s' type=%d location=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k));
+ }
+ return ip->ptr;
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_fcopy(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
+{ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Copying data type=%d (target type=%d) %p -> %p (%lu bytes)\n", st, tt, q, p, (unsigned long)n));
+ memcpy(p, q, n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_end_send(struct soap *soap)
+{
+#ifndef WITH_LEANER
+ int err;
+ if (soap->dime.list)
+ { /* SOAP body referenced attachments must appear first */
+ soap->dime.last->next = soap->dime.first;
+ soap->dime.first = soap->dime.list->next;
+ soap->dime.list->next = NULL;
+ soap->dime.last = soap->dime.list;
+ }
+ if (!(err = soap_putdime(soap)))
+ err = soap_putmime(soap);
+ soap->mime.list = NULL;
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->dime.list = NULL;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+ if (err)
+ return err;
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End send\n"));
+ if (soap->mode & SOAP_IO) /* need to flush the remaining data in buffer */
+ { if (soap_flush(soap))
+#ifdef WITH_ZLIB
+ { if (soap->mode & SOAP_ENC_ZLIB && soap->zlib_state == SOAP_ZLIB_DEFLATE)
+ { soap->zlib_state = SOAP_ZLIB_NONE;
+ deflateEnd(soap->d_stream);
+ }
+ return soap->error;
+ }
+#else
+ return soap->error;
+#endif
+#ifdef WITH_ZLIB
+ if (soap->mode & SOAP_ENC_ZLIB)
+ { int r;
+ soap->d_stream->avail_in = 0;
+ do
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n"));
+ r = deflate(soap->d_stream, Z_FINISH);
+ if (soap->d_stream->avail_out != SOAP_BUFLEN)
+ { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream->avail_out))
+ { soap->zlib_state = SOAP_ZLIB_NONE;
+ deflateEnd(soap->d_stream);
+ return soap->error;
+ }
+ soap->d_stream->next_out = (Byte*)soap->z_buf;
+ soap->d_stream->avail_out = SOAP_BUFLEN;
+ }
+ } while (r == Z_OK);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated total %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out));
+ soap->z_ratio_out = (float)soap->d_stream->total_out / (float)soap->d_stream->total_in;
+ soap->mode &= ~SOAP_ENC_ZLIB;
+ soap->zlib_state = SOAP_ZLIB_NONE;
+ if (deflateEnd(soap->d_stream) != Z_OK || r != Z_STREAM_END)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unable to end deflate: %s\n", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS));
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+#ifdef WITH_GZIP
+ if (soap->zlib_out != SOAP_ZLIB_DEFLATE)
+ { soap->z_buf[0] = soap->z_crc & 0xFF;
+ soap->z_buf[1] = (soap->z_crc >> 8) & 0xFF;
+ soap->z_buf[2] = (soap->z_crc >> 16) & 0xFF;
+ soap->z_buf[3] = (soap->z_crc >> 24) & 0xFF;
+ soap->z_buf[4] = soap->d_stream->total_in & 0xFF;
+ soap->z_buf[5] = (soap->d_stream->total_in >> 8) & 0xFF;
+ soap->z_buf[6] = (soap->d_stream->total_in >> 16) & 0xFF;
+ soap->z_buf[7] = (soap->d_stream->total_in >> 24) & 0xFF;
+ if (soap_flush_raw(soap, soap->z_buf, 8))
+ return soap->error;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip crc32=%lu\n", (unsigned long)soap->z_crc));
+ }
+#endif
+ }
+#endif
+ if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
+ { char *p;
+#ifndef WITH_NOHTTP
+ if (!(soap->mode & SOAP_ENC_XML))
+ { soap->mode--;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size));
+ if (soap->status >= SOAP_POST)
+ soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size);
+ else if (soap->status != SOAP_STOP)
+ soap->error = soap->fresponse(soap, soap->status, soap->blist->size);
+ if (soap->error || soap_flush(soap))
+ return soap->error;
+ soap->mode++;
+ }
+#endif
+ for (p = soap_first_block(soap, NULL); p; p = soap_next_block(soap, NULL))
+ { DBGMSG(SENT, p, soap_block_size(soap, NULL));
+ if ((soap->error = soap->fsend(soap, p, soap_block_size(soap, NULL))))
+ { soap_end_block(soap, NULL);
+ return soap->error;
+ }
+ }
+ soap_end_block(soap, NULL);
+ }
+#ifndef WITH_LEANER
+ else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
+ { DBGMSG(SENT, "\r\n0\r\n\r\n", 7);
+ if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7)))
+ return soap->error;
+ }
+#endif
+ }
+#ifdef WITH_TCPFIN
+#ifdef WITH_OPENSSL
+ if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP))
+ soap->fshutdownsocket(soap, soap->socket, 1); /* Send TCP FIN */
+#else
+ if (soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP))
+ soap->fshutdownsocket(soap, soap->socket, 1); /* Send TCP FIN */
+#endif
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send phase\n"));
+ soap->omode &= ~SOAP_XML_SEC;
+ soap->count = 0;
+ soap->part = SOAP_END;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_end_recv(struct soap *soap)
+{ soap->part = SOAP_END;
+#ifndef WITH_LEAN
+ soap->wsuid = NULL; /* reset before next send */
+ soap->c14nexclude = NULL; /* reset before next send */
+#endif
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_ENC_DIME) && soap_getdime(soap))
+ { soap->dime.first = NULL;
+ soap->dime.last = NULL;
+ return soap->error;
+ }
+ soap->dime.list = soap->dime.first;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+ /* Check if MIME attachments and mime-post-check flag is set, if set call soap_resolve() and return */
+ if (soap->mode & SOAP_ENC_MIME)
+ {
+#ifndef WITH_NOIDREF
+ if (soap->mode & SOAP_MIME_POSTCHECK)
+ { soap_resolve(soap);
+ return SOAP_OK;
+ }
+#endif
+ if (soap_getmime(soap))
+ return soap->error;
+ }
+ soap->mime.list = soap->mime.first;
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->mime.boundary = NULL;
+ if (soap->xlist)
+ { struct soap_multipart *content;
+ for (content = soap->mime.list; content; content = content->next)
+ soap_resolve_attachment(soap, content);
+ }
+#endif
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "End of receive message ok\n"));
+#ifdef WITH_ZLIB
+ if (soap->mode & SOAP_ENC_ZLIB)
+ { /* Make sure end of compressed content is reached */
+ while (soap->d_stream->next_out != Z_NULL)
+ if ((int)soap_get1(soap) == EOF)
+ break;
+ soap->mode &= ~SOAP_ENC_ZLIB;
+ memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN);
+ soap->bufidx = (char*)soap->d_stream->next_in - soap->z_buf;
+ soap->buflen = soap->z_buflen;
+ soap->zlib_state = SOAP_ZLIB_NONE;
+ if (inflateEnd(soap->d_stream) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Inflate end ok\n"));
+#ifdef WITH_GZIP
+ if (soap->zlib_in == SOAP_ZLIB_GZIP)
+ { soap_wchar c;
+ short i;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Inflate gzip crc check\n"));
+ for (i = 0; i < 8; i++)
+ { if ((int)(c = soap_get1(soap)) == EOF)
+ return soap->error = SOAP_EOF;
+ soap->z_buf[i] = (char)c;
+ }
+ if (soap->z_crc != ((uLong)(unsigned char)soap->z_buf[0] | ((uLong)(unsigned char)soap->z_buf[1] << 8) | ((uLong)(unsigned char)soap->z_buf[2] << 16) | ((uLong)(unsigned char)soap->z_buf[3] << 24)))
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: crc check failed, message corrupted? (crc32=%lu)\n", (unsigned long)soap->z_crc));
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ if (soap->d_stream->total_out != ((uLong)(unsigned char)soap->z_buf[4] | ((uLong)(unsigned char)soap->z_buf[5] << 8) | ((uLong)(unsigned char)soap->z_buf[6] << 16) | ((uLong)(unsigned char)soap->z_buf[7] << 24)))
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: incorrect message length\n"));
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ }
+ soap->zlib_in = SOAP_ZLIB_NONE;
+#endif
+ }
+#endif
+ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
+ while ((int)soap_getchar(soap) != EOF) /* advance to last chunk */
+ ;
+#ifndef WITH_NOIDREF
+ if (soap_resolve(soap))
+ return soap->error;
+#endif
+#ifndef WITH_LEANER
+ if (soap->xlist)
+ { if (soap->mode & SOAP_ENC_MTOM)
+ return soap->error = SOAP_MIME_HREF;
+ return soap->error = SOAP_DIME_HREF;
+ }
+#endif
+ soap_free_ns(soap);
+#ifndef WITH_LEANER
+ if (soap->fpreparefinalrecv)
+ return soap->error = soap->fpreparefinalrecv(soap);
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_free_temp(struct soap *soap)
+{ register struct soap_attribute *tp, *tq;
+ register struct Namespace *ns;
+ soap_free_ns(soap);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free any remaining temp blocks\n"));
+ while (soap->blist)
+ soap_end_block(soap, NULL);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attribute storage\n"));
+ for (tp = soap->attributes; tp; tp = tq)
+ { tq = tp->next;
+ if (tp->value)
+ SOAP_FREE(soap, tp->value);
+ SOAP_FREE(soap, tp);
+ }
+ soap->attributes = NULL;
+#ifdef WITH_FAST
+ if (soap->labbuf)
+ SOAP_FREE(soap, soap->labbuf);
+ soap->labbuf = NULL;
+ soap->lablen = 0;
+ soap->labidx = 0;
+#endif
+ ns = soap->local_namespaces;
+ if (ns)
+ { for (; ns->id; ns++)
+ { if (ns->out)
+ { if (soap->encodingStyle == ns->out)
+ soap->encodingStyle = SOAP_STR_EOS;
+ SOAP_FREE(soap, ns->out);
+ ns->out = NULL;
+ }
+ if (soap->encodingStyle == ns->ns)
+ soap->encodingStyle = SOAP_STR_EOS;
+ }
+ SOAP_FREE(soap, soap->local_namespaces);
+ soap->local_namespaces = NULL;
+ }
+#ifndef WITH_LEANER
+ while (soap->xlist)
+ { struct soap_xlist *xp = soap->xlist->next;
+ SOAP_FREE(soap, soap->xlist);
+ soap->xlist = xp;
+ }
+#endif
+#ifndef WITH_NOIDREF
+ soap_free_pht(soap);
+ soap_free_iht(soap);
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static void
+soap_free_ns(struct soap *soap)
+{ register struct soap_nlist *np, *nq;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free namespace stack\n"));
+ for (np = soap->nlist; np; np = nq)
+ { nq = np->next;
+ SOAP_FREE(soap, np);
+ }
+ soap->nlist = NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+#if !defined(WITH_LEAN) || defined(SOAP_DEBUG)
+static void
+soap_init_logs(struct soap *soap)
+{ int i;
+ for (i = 0; i < SOAP_MAXLOGS; i++)
+ { soap->logfile[i] = NULL;
+ soap->fdebug[i] = NULL;
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#if !defined(WITH_LEAN) || defined(SOAP_DEBUG)
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_open_logfile(struct soap *soap, int i)
+{ if (soap->logfile[i])
+ soap->fdebug[i] = fopen(soap->logfile[i], i < 2 ? "ab" : "a");
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_DEBUG
+static void
+soap_close_logfile(struct soap *soap, int i)
+{ if (soap->fdebug[i])
+ { fclose(soap->fdebug[i]);
+ soap->fdebug[i] = NULL;
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_DEBUG
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_close_logfiles(struct soap *soap)
+{ int i;
+ for (i = 0; i < SOAP_MAXLOGS; i++)
+ soap_close_logfile(soap, i);
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_DEBUG
+static void
+soap_set_logfile(struct soap *soap, int i, const char *logfile)
+{ const char *s;
+ char *t = NULL;
+ soap_close_logfile(soap, i);
+ s = soap->logfile[i];
+ soap->logfile[i] = logfile;
+ if (s)
+ SOAP_FREE(soap, (void*)s);
+ if (logfile)
+ if ((t = (char*)SOAP_MALLOC(soap, strlen(logfile) + 1)))
+ strcpy(t, logfile);
+ soap->logfile[i] = t;
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_DEBUG
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_recv_logfile(struct soap *soap, const char *logfile)
+{ soap_set_logfile(soap, SOAP_INDEX_RECV, logfile);
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_DEBUG
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_sent_logfile(struct soap *soap, const char *logfile)
+{ soap_set_logfile(soap, SOAP_INDEX_SENT, logfile);
+}
+#endif
+
+/******************************************************************************/
+#ifdef SOAP_DEBUG
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_test_logfile(struct soap *soap, const char *logfile)
+{ soap_set_logfile(soap, SOAP_INDEX_TEST, logfile);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap*
+SOAP_FMAC2
+soap_copy(const struct soap *soap)
+{ return soap_copy_context((struct soap*)malloc(sizeof(struct soap)), soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap*
+SOAP_FMAC2
+soap_copy_context(struct soap *copy, const struct soap *soap)
+{ if (soap_check_state(soap))
+ return NULL;
+ if (copy)
+ { register struct soap_plugin *p = NULL;
+#ifdef __cplusplus
+ *copy = *soap;
+#else
+ memcpy(copy, soap, sizeof(struct soap));
+#endif
+ copy->state = SOAP_COPY;
+ copy->error = SOAP_OK;
+ copy->userid = NULL;
+ copy->passwd = NULL;
+ copy->nlist = NULL;
+ copy->blist = NULL;
+ copy->clist = NULL;
+ copy->alist = NULL;
+ copy->attributes = NULL;
+ copy->labbuf = NULL;
+ copy->lablen = 0;
+ copy->labidx = 0;
+#ifdef SOAP_MEM_DEBUG
+ soap_init_mht(copy);
+#endif
+#if !defined(WITH_LEAN) || defined(SOAP_DEBUG)
+ soap_init_logs(copy);
+#endif
+#ifdef SOAP_DEBUG
+ soap_set_test_logfile(copy, soap->logfile[SOAP_INDEX_TEST]);
+ soap_set_sent_logfile(copy, soap->logfile[SOAP_INDEX_SENT]);
+ soap_set_recv_logfile(copy, soap->logfile[SOAP_INDEX_RECV]);
+#endif
+#ifdef WITH_C_LOCALE
+ copy->c_locale = duplocale(soap->c_locale);
+#else
+ copy->c_locale = NULL;
+#endif
+#ifdef WITH_OPENSSL
+ copy->bio = NULL;
+ copy->ssl = NULL;
+ copy->session = NULL;
+#endif
+#ifdef WITH_ZLIB
+ copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream));
+ copy->d_stream->zalloc = Z_NULL;
+ copy->d_stream->zfree = Z_NULL;
+ copy->d_stream->opaque = Z_NULL;
+ copy->z_buf = NULL;
+#endif
+ copy->local_namespaces = NULL;
+#ifndef WITH_NOIDREF
+ soap_init_iht(copy);
+ soap_init_pht(copy);
+#endif
+ copy->header = NULL;
+ copy->fault = NULL;
+ copy->action = NULL;
+#ifndef WITH_LEAN
+#ifdef WITH_COOKIES
+ copy->cookies = soap_copy_cookies(copy, soap);
+#else
+ copy->cookies = NULL;
+#endif
+#endif
+ copy->plugins = NULL;
+ for (p = soap->plugins; p; p = p->next)
+ { register struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(copy, sizeof(struct soap_plugin));
+ if (!q)
+ return NULL;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying plugin '%s'\n", p->id));
+ *q = *p;
+ if (p->fcopy && p->fcopy(copy, q, p))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not copy plugin '%s'\n", p->id));
+ SOAP_FREE(copy, q);
+ return NULL;
+ }
+ q->next = copy->plugins;
+ copy->plugins = q;
+ }
+ }
+ return copy;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_copy_stream(struct soap *copy, struct soap *soap)
+{ copy->mode = soap->mode;
+ copy->imode = soap->imode;
+ copy->omode = soap->omode;
+ copy->socket = soap->socket;
+ copy->recv_timeout = soap->recv_timeout;
+ copy->send_timeout = soap->send_timeout;
+#if defined(__cplusplus) && !defined(WITH_LEAN)
+ copy->os = soap->os;
+ copy->is = soap->is;
+#endif
+ copy->sendfd = soap->sendfd;
+ copy->recvfd = soap->recvfd;
+ copy->bufidx = soap->bufidx;
+ copy->buflen = soap->buflen;
+ copy->ahead = soap->ahead;
+ copy->cdata = soap->cdata;
+ copy->chunksize = soap->chunksize;
+ copy->chunkbuflen = soap->chunkbuflen;
+ copy->keep_alive = soap->keep_alive;
+ copy->tcp_keep_alive = soap->tcp_keep_alive;
+ copy->tcp_keep_idle = soap->tcp_keep_idle;
+ copy->tcp_keep_intvl = soap->tcp_keep_intvl;
+ copy->tcp_keep_cnt = soap->tcp_keep_cnt;
+ copy->max_keep_alive = soap->max_keep_alive;
+#ifndef WITH_NOIO
+ copy->peer = soap->peer;
+ copy->peerlen = soap->peerlen;
+#endif
+#ifdef WITH_OPENSSL
+ copy->bio = soap->bio;
+ copy->ssl = soap->ssl;
+ copy->ctx = soap->ctx;
+#endif
+#ifdef WITH_ZLIB
+ copy->zlib_state = soap->zlib_state;
+ copy->zlib_in = soap->zlib_in;
+ copy->zlib_out = soap->zlib_out;
+ copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream));
+ memcpy(copy->d_stream, soap->d_stream, sizeof(z_stream));
+ copy->z_crc = soap->z_crc;
+ copy->z_ratio_in = soap->z_ratio_in;
+ copy->z_ratio_out = soap->z_ratio_out;
+ copy->z_buf = NULL;
+ copy->z_buflen = soap->z_buflen;
+ copy->z_level = soap->z_level;
+ if (soap->z_buf && soap->zlib_state != SOAP_ZLIB_NONE)
+ { copy->z_buf = (char*)SOAP_MALLOC(copy, SOAP_BUFLEN);
+ memcpy(copy->z_buf, soap->z_buf, sizeof(soap->z_buf));
+ }
+ copy->z_dict = soap->z_dict;
+ copy->z_dict_len = soap->z_dict_len;
+#endif
+ memcpy(copy->buf, soap->buf, sizeof(soap->buf));
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_free_stream(struct soap *soap)
+{ soap->socket = SOAP_INVALID_SOCKET;
+#ifdef WITH_OPENSSL
+ soap->bio = NULL;
+ soap->ssl = NULL;
+#endif
+#ifdef WITH_ZLIB
+ if (soap->d_stream)
+ SOAP_FREE(soap, soap->d_stream);
+ soap->d_stream = NULL;
+ if (soap->z_buf)
+ SOAP_FREE(soap, soap->z_buf);
+ soap->z_buf = NULL;
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_init(struct soap *soap)
+{ soap->state = SOAP_INIT;
+#ifdef SOAP_MEM_DEBUG
+ soap_init_mht(soap);
+#endif
+#if !defined(WITH_LEAN) || defined(SOAP_DEBUG)
+ soap_init_logs(soap);
+#endif
+#ifdef SOAP_DEBUG
+/*
+ Oracle customization for KMS server debug
+*/
+#ifdef SOAP_DEBUG_SERVER
+ soap_set_test_logfile(soap, "/var/log/SUNWkms2/TEST.log");
+ soap_set_sent_logfile(soap, "/var/log/SUNWkms2/SENT.log");
+ soap_set_recv_logfile(soap, "/var/log/SUNWkms2/RECV.log");
+#else
+ soap_set_test_logfile(soap, "TEST.log");
+ soap_set_sent_logfile(soap, "SENT.log");
+ soap_set_recv_logfile(soap, "RECV.log");
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing context\n"));
+#endif
+ soap->version = 0;
+ soap_imode(soap, SOAP_IO_DEFAULT);
+ soap_omode(soap, SOAP_IO_DEFAULT);
+ soap->plugins = NULL;
+ soap->user = NULL;
+ soap->userid = NULL;
+ soap->passwd = NULL;
+#ifndef WITH_NOHTTP
+ soap->fpost = http_post;
+ soap->fget = http_get;
+ soap->fput = http_405;
+ soap->fdel = http_405;
+ soap->fhead = http_405;
+ soap->fform = NULL;
+ soap->fposthdr = http_post_header;
+ soap->fresponse = http_response;
+ soap->fparse = http_parse;
+ soap->fparsehdr = http_parse_header;
+#endif
+ soap->fheader = NULL;
+ soap->fconnect = NULL;
+ soap->fdisconnect = NULL;
+#ifndef WITH_NOIO
+ soap->ipv6_multicast_if = 0;
+ soap->ipv4_multicast_if = NULL;
+#ifndef WITH_IPV6
+ soap->fresolve = tcp_gethost;
+#else
+ soap->fresolve = NULL;
+#endif
+ soap->faccept = tcp_accept;
+ soap->fopen = tcp_connect;
+ soap->fclose = tcp_disconnect;
+ soap->fclosesocket = tcp_closesocket;
+ soap->fshutdownsocket = tcp_shutdownsocket;
+ soap->fsend = fsend;
+ soap->frecv = frecv;
+ soap->fpoll = soap_poll;
+#else
+ soap->fopen = NULL;
+ soap->fclose = NULL;
+ soap->fpoll = NULL;
+#endif
+ soap->fseterror = NULL;
+ soap->fignore = NULL;
+ soap->fserveloop = NULL;
+ soap->fplugin = fplugin;
+ soap->fmalloc = NULL;
+#ifndef WITH_LEANER
+ soap->fprepareinitsend = NULL;
+ soap->fprepareinitrecv = NULL;
+ soap->fpreparesend = NULL;
+ soap->fpreparerecv = NULL;
+ soap->fpreparefinalsend = NULL;
+ soap->fpreparefinalrecv = NULL;
+ soap->fdimereadopen = NULL;
+ soap->fdimewriteopen = NULL;
+ soap->fdimereadclose = NULL;
+ soap->fdimewriteclose = NULL;
+ soap->fdimeread = NULL;
+ soap->fdimewrite = NULL;
+ soap->fmimereadopen = NULL;
+ soap->fmimewriteopen = NULL;
+ soap->fmimereadclose = NULL;
+ soap->fmimewriteclose = NULL;
+ soap->fmimeread = NULL;
+ soap->fmimewrite = NULL;
+#endif
+ soap->float_format = "%.9G"; /* Alternative: use "%G" */
+ soap->double_format = "%.17lG"; /* Alternative: use "%lG" */
+ soap->dime_id_format = "cid:id%d"; /* default DIME id format */
+ soap->http_version = "1.1";
+ soap->proxy_http_version = "1.0";
+ soap->http_content = NULL;
+ soap->actor = NULL;
+ soap->lang = "en";
+ soap->keep_alive = 0;
+ soap->tcp_keep_alive = 0;
+ soap->tcp_keep_idle = 0;
+ soap->tcp_keep_intvl = 0;
+ soap->tcp_keep_cnt = 0;
+ soap->max_keep_alive = SOAP_MAXKEEPALIVE;
+ soap->recv_timeout = 0;
+ soap->send_timeout = 0;
+ soap->connect_timeout = 0;
+ soap->accept_timeout = 0;
+#if defined(WITH_OPENSSL) && defined(KMS_SERVER)
+ /* Oracle customization for Ultra 2 KMS Server */
+ soap->ssl_accept_timeout = 0;
+#endif
+ soap->socket_flags = 0;
+ soap->connect_flags = 0;
+ soap->bind_flags = 0;
+ soap->accept_flags = 0;
+ soap->linger_time = 0;
+ soap->ip = 0;
+ soap->labbuf = NULL;
+ soap->lablen = 0;
+ soap->labidx = 0;
+ soap->encodingStyle = SOAP_STR_EOS;
+#ifndef WITH_NONAMESPACES
+ soap->namespaces = namespaces;
+#else
+ soap->namespaces = NULL;
+#endif
+ soap->local_namespaces = NULL;
+ soap->nlist = NULL;
+ soap->blist = NULL;
+ soap->clist = NULL;
+ soap->alist = NULL;
+ soap->attributes = NULL;
+ soap->header = NULL;
+ soap->fault = NULL;
+ soap->master = SOAP_INVALID_SOCKET;
+ soap->socket = SOAP_INVALID_SOCKET;
+ soap->os = NULL;
+ soap->is = NULL;
+#ifndef WITH_LEANER
+ soap->dom = NULL;
+ soap->dime.list = NULL;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+ soap->mime.list = NULL;
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->mime.boundary = NULL;
+ soap->mime.start = NULL;
+ soap->xlist = NULL;
+#endif
+#ifndef UNDER_CE
+ soap->recvfd = 0;
+ soap->sendfd = 1;
+#else
+ soap->recvfd = stdin;
+ soap->sendfd = stdout;
+#endif
+ soap->host[0] = '\0';
+ soap->session_host[0] = '\0'; /* Oracle customization */
+ soap->session_port = 0; /* Oracle customization */
+ soap->port = 0;
+ soap->action = NULL;
+ soap->proxy_host = NULL;
+ soap->proxy_port = 8080;
+ soap->proxy_userid = NULL;
+ soap->proxy_passwd = NULL;
+ soap->authrealm = NULL;
+ soap->prolog = NULL;
+#ifdef WITH_ZLIB
+ soap->zlib_state = SOAP_ZLIB_NONE;
+ soap->zlib_in = SOAP_ZLIB_NONE;
+ soap->zlib_out = SOAP_ZLIB_NONE;
+ soap->d_stream = (z_stream*)SOAP_MALLOC(soap, sizeof(z_stream));
+ soap->d_stream->zalloc = Z_NULL;
+ soap->d_stream->zfree = Z_NULL;
+ soap->d_stream->opaque = Z_NULL;
+ soap->z_buf = NULL;
+ soap->z_level = 6;
+ soap->z_dict = NULL;
+ soap->z_dict_len = 0;
+#endif
+#ifndef WITH_LEAN
+ soap->wsuid = NULL;
+ soap->c14nexclude = NULL;
+ soap->cookies = NULL;
+ soap->cookie_domain = NULL;
+ soap->cookie_path = NULL;
+ soap->cookie_max = 32;
+#endif
+#ifdef WMW_RPM_IO
+ soap->rpmreqid = NULL;
+#endif
+#ifdef PALM
+ palmNetLibOpen();
+#endif
+#ifndef WITH_NOIDREF
+ soap_init_iht(soap);
+ soap_init_pht(soap);
+#endif
+#ifdef WITH_OPENSSL
+ if (!soap_ssl_init_done)
+ soap_ssl_init();
+ soap->fsslauth = ssl_auth_init;
+ soap->fsslverify = ssl_verify_callback;
+ soap->bio = NULL;
+ soap->ssl = NULL;
+ soap->ctx = NULL;
+ soap->ssl_flags = SOAP_SSL_DEFAULT;
+ soap->keyfile = NULL;
+ soap->password = NULL;
+ soap->dhfile = NULL;
+ soap->cafile = NULL;
+ soap->capath = NULL;
+ soap->crlfile = NULL;
+ soap->randfile = NULL;
+ soap->session = NULL;
+#endif
+#ifdef WITH_C_LOCALE
+ soap->c_locale = newlocale(LC_ALL_MASK, "C", NULL);
+#else
+ soap->c_locale = NULL;
+#endif
+ soap->buflen = 0;
+ soap->bufidx = 0;
+#ifndef WITH_LEANER
+ soap->dime.chunksize = 0;
+ soap->dime.buflen = 0;
+#endif
+ soap->null = 0;
+ soap->position = 0;
+ soap->encoding = 0;
+ soap->mustUnderstand = 0;
+ soap->ns = 0;
+ soap->part = SOAP_END;
+ soap->alloced = 0;
+ soap->count = 0;
+ soap->length = 0;
+ soap->cdata = 0;
+ soap->peeked = 0;
+ soap->ahead = 0;
+ soap->idnum = 0;
+ soap->level = 0;
+ soap->endpoint[0] = '\0';
+ soap->error = SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_init1(struct soap *soap, soap_mode mode)
+{ soap_init2(soap, mode, mode);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_init2(struct soap *soap, soap_mode imode, soap_mode omode)
+{ soap_init(soap);
+ soap_imode(soap, imode);
+ soap_omode(soap, omode);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_begin(struct soap *soap)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reinitializing context\n"));
+ if (!soap->keep_alive)
+ { soap->buflen = 0;
+ soap->bufidx = 0;
+ }
+ soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0);
+ soap->null = 0;
+ soap->position = 0;
+ soap->encoding = 0;
+ soap->mustUnderstand = 0;
+ soap->mode = 0;
+ soap->ns = 0;
+ soap->part = SOAP_END;
+ soap->alloced = 0;
+ soap->count = 0;
+ soap->length = 0;
+ soap->cdata = 0;
+ soap->error = SOAP_OK;
+ soap->peeked = 0;
+ soap->ahead = 0;
+ soap->idnum = 0;
+ soap->level = 0;
+ soap->endpoint[0] = '\0';
+#ifndef WITH_LEANER
+ soap->dime.chunksize = 0;
+ soap->dime.buflen = 0;
+#endif
+ soap_free_temp(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_end(struct soap *soap)
+{ if (soap_check_state(soap))
+ return;
+ soap_free_temp(soap);
+ soap_dealloc(soap, NULL);
+ while (soap->clist)
+ { register struct soap_clist *cp = soap->clist->next;
+ SOAP_FREE(soap, soap->clist);
+ soap->clist = cp;
+ }
+ soap_closesock(soap);
+#ifdef SOAP_DEBUG
+ soap_close_logfiles(soap);
+#endif
+#ifdef PALM
+ palmNetLibClose();
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_namespaces(struct soap *soap, const struct Namespace *p)
+{ register struct Namespace *ns = soap->local_namespaces;
+ register struct soap_nlist *np, *nq, *nr;
+ register unsigned int level = soap->level;
+ soap->namespaces = p;
+ soap->local_namespaces = NULL;
+ soap_set_local_namespaces(soap);
+ /* reverse the namespace list */
+ np = soap->nlist;
+ soap->nlist = NULL;
+ if (np)
+ { nq = np->next;
+ np->next = NULL;
+ while (nq)
+ { nr = nq->next;
+ nq->next = np;
+ np = nq;
+ nq = nr;
+ }
+ }
+ /* then push on new stack */
+ while (np)
+ { register const char *s;
+ soap->level = np->level; /* preserve element nesting level */
+ s = np->ns;
+ if (!s && np->index >= 0 && ns)
+ { s = ns[np->index].out;
+ if (!s)
+ s = ns[np->index].ns;
+ }
+ if (s && soap_push_namespace(soap, np->id, s) == NULL)
+ return soap->error;
+ nq = np;
+ np = np->next;
+ SOAP_FREE(soap, nq);
+ }
+ if (ns)
+ { register int i;
+ for (i = 0; ns[i].id; i++)
+ { if (ns[i].out)
+ { SOAP_FREE(soap, ns[i].out);
+ ns[i].out = NULL;
+ }
+ }
+ SOAP_FREE(soap, ns);
+ }
+ soap->level = level; /* restore level */
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_local_namespaces(struct soap *soap)
+{ if (soap->namespaces && !soap->local_namespaces)
+ { register const struct Namespace *ns1;
+ register struct Namespace *ns2;
+ register size_t n = 1;
+ for (ns1 = soap->namespaces; ns1->id; ns1++)
+ n++;
+ n *= sizeof(struct Namespace);
+ ns2 = (struct Namespace*)SOAP_MALLOC(soap, n);
+ if (ns2)
+ { memcpy(ns2, soap->namespaces, n);
+ if (ns2[0].ns)
+ { if (!strcmp(ns2[0].ns, soap_env1))
+ soap->version = 1;
+ else
+ soap->version = 2;
+ }
+ soap->local_namespaces = ns2;
+ }
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+#ifndef PALM_1
+SOAP_FMAC1
+const char *
+SOAP_FMAC2
+soap_tagsearch(const char *big, const char *little)
+{ if (little)
+ { register size_t n = strlen(little);
+ register const char *s = big;
+ while (s)
+ { register const char *t = s;
+ register size_t i;
+ for (i = 0; i < n; i++, t++)
+ { if (*t != little[i])
+ break;
+ }
+ if (*t == '\0' || *t == ' ')
+ { if (i == n || (i && little[i-1] == ':'))
+ return s;
+ }
+ s = strchr(t, ' ');
+ if (s)
+ s++;
+ }
+ }
+ return NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap_nlist *
+SOAP_FMAC2
+soap_lookup_ns(struct soap *soap, const char *tag, size_t n)
+{ register struct soap_nlist *np;
+ for (np = soap->nlist; np; np = np->next)
+ { if (!strncmp(np->id, tag, n) && !np->id[n])
+ return np;
+ }
+ return NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+static struct soap_nlist *
+soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized)
+{ register struct soap_nlist *np;
+ size_t n, k;
+ if (soap_tagsearch(soap->c14nexclude, id))
+ return NULL;
+ if (!utilized)
+ { for (np = soap->nlist; np; np = np->next)
+ { if (!strcmp(np->id, id) && (!np->ns || !strcmp(np->ns, ns)))
+ break;
+ }
+ if (np)
+ { if ((np->level < soap->level || !np->ns) && np->index == 1)
+ utilized = 1;
+ else
+ return NULL;
+ }
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Adding namespace binding (level=%u) '%s' '%s' utilized=%d\n", soap->level, id, ns?ns:"(null)", utilized));
+ n = strlen(id);
+ if (ns)
+ k = strlen(ns);
+ else
+ k = 0;
+ np = (struct soap_nlist*)SOAP_MALLOC(soap, sizeof(struct soap_nlist) + n + k + 1);
+ if (!np)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ np->next = soap->nlist;
+ soap->nlist = np;
+ strcpy(np->id, id);
+ if (ns)
+ np->ns = strcpy(np->id + n + 1, ns);
+ else
+ np->ns = NULL;
+ np->level = soap->level;
+ np->index = utilized;
+ return np;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+static void
+soap_utilize_ns(struct soap *soap, const char *tag, size_t n)
+{ register struct soap_nlist *np = soap_lookup_ns(soap, tag, n);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Utilizing namespace of '%s'\n", tag));
+ if (np)
+ { if (np->index == 0)
+ soap_push_ns(soap, np->id, np->ns, 1);
+ }
+ else if (strncmp(tag, "xml", 3))
+ { strncpy(soap->tmpbuf, tag, n);
+ soap->tmpbuf[n] = '\0';
+ soap_push_ns(soap, soap->tmpbuf, NULL, 1);
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element(struct soap *soap, const char *tag, int id, const char *type)
+{
+#ifndef WITH_LEAN
+ register const char *s;
+#endif
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' id='%d' type='%s'\n", tag, id, type?type:SOAP_STR_EOS));
+#ifdef WITH_DOM
+#ifndef WITH_LEAN
+ if (soap->wsuid && soap_tagsearch(soap->wsuid, tag))
+ { int i;
+ for (s = tag, i = 0; *s && i < sizeof(soap->tag); s++, i++)
+ soap->tag[i] = *s == ':' ? '-' : *s;
+ soap->tag[sizeof(soap->tag) - 1] = '\0';
+ if (soap_set_attr(soap, "wsu:Id", soap->tag, 1))
+ return soap->error;
+ }
+#endif
+ if (soap->part == SOAP_BEGIN_SECURITY && (soap->mode & SOAP_XML_CANONICAL) && !(soap->mode & SOAP_DOM_ASIS))
+ { register struct soap_nlist *np;
+ /* wsu:Id found: clear xmlns renderings, so re-emit them for exc-c14n */
+ for (np = soap->nlist; np; np = np->next)
+ { if (np->index == 2)
+ np->index = 0;
+ }
+ }
+ if (soap->mode & SOAP_XML_DOM)
+ { register struct soap_dom_element *elt = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element));
+ if (!elt)
+ return soap->error;
+ elt->soap = soap;
+ elt->next = NULL;
+ elt->prnt = soap->dom;
+ elt->name = soap_strdup(soap, tag);
+ elt->elts = NULL;
+ elt->atts = NULL;
+ elt->nstr = NULL;
+ elt->data = NULL;
+ elt->wide = NULL;
+ elt->node = NULL;
+ elt->type = 0;
+ elt->head = NULL;
+ elt->tail = NULL;
+ if (soap->dom)
+ { struct soap_dom_element *p = soap->dom->elts;
+ if (p)
+ { while (p->next)
+ p = p->next;
+ p->next = elt;
+ }
+ else
+ soap->dom->elts = elt;
+ }
+ soap->dom = elt;
+ }
+ else
+ {
+#endif
+ soap->level++;
+#ifndef WITH_LEAN
+ if (!soap->ns)
+ { if (!(soap->mode & SOAP_XML_CANONICAL)
+ && soap_send(soap, soap->prolog ? soap->prolog : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"))
+ return soap->error;
+ }
+ else if (soap->mode & SOAP_XML_INDENT)
+ { if (soap->ns == 1 && soap_send_raw(soap, soap_indent, soap->level < sizeof(soap_indent) ? soap->level : sizeof(soap_indent) - 1))
+ return soap->error;
+ soap->body = 1;
+ }
+ if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tag, ':')))
+ { struct Namespace *ns = soap->local_namespaces;
+ size_t n = s - tag;
+ if (soap_send_raw(soap, "<", 1)
+ || soap_send(soap, s + 1))
+ return soap->error;
+ if (soap->nlist && !strncmp(soap->nlist->id, tag, n) && !soap->nlist->id[n])
+ ns = NULL;
+ for (; ns && ns->id; ns++)
+ { if (*ns->id && (ns->out || ns->ns) && !strncmp(ns->id, tag, n) && !ns->id[n])
+ { soap_push_ns(soap, ns->id, ns->out ? ns->out : ns->ns, 0);
+ if (soap_attribute(soap, "xmlns", ns->out ? ns->out : ns->ns))
+ return soap->error;
+ break;
+ }
+ }
+ }
+ else
+#endif
+ if (soap_send_raw(soap, "<", 1)
+ || soap_send(soap, tag))
+ return soap->error;
+#ifdef WITH_DOM
+ }
+#endif
+ if (!soap->ns)
+ { struct Namespace *ns;
+ int k = -1;
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_XML_DEFAULTNS))
+ k = 4; /* only produce the first four required entries */
+#endif
+ for (ns = soap->local_namespaces; ns && ns->id && k; ns++, k--)
+ { if (*ns->id && (ns->out || ns->ns))
+ { sprintf(soap->tmpbuf, "xmlns:%s", ns->id);
+ if (soap_attribute(soap, soap->tmpbuf, ns->out ? ns->out : ns->ns))
+ return soap->error;
+ }
+ }
+ }
+ soap->ns = 1; /* namespace table control: ns = 0 or 2 to start, then 1 to stop dumping the table */
+#ifndef WITH_LEAN
+ if (soap->mode & SOAP_XML_CANONICAL)
+ { const char *t = strchr(tag, ':');
+ if (t)
+ soap_utilize_ns(soap, tag, t - tag);
+ }
+#endif
+ if (id > 0)
+ { sprintf(soap->tmpbuf, "_%d", id);
+ if (soap_attribute(soap, "id", soap->tmpbuf))
+ return soap->error;
+ }
+ if (type && *type && (!(soap->mode & SOAP_XML_SEC) || soap->part == SOAP_IN_BODY))
+ { if (soap_attribute(soap, "xsi:type", type))
+ return soap->error;
+#ifndef WITH_LEAN
+ if (soap->mode & SOAP_XML_CANONICAL)
+ { const char *t = strchr(type, ':');
+ if (t)
+ soap_utilize_ns(soap, type, t - type);
+ }
+#endif
+ }
+ if (soap->null && soap->position > 0)
+ { register int i;
+ sprintf(soap->tmpbuf, "[%d", soap->positions[0]);
+ for (i = 1; i < soap->position; i++)
+ sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ",%d", soap->positions[i]);
+ strcat(soap->tmpbuf, "]");
+ if (soap_attribute(soap, "SOAP-ENC:position", soap->tmpbuf))
+ return soap->error;
+ }
+ if (soap->mustUnderstand)
+ { if (soap->actor && *soap->actor)
+ { if (soap_attribute(soap, soap->version == 2 ? "SOAP-ENV:role" : "SOAP-ENV:actor", soap->actor))
+ return soap->error;
+ }
+ if (soap_attribute(soap, "SOAP-ENV:mustUnderstand", soap->version == 2 ? "true" : "1"))
+ return soap->error;
+ soap->mustUnderstand = 0;
+ }
+ if (soap->encoding)
+ { if (soap->encodingStyle && soap->local_namespaces)
+ { if (!*soap->encodingStyle)
+ { if (soap->local_namespaces[1].out)
+ soap->encodingStyle = soap->local_namespaces[1].out;
+ else
+ soap->encodingStyle = soap->local_namespaces[1].ns;
+ }
+ if (soap->encodingStyle && soap_attribute(soap, "SOAP-ENV:encodingStyle", soap->encodingStyle))
+ return soap->error;
+ }
+ soap->encoding = 0;
+ }
+ soap->null = 0;
+ soap->position = 0;
+ if (soap->part == SOAP_BEGIN_SECURITY && (soap->mode & SOAP_XML_CANONICAL))
+ soap->part = SOAP_IN_SECURITY;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type)
+{ if (*tag == '-')
+ return SOAP_OK;
+ if (soap_element(soap, tag, id, type))
+ return soap->error;
+ return soap_element_start_end_out(soap, NULL);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+#ifndef HAVE_STRRCHR
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_strrchr(const char *s, int t)
+{ register char *r = NULL;
+ while (*s)
+ if (*s++ == t)
+ r = (char*)s - 1;
+ return r;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+#ifndef HAVE_STRTOL
+SOAP_FMAC1
+long
+SOAP_FMAC2
+soap_strtol(const char *s, char **t, int b)
+{ register long n = 0;
+ register int c;
+ while (*s > 0 && *s <= 32)
+ s++;
+ if (b == 10)
+ { short neg = 0;
+ if (*s == '-')
+ { s++;
+ neg = 1;
+ }
+ else if (*s == '+')
+ s++;
+ while ((c = *s) && c >= '0' && c <= '9')
+ { if (n >= 214748364 && (n > 214748364 || c >= '8'))
+ break;
+ n *= 10;
+ n += c - '0';
+ s++;
+ }
+ if (neg)
+ n = -n;
+ }
+ else /* assume b == 16 and value is always positive */
+ { while ((c = *s))
+ { if (c >= '0' && c <= '9')
+ c -= '0';
+ else if (c >= 'A' && c <= 'F')
+ c -= 'A' - 10;
+ else if (c >= 'a' && c <= 'f')
+ c -= 'a' - 10;
+ if (n > 0x07FFFFFF)
+ break;
+ n <<= 4;
+ n += c;
+ s++;
+ }
+ }
+ if (t)
+ *t = (char*)s;
+ return n;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+#ifndef HAVE_STRTOUL
+SOAP_FMAC1
+unsigned long
+SOAP_FMAC2
+soap_strtoul(const char *s, char **t, int b)
+{ unsigned long n = 0;
+ register int c;
+ while (*s > 0 && *s <= 32)
+ s++;
+ if (b == 10)
+ { if (*s == '+')
+ s++;
+ while ((c = *s) && c >= '0' && c <= '9')
+ { if (n >= 429496729 && (n > 429496729 || c >= '6'))
+ break;
+ n *= 10;
+ n += c - '0';
+ s++;
+ }
+ }
+ else /* b == 16 */
+ { while ((c = *s))
+ { if (c >= '0' && c <= '9')
+ c -= '0';
+ else if (c >= 'A' && c <= 'F')
+ c -= 'A' - 10;
+ else if (c >= 'a' && c <= 'f')
+ c -= 'a' - 10;
+ if (n > 0x0FFFFFFF)
+ break;
+ n <<= 4;
+ n += c;
+ s++;
+ }
+ }
+ if (t)
+ *t = (char*)s;
+ return n;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *type, const char *offset)
+{ if (!type || !*type)
+ return soap_element_begin_out(soap, tag, id, NULL);
+ if (soap_element(soap, tag, id, "SOAP-ENC:Array"))
+ return soap->error;
+ if (soap->version == 2)
+ { const char *s;
+ s = soap_strrchr(type, '[');
+ if ((size_t)(s - type) < sizeof(soap->tmpbuf))
+ { strncpy(soap->tmpbuf, type, s - type);
+ soap->tmpbuf[s - type] = '\0';
+ if (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf))
+ return soap->error;
+ if (s && (soap_attribute(soap, "SOAP-ENC:arraySize", s + 1)))
+ return soap->error;
+ }
+ }
+ else
+ { if (offset && soap_attribute(soap, "SOAP-ENC:offset", offset))
+ return soap->error;
+ if (soap_attribute(soap, "SOAP-ENC:arrayType", type))
+ return soap->error;
+ }
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_XML_CANONICAL))
+ { const char *s = strchr(type, ':');
+ if (s)
+ soap_utilize_ns(soap, type, s - type);
+ }
+#endif
+ return soap_element_start_end_out(soap, NULL);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_start_end_out(struct soap *soap, const char *tag)
+{ register struct soap_attribute *tp;
+#ifndef WITH_LEAN
+ if (soap->mode & SOAP_XML_CANONICAL)
+ { struct soap_nlist *np;
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible && tp->name)
+ { const char *s = strchr(tp->name, ':');
+ if (s)
+ soap_utilize_ns(soap, tp->name, s - tp->name);
+ }
+ }
+ for (np = soap->nlist; np; np = np->next)
+ { if (np->index == 1 && np->ns)
+ { sprintf(soap->tmpbuf, "xmlns:%s", np->id);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enabling utilized binding (level=%u) %s='%s'\n", np->level, soap->tmpbuf, np->ns));
+ soap_set_attr(soap, soap->tmpbuf, np->ns, 1);
+ np->index = 2;
+ }
+ }
+ }
+#endif
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { register struct soap_dom_attribute **att;
+ att = &soap->dom->atts;
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible)
+ { *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
+ if (!*att)
+ return soap->error;
+ (*att)->next = NULL;
+ (*att)->nstr = NULL;
+ (*att)->name = soap_strdup(soap, tp->name);
+ (*att)->data = soap_strdup(soap, tp->value);
+ (*att)->wide = NULL;
+ (*att)->soap = soap;
+ att = &(*att)->next;
+ tp->visible = 0;
+ }
+ }
+ return SOAP_OK;
+ }
+#endif
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible)
+ {
+#ifndef WITH_LEAN
+ const char *s;
+ if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tp->name, ':')))
+ { size_t n = s - tp->name;
+ if (soap->nlist && !strncmp(soap->nlist->id, tp->name, n) && !soap->nlist->id[n])
+ s++;
+ else
+ s = tp->name;
+ if (soap_send(soap, " ") || soap_send(soap, s))
+ return soap->error;
+ }
+ else
+#endif
+ if (soap_send(soap, " ") || soap_send(soap, tp->name))
+ return soap->error;
+ if (tp->visible == 2 && tp->value)
+ if (soap_send_raw(soap, "=\"", 2)
+ || soap_string_out(soap, tp->value, tp->flag)
+ || soap_send_raw(soap, "\"", 1))
+ return soap->error;
+ tp->visible = 0;
+ }
+ }
+ if (tag)
+ {
+#ifndef WITH_LEAN
+ if (soap->mode & SOAP_XML_CANONICAL)
+ { if (soap_send_raw(soap, ">", 1)
+ || soap_element_end_out(soap, tag))
+ return soap->error;
+ return SOAP_OK;
+ }
+#endif
+ soap->level--; /* decrement level just before /> */
+ if (soap_send_raw(soap, "/>", 2))
+ return soap->error;
+ return SOAP_OK;
+ }
+ return soap_send_raw(soap, ">", 1);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_end_out(struct soap *soap, const char *tag)
+{
+#ifndef WITH_LEAN
+ const char *s;
+#endif
+ if (*tag == '-')
+ return SOAP_OK;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element ending tag='%s'\n", tag));
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { if (soap->dom->prnt)
+ soap->dom = soap->dom->prnt;
+ return SOAP_OK;
+ }
+#endif
+#ifndef WITH_LEAN
+ if (soap->mode & SOAP_XML_CANONICAL)
+ soap_pop_namespace(soap);
+ if (soap->mode & SOAP_XML_INDENT)
+ { if (!soap->body)
+ { if (soap_send_raw(soap, soap_indent, soap->level < sizeof(soap_indent) ? soap->level : sizeof(soap_indent) - 1))
+ return soap->error;
+ }
+ soap->body = 0;
+ }
+ if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tag, ':')))
+ { soap_pop_namespace(soap);
+ tag = s + 1;
+ }
+#endif
+ if (soap_send_raw(soap, "</", 2)
+ || soap_send(soap, tag))
+ return soap->error;
+ soap->level--; /* decrement level just before > */
+ return soap_send_raw(soap, ">", 1);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_ref(struct soap *soap, const char *tag, int id, int href)
+{ register int n = 0;
+ const char *s = "href";
+ if (soap->version == 2)
+ { s = "SOAP-ENC:ref";
+ n = 1;
+ }
+ sprintf(soap->href, "#_%d", href);
+ return soap_element_href(soap, tag, id, s, soap->href + n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_href(struct soap *soap, const char *tag, int id, const char *ref, const char *val)
+{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element '%s' reference %s='%s'\n", tag, ref, val));
+ if (soap_element(soap, tag, id, NULL)
+ || soap_attribute(soap, ref, val)
+ || soap_element_start_end_out(soap, tag))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_null(struct soap *soap, const char *tag, int id, const char *type)
+{ struct soap_attribute *tp;
+ for (tp = soap->attributes; tp; tp = tp->next)
+ if (tp->visible)
+ break;
+ if (tp || (soap->version == 2 && soap->position > 0) || id > 0 || (soap->mode & SOAP_XML_NIL))
+ { if (soap_element(soap, tag, id, type))
+ return soap->error;
+ if (!tp && soap_attribute(soap, "xsi:nil", "true"))
+ return soap->error;
+ return soap_element_start_end_out(soap, tag);
+ }
+ soap->null = 1;
+ soap->position = 0;
+ soap->mustUnderstand = 0;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, int n, const char *type, int t)
+{ if (!p)
+ { soap_element_null(soap, tag, id, type);
+ return -1;
+ }
+#ifndef WITH_NOIDREF
+ if (soap->mode & SOAP_XML_TREE)
+ return 0;
+ if (id < 0)
+ { struct soap_plist *pp;
+ if (a)
+ id = soap_array_pointer_lookup(soap, p, a, n, t, &pp);
+ else
+ id = soap_pointer_lookup(soap, p, t, &pp);
+ if (id)
+ { if (soap_is_embedded(soap, pp))
+ { soap_element_ref(soap, tag, 0, id);
+ return -1;
+ }
+ if (soap_is_single(soap, pp))
+ return 0;
+ soap_set_embedded(soap, pp);
+ }
+ }
+ return id;
+#else
+ return 0;
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_result(struct soap *soap, const char *tag)
+{ if (soap->version == 2 && soap->encodingStyle)
+ { if (soap_element(soap, "SOAP-RPC:result", 0, NULL)
+ || soap_attribute(soap, "xmlns:SOAP-RPC", soap_rpc)
+ || soap_element_start_end_out(soap, NULL)
+ || soap_string_out(soap, tag, 0)
+ || soap_element_end_out(soap, "SOAP-RPC:result"))
+ return soap->error;
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_check_result(struct soap *soap, const char *tag)
+{ if (soap->version == 2 && soap->encodingStyle)
+ { soap_instring(soap, ":result", NULL, NULL, 0, 2, -1, -1);
+ /* just ignore content for compliance reasons, but should compare tag to element's QName value? */
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_attribute(struct soap *soap, const char *name, const char *value)
+{
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attribute '%s'='%s'\n", name, value));
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && !(soap->mode & SOAP_XML_CANONICAL) && soap->dom)
+ { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
+ if (!a)
+ return soap->error;
+ a->next = soap->dom->atts;
+ a->nstr = NULL;
+ a->name = soap_strdup(soap, name);
+ a->data = soap_strdup(soap, value);
+ a->wide = NULL;
+ a->soap = soap;
+ soap->dom->atts = a;
+ return SOAP_OK;
+ }
+#endif
+#ifndef WITH_LEAN
+ if (soap->mode & SOAP_XML_CANONICAL)
+ { /* TODO: consider using this code to handle default namespace bindings
+ if (!strncmp(name, "xmlns", 5) && (name[5] == ':' || name[5] == '\0'))
+ { if (name[5] == ':')
+ soap_push_ns(soap, name + 6, value, 0);
+ else
+ soap_push_ns(soap, "", value, 0);
+ }
+ */
+ if (!strncmp(name, "xmlns:", 6))
+ soap_push_ns(soap, name + 6, value, 0);
+ else if (soap_set_attr(soap, name, value, 1))
+ return soap->error;
+ }
+ else
+#endif
+ { if (soap_send(soap, " ") || soap_send(soap, name))
+ return soap->error;
+ if (value)
+ if (soap_send_raw(soap, "=\"", 2)
+ || soap_string_out(soap, value, 1)
+ || soap_send_raw(soap, "\"", 1))
+ return soap->error;
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_begin_in(struct soap *soap, const char *tag, int nillable, const char *type)
+{ if (!soap_peek_element(soap))
+ { if (soap->other)
+ return soap->error = SOAP_TAG_MISMATCH;
+ if (tag && *tag == '-')
+ return SOAP_OK;
+ if (!(soap->error = soap_match_tag(soap, soap->tag, tag)))
+ { soap->peeked = 0;
+ if (type && *soap->type && soap_match_tag(soap, soap->type, type))
+ return soap->error = SOAP_TYPE;
+ if (!nillable && soap->null && (soap->mode & SOAP_XML_STRICT))
+ return soap->error = SOAP_NULL;
+ if (soap->body)
+ soap->level++;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:SOAP_STR_EOS ));
+ }
+ }
+ else if (soap->error == SOAP_NO_TAG && tag && *tag == '-')
+ soap->error = SOAP_OK;
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_element_end_in(struct soap *soap, const char *tag)
+{ register soap_wchar c;
+ register char *s;
+ register int n = 0;
+ if (tag && *tag == '-')
+ return SOAP_OK;
+ if (soap->error == SOAP_NO_TAG)
+ soap->error = SOAP_OK;
+#ifdef WITH_DOM
+ /* this whitespace or mixed content is not insignificant for DOM */
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { if (!soap->peeked && !soap_string_in(soap, 3, -1, -1))
+ return soap->error;
+ if (soap->dom->prnt)
+ soap->dom = soap->dom->prnt;
+ }
+#endif
+ if (soap->peeked)
+ { if (*soap->tag)
+ n++;
+ soap->peeked = 0;
+ }
+ do
+ { while (((c = soap_get(soap)) != SOAP_TT))
+ { if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ if (c == SOAP_LT)
+ n++;
+ else if (c == '/')
+ { c = soap_get(soap);
+ if (c == SOAP_GT)
+ n--;
+ else
+ soap_unget(soap, c);
+ }
+ }
+ } while (n--);
+ s = soap->tag;
+ n = sizeof(soap->tag);
+ while (soap_notblank(c = soap_get(soap)))
+ { if (--n > 0)
+ *s++ = (char)c;
+ }
+ *s = '\0';
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ while (soap_blank(c))
+ c = soap_get(soap);
+ if (c != SOAP_GT)
+ return soap->error = SOAP_SYNTAX_ERROR;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag?tag:SOAP_STR_EOS));
+#ifndef WITH_LEAN
+ if (tag && (soap->mode & SOAP_XML_STRICT))
+ { soap_pop_namespace(soap);
+ if (soap_match_tag(soap, soap->tag, tag))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element tag name does not match\n"));
+ return soap->error = SOAP_SYNTAX_ERROR;
+ }
+ }
+#endif
+ soap->level--;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char *
+SOAP_FMAC2
+soap_attr_value(struct soap *soap, const char *name, int flag)
+{ register struct soap_attribute *tp;
+ if (*name == '-')
+ return SOAP_STR_EOS;
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible && !soap_match_tag(soap, tp->name, name))
+ break;
+ }
+ if (tp)
+ { if (flag == 2 && (soap->mode & SOAP_XML_STRICT))
+ soap->error = SOAP_PROHIBITED;
+ else
+ return tp->value;
+ }
+ else if (flag == 1 && (soap->mode & SOAP_XML_STRICT))
+ soap->error = SOAP_REQUIRED;
+ else
+ soap->error = SOAP_OK;
+ return NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_attr(struct soap *soap, const char *name, const char *value, int flag)
+{ register struct soap_attribute *tp;
+ if (*name == '-')
+ return SOAP_OK;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value?value:SOAP_STR_EOS));
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (!strcmp(tp->name, name))
+ break;
+ }
+ if (!tp)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name));
+ if (!(tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + strlen(name))))
+ return soap->error = SOAP_EOM;
+ tp->ns = NULL;
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_XML_CANONICAL))
+ { struct soap_attribute **tpp = &soap->attributes;
+ const char *s = strchr(name, ':');
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inserting attribute %s for c14n\n", name))
+ if (!strncmp(name, "xmlns", 5))
+ { for (; *tpp; tpp = &(*tpp)->next)
+ if (strncmp((*tpp)->name, "xmlns", 5) || strcmp((*tpp)->name + 5, name + 5) > 0)
+ break;
+ }
+ else if (!s)
+ { for (; *tpp; tpp = &(*tpp)->next)
+ if (strncmp((*tpp)->name, "xmlns", 5) && ((*tpp)->ns || strcmp((*tpp)->name, name) > 0))
+ break;
+ }
+ else
+ { int k;
+ for (; *tpp; tpp = &(*tpp)->next)
+ { if (!strncmp((*tpp)->name, "xmlns:", 6) && !strncmp((*tpp)->name + 6, name, s - name) && !(*tpp)->name[6 + s - name])
+ { if (!tp->ns)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Canonicalization: prefix %s=%p (%s)\n", name, (*tpp)->ns, (*tpp)->ns));
+ tp->ns = (*tpp)->ns;
+ }
+ }
+ else if (strncmp((*tpp)->name, "xmlns", 5) && (*tpp)->ns && tp->ns && ((k = strcmp((*tpp)->ns, tp->ns)) > 0 || (!k && strcmp((*tpp)->name, name) > 0)))
+ break;
+ }
+ }
+ tp->next = *tpp;
+ *tpp = tp;
+ }
+ else
+#endif
+ { tp->next = soap->attributes;
+ soap->attributes = tp;
+ }
+ strcpy(tp->name, name);
+ tp->value = NULL;
+ }
+ else if (tp->visible)
+ { return SOAP_OK;
+ }
+ else if (value && tp->value && tp->size <= strlen(value))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free attribute value of %s (free %p)\n", name, tp->value));
+ SOAP_FREE(soap, tp->value);
+ tp->value = NULL;
+ tp->ns = NULL;
+ }
+ if (value)
+ { if (!tp->value)
+ { tp->size = strlen(value) + 1;
+ if (!(tp->value = (char*)SOAP_MALLOC(soap, tp->size)))
+ return soap->error = SOAP_EOM;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute value for %s (%p)\n", tp->name, tp->value));
+ }
+ strcpy(tp->value, value);
+ if (!strncmp(tp->name, "xmlns:", 6))
+ tp->ns = tp->value;
+ tp->visible = 2;
+ tp->flag = flag;
+#ifndef WITH_LEAN
+ if (soap->part != SOAP_IN_SECURITY && !strcmp(name, "wsu:Id"))
+ { soap->part = SOAP_BEGIN_SECURITY;
+ strncpy(soap->id, value, sizeof(soap->id));
+ soap->id[sizeof(soap->id)-1] = '\0';
+ }
+#endif
+ }
+ else
+ tp->visible = 1;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_clr_attr(struct soap *soap)
+{ register struct soap_attribute *tp;
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_XML_CANONICAL))
+ { while (soap->attributes)
+ { tp = soap->attributes->next;
+ if (soap->attributes->value)
+ SOAP_FREE(soap, soap->attributes->value);
+ SOAP_FREE(soap, soap->attributes);
+ soap->attributes = tp;
+ }
+ }
+ else
+#endif
+ { for (tp = soap->attributes; tp; tp = tp->next)
+ tp->visible = 0;
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+static int
+soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d)
+{ register size_t i;
+ for (i = 0; i < n; i++)
+ { register soap_wchar c = soap_get(soap);
+ switch (c)
+ {
+ case SOAP_TT:
+ *s++ = '<';
+ soap_unget(soap, '/');
+ break;
+ case SOAP_LT:
+ *s++ = '<';
+ break;
+ case SOAP_GT:
+ if (d == ' ')
+ { soap_unget(soap, c);
+ *s = '\0';
+ return SOAP_OK;
+ }
+ *s++ = '>';
+ break;
+ case SOAP_QT:
+ if (c == d)
+ { *s = '\0';
+ return SOAP_OK;
+ }
+ *s++ = '"';
+ break;
+ case SOAP_AP:
+ if (c == d)
+ { *s = '\0';
+ return SOAP_OK;
+ }
+ *s++ = '\'';
+ break;
+ case '\t':
+ case '\n':
+ case '\r':
+ case ' ':
+ case '/':
+ if (d == ' ')
+ { soap_unget(soap, c);
+ *s = '\0';
+ return SOAP_OK;
+ }
+ default:
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ *s++ = (char)c;
+ }
+ }
+ return soap->error = SOAP_EOM;
+}
+#endif
+
+/******************************************************************************/
+#ifdef WITH_FAST
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_store_lab(struct soap *soap, const char *s, size_t n)
+{ soap->labidx = 0;
+ return soap_append_lab(soap, s, n);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_FAST
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_append_lab(struct soap *soap, const char *s, size_t n)
+{ if (soap->labidx + n >= soap->lablen)
+ { register char *t = soap->labbuf;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enlarging look-aside buffer to append data, old size=%lu", (unsigned long)soap->lablen));
+ if (soap->lablen == 0)
+ soap->lablen = SOAP_LABLEN;
+ while (soap->labidx + n >= soap->lablen)
+ soap->lablen <<= 1;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, ", new size=%lu\n", (unsigned long)soap->lablen));
+ soap->labbuf = (char*)SOAP_MALLOC(soap, soap->lablen);
+ if (!soap->labbuf)
+ { if (t)
+ SOAP_FREE(soap, t);
+ return soap->error = SOAP_EOM;
+ }
+ if (t)
+ { memcpy(soap->labbuf, t, soap->labidx);
+ SOAP_FREE(soap, t);
+ }
+ }
+ if (s)
+ { memcpy(soap->labbuf + soap->labidx, s, n);
+ soap->labidx += n;
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_peek_element(struct soap *soap)
+{
+#ifdef WITH_DOM
+ register struct soap_dom_attribute **att = NULL;
+ register char *lead = NULL;
+#endif
+ register struct soap_attribute *tp, *tq = NULL;
+ register const char *t;
+ register char *s;
+ register soap_wchar c;
+ register int i;
+ if (soap->peeked)
+ { if (!*soap->tag)
+ return soap->error = SOAP_NO_TAG;
+ return SOAP_OK;
+ }
+ soap->peeked = 1;
+ soap->id[0] = '\0';
+ soap->href[0] = '\0';
+ soap->type[0] = '\0';
+ soap->arrayType[0] = '\0';
+ soap->arraySize[0] = '\0';
+ soap->arrayOffset[0] = '\0';
+ soap->other = 0;
+ soap->root = -1;
+ soap->position = 0;
+ soap->null = 0;
+ soap->mustUnderstand = 0;
+ /* skip BOM */
+ if ((c = soap_getchar(soap)) != 0xEF || (c = soap_get1(soap)) != 0xBB || (c = soap_get1(soap)) != 0xBF)
+ soap_unget(soap, c);
+ c = soap_get(soap);
+#ifdef WITH_DOM
+ /* whitespace leading to start tag is not insignificant for DOM */
+ if (soap_blank(c))
+ { soap->labidx = 0;
+ do
+ { if (soap_append_lab(soap, NULL, 0))
+ return soap->error;
+ s = soap->labbuf + soap->labidx;
+ i = soap->lablen - soap->labidx;
+ soap->labidx = soap->lablen;
+ while (soap_blank(c) && i--)
+ { *s++ = c;
+ c = soap_get(soap);
+ }
+ }
+ while (soap_blank(c));
+ *s = '\0';
+ if (*soap->labbuf)
+ lead = soap->labbuf;
+ }
+#else
+ /* skip space */
+ while (soap_blank(c))
+ c = soap_get(soap);
+#endif
+ if (c != SOAP_LT)
+ { *soap->tag = '\0';
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ soap_unget(soap, c);
+#ifdef WITH_DOM
+ /* whitespace leading to end tag is not insignificant for DOM */
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ soap->dom->tail = soap_strdup(soap, lead);
+#endif
+ return soap->error = SOAP_NO_TAG;
+ }
+ s = soap->tag;
+ do c = soap_get1(soap);
+ while (soap_blank(c));
+ i = sizeof(soap->tag);
+ while (c != '>' && c != '/' && soap_notblank(c) && (int)c != EOF)
+ { if (--i > 0)
+ *s++ = (char)c;
+ c = soap_get1(soap);
+ }
+ while (soap_blank(c))
+ c = soap_get1(soap);
+ *s = '\0';
+#ifdef WITH_DOM
+ if (soap->mode & SOAP_XML_DOM)
+ { register struct soap_dom_element *elt;
+ elt = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element));
+ if (!elt)
+ return soap->error;
+ elt->next = NULL;
+ elt->nstr = NULL;
+ elt->name = soap_strdup(soap, soap->tag);
+ elt->prnt = soap->dom;
+ elt->elts = NULL;
+ elt->atts = NULL;
+ elt->data = NULL;
+ elt->wide = NULL;
+ elt->type = 0;
+ elt->node = NULL;
+ elt->head = soap_strdup(soap, lead);
+ elt->tail = NULL;
+ elt->soap = soap;
+ if (soap->dom)
+ { struct soap_dom_element *p = soap->dom->elts;
+ if (p)
+ { while (p->next)
+ p = p->next;
+ p->next = elt;
+ }
+ else
+ soap->dom->elts = elt;
+ }
+ soap->dom = elt;
+ att = &elt->atts;
+ }
+#endif
+ soap_pop_namespace(soap);
+ for (tp = soap->attributes; tp; tp = tp->next)
+ tp->visible = 0;
+ while ((int)c != EOF && c != '>' && c != '/')
+ { s = soap->tmpbuf;
+ i = sizeof(soap->tmpbuf);
+ while (c != '=' && c != '>' && c != '/' && soap_notblank(c) && (int)c != EOF)
+ { if (--i > 0)
+ *s++ = (char)c;
+ c = soap_get1(soap);
+ }
+ *s = '\0';
+ if (i == sizeof(soap->tmpbuf))
+ return soap->error = SOAP_SYNTAX_ERROR;
+#ifdef WITH_DOM
+ /* add attribute name to dom */
+ if (att)
+ { *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
+ if (!*att)
+ return soap->error;
+ (*att)->next = NULL;
+ (*att)->nstr = NULL;
+ (*att)->name = soap_strdup(soap, soap->tmpbuf);
+ (*att)->data = NULL;
+ (*att)->wide = NULL;
+ (*att)->soap = soap;
+ }
+#endif
+ if (!strncmp(soap->tmpbuf, "xmlns", 5))
+ { if (soap->tmpbuf[5] == ':')
+ t = soap->tmpbuf + 6;
+ else if (soap->tmpbuf[5])
+ t = NULL;
+ else
+ t = SOAP_STR_EOS;
+ }
+ else
+ t = NULL;
+ tq = NULL;
+ for (tp = soap->attributes; tp; tq = tp, tp = tp->next)
+ { if (!SOAP_STRCMP(tp->name, soap->tmpbuf))
+ break;
+ }
+ if (!tp)
+ { tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + strlen(soap->tmpbuf));
+ if (!tp)
+ return soap->error = SOAP_EOM;
+ strcpy(tp->name, soap->tmpbuf);
+ tp->value = NULL;
+ tp->size = 0;
+ /* if attribute name is qualified, append it to the end of the list */
+ if (tq && strchr(soap->tmpbuf, ':'))
+ { tq->next = tp;
+ tp->next = NULL;
+ }
+ else
+ { tp->next = soap->attributes;
+ soap->attributes = tp;
+ }
+ }
+ while (soap_blank(c))
+ c = soap_get1(soap);
+ if (c == '=')
+ { do c = soap_getutf8(soap);
+ while (soap_blank(c));
+ if (c != SOAP_QT && c != SOAP_AP)
+ { soap_unget(soap, c);
+ c = ' '; /* blank delimiter */
+ }
+ if (soap_getattrval(soap, tp->value, tp->size, c))
+ {
+#ifdef WITH_FAST
+ if (soap->error != SOAP_EOM)
+ return soap->error;
+ soap->error = SOAP_OK;
+ if (soap_store_lab(soap, tp->value, tp->size))
+ return soap->error;
+ if (tp->value)
+ SOAP_FREE(soap, tp->value);
+ for (;;)
+ { if (soap_getattrval(soap, soap->labbuf + soap->labidx, soap->lablen - soap->labidx, c))
+ { if (soap->error != SOAP_EOM)
+ return soap->error;
+ soap->error = SOAP_OK;
+ soap->labidx = soap->lablen;
+ if (soap_append_lab(soap, NULL, 0))
+ return soap->error;
+ }
+ else
+ break;
+ }
+ if (soap->labidx)
+ tp->size = soap->lablen;
+ else
+ { tp->size = strlen(soap->labbuf) + 1;
+ if (tp->size < SOAP_LABLEN)
+ tp->size = SOAP_LABLEN;
+ }
+ if (!(tp->value = (char*)SOAP_MALLOC(soap, tp->size)))
+ return soap->error = SOAP_EOM;
+ strcpy(tp->value, soap->labbuf);
+#else
+ size_t n;
+ if (soap->error != SOAP_EOM)
+ return soap->error;
+ soap->error = SOAP_OK;
+ if (soap_new_block(soap) == NULL)
+ return soap->error;
+ for (;;)
+ { if (!(s = (char*)soap_push_block(soap, NULL, SOAP_BLKLEN)))
+ return soap->error;
+ if (soap_getattrval(soap, s, SOAP_BLKLEN, c))
+ { if (soap->error != SOAP_EOM)
+ return soap->error;
+ soap->error = SOAP_OK;
+ }
+ else
+ break;
+ }
+ n = tp->size + soap->blist->size;
+ if (!(s = (char*)SOAP_MALLOC(soap, n)))
+ return soap->error = SOAP_EOM;
+ if (tp->value)
+ { memcpy(s, tp->value, tp->size);
+ SOAP_FREE(soap, tp->value);
+ }
+ soap_save_block(soap, NULL, s + tp->size, 0);
+ tp->value = s;
+ tp->size = n;
+#endif
+ }
+ do c = soap_get1(soap);
+ while (soap_blank(c));
+ tp->visible = 2; /* seen this attribute w/ value */
+#ifdef WITH_DOM
+ if (att)
+ (*att)->data = soap_strdup(soap, tp->value);
+#endif
+ }
+ else
+ tp->visible = 1; /* seen this attribute w/o value */
+#ifdef WITH_DOM
+ if (att)
+ att = &(*att)->next;
+#endif
+ if (t && tp->value)
+ { if (soap_push_namespace(soap, t, tp->value) == NULL)
+ return soap->error;
+ }
+ }
+#ifdef WITH_DOM
+ if (att)
+ { soap->dom->nstr = soap_current_namespace(soap, soap->tag);
+ for (att = &soap->dom->atts; *att; att = &(*att)->next)
+ (*att)->nstr = soap_current_namespace(soap, (*att)->name);
+ }
+#endif
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ if (!(soap->body = (c != '/')))
+ do c = soap_get1(soap);
+ while (soap_blank(c));
+#ifdef WITH_DOM
+ if (soap->mode & SOAP_XML_DOM)
+ { if (!soap->body && soap->dom->prnt)
+ soap->dom = soap->dom->prnt;
+ }
+#endif
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible && tp->value)
+ {
+#ifndef WITH_NOIDREF
+ if (!strcmp(tp->name, "id"))
+ { if ((soap->version > 0 && !(soap->mode & SOAP_XML_TREE))
+ || (soap->mode & SOAP_XML_GRAPH))
+ { *soap->id = '#';
+ strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2);
+ soap->id[sizeof(soap->id)-1] = '\0';
+ }
+ }
+ else if (!strcmp(tp->name, "href"))
+ { if (soap->version == 1
+ || (soap->mode & SOAP_XML_GRAPH)
+ || (soap->mode & SOAP_ENC_MTOM)
+ || (soap->mode & SOAP_ENC_DIME))
+ { strncpy(soap->href, tp->value, sizeof(soap->href) - 1);
+ soap->href[sizeof(soap->href)-1] = '\0';
+ }
+ }
+ else
+#endif
+ if (!soap_match_tag(soap, tp->name, "xsi:type"))
+ { strncpy(soap->type, tp->value, sizeof(soap->type) - 1);
+ soap->type[sizeof(soap->type)-1] = '\0';
+ }
+ else if ((!soap_match_tag(soap, tp->name, "xsi:null")
+ || !soap_match_tag(soap, tp->name, "xsi:nil"))
+ && (!strcmp(tp->value, "1")
+ || !strcmp(tp->value, "true")))
+ { soap->null = 1;
+ }
+ else if (soap->version == 1)
+ { if (!soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType"))
+ { s = soap_strrchr(tp->value, '[');
+ if (s && (size_t)(s - tp->value) < sizeof(soap->arrayType))
+ { strncpy(soap->arrayType, tp->value, s - tp->value);
+ soap->arrayType[s - tp->value] = '\0';
+ strncpy(soap->arraySize, s, sizeof(soap->arraySize) - 1);
+ }
+ else
+ strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1);
+ soap->arraySize[sizeof(soap->arrayType)-1] = '\0';
+ soap->arrayType[sizeof(soap->arrayType)-1] = '\0';
+ }
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:offset"))
+ strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset));
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:position"))
+ soap->position = soap_getposition(tp->value, soap->positions);
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:root"))
+ soap->root = ((!strcmp(tp->value, "1") || !strcmp(tp->value, "true")));
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand")
+ && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true")))
+ soap->mustUnderstand = 1;
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:actor"))
+ { if ((!soap->actor || strcmp(soap->actor, tp->value))
+ && strcmp(tp->value, "http://schemas.xmlsoap.org/soap/actor/next"))
+ soap->other = 1;
+ }
+ }
+ else if (soap->version == 2)
+ {
+#ifndef WITH_NOIDREF
+ if (!strcmp(tp->name, "ref")
+ || !soap_match_tag(soap, tp->name, "SOAP-ENC:ref"))
+ { *soap->href = '#';
+ strncpy(soap->href + 1, tp->value, sizeof(soap->href) - 2);
+ soap->href[sizeof(soap->href)-1] = '\0';
+ }
+ else
+#endif
+ if (!soap_match_tag(soap, tp->name, "SOAP-ENC:itemType"))
+ strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1);
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:arraySize"))
+ strncpy(soap->arraySize, tp->value, sizeof(soap->arraySize) - 1);
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand")
+ && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true")))
+ soap->mustUnderstand = 1;
+ else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:role"))
+ { if ((!soap->actor || strcmp(soap->actor, tp->value))
+ && strcmp(tp->value, "http://www.w3.org/2003/05/soap-envelope/role/next"))
+ soap->other = 1;
+ }
+ }
+ else
+ { if (!soap_match_tag(soap, tp->name, "wsdl:required") && !strcmp(tp->value, "true"))
+ soap->mustUnderstand = 1;
+ }
+ }
+ }
+ return soap->error = SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_retry(struct soap *soap)
+{ soap->error = SOAP_OK;
+ soap_revert(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_revert(struct soap *soap)
+{ if (!soap->peeked)
+ { soap->peeked = 1;
+ if (soap->body)
+ soap->level--;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reverting last element (level=%u)\n", soap->level));
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_string_out(struct soap *soap, const char *s, int flag)
+{ register const char *t;
+ register soap_wchar c;
+ register soap_wchar mask = (soap_wchar)0xFFFFFF80UL;
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { soap->dom->data = soap_strdup(soap, s);
+ return SOAP_OK;
+ }
+#endif
+ if (flag == 2 || soap->mode & SOAP_C_UTFSTRING)
+ mask = 0;
+ t = s;
+ while ((c = *t++))
+ { switch (c)
+ {
+ case 0x09:
+ if (flag)
+ { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&#x9;", 5))
+ return soap->error;
+ s = t;
+ }
+ break;
+ case 0x0A:
+ if (flag || !(soap->mode & SOAP_XML_CANONICAL))
+ { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&#xA;", 5))
+ return soap->error;
+ s = t;
+ }
+ break;
+ case 0x0D:
+ if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&#xD;", 5))
+ return soap->error;
+ s = t;
+ break;
+ case '&':
+ if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&amp;", 5))
+ return soap->error;
+ s = t;
+ break;
+ case '<':
+ if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&lt;", 4))
+ return soap->error;
+ s = t;
+ break;
+ case '>':
+ if (!flag)
+ { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&gt;", 4))
+ return soap->error;
+ s = t;
+ }
+ break;
+ case '"':
+ if (flag)
+ { if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&quot;", 6))
+ return soap->error;
+ s = t;
+ }
+ break;
+ default:
+#ifndef WITH_LEANER
+#ifdef HAVE_MBTOWC
+ if (soap->mode & SOAP_C_MBSTRING)
+ { wchar_t wc;
+ register int m = mbtowc(&wc, t - 1, MB_CUR_MAX);
+ if (m > 0 && wc != c)
+ { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, wc))
+ return soap->error;
+ s = t += m - 1;
+ continue;
+ }
+ }
+#endif
+#endif
+#ifndef WITH_NOSTRINGTOUTF8
+ if ((c & mask) || !(c & 0xFFFFFFE0UL))
+ { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, (unsigned char)c))
+ return soap->error;
+ s = t;
+ }
+#endif
+ }
+ }
+ return soap_send_raw(soap, s, t - s - 1);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_string_in(struct soap *soap, int flag, long minlen, long maxlen)
+{ register char *s;
+ char *t = NULL;
+ register size_t i;
+ register long l = 0;
+ register int n = 0, f = 0, m = 0;
+ register soap_wchar c;
+#if !defined(WITH_LEANER) && defined(HAVE_WCTOMB)
+ char buf[MB_LEN_MAX > 8 ? MB_LEN_MAX : 8];
+#else
+ char buf[8];
+#endif
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reading string content, flag=%d\n", flag));
+ if (soap->peeked && *soap->tag)
+ {
+#ifndef WITH_LEAN
+ struct soap_attribute *tp;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String content includes tag '%s' and attributes\n", soap->tag));
+ t = soap->tmpbuf;
+ *t = '<';
+ t[sizeof(soap->tmpbuf)-1] = '\0';
+ strncpy(t + 1, soap->tag, sizeof(soap->tmpbuf) - 2);
+ t += strlen(t);
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible)
+ { if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2)
+ break;
+ *t++ = ' ';
+ strcpy(t, tp->name);
+ t += strlen(t);
+ if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2)
+ break; /* too many or large attribute values */
+ if (tp->value)
+ { *t++ = '=';
+ *t++ = '"';
+ strcpy(t, tp->value);
+ t += strlen(t);
+ *t++ = '"';
+ }
+ }
+ }
+ if (!soap->body)
+ *t++ = '/';
+ *t++ = '>';
+ *t = '\0';
+ t = soap->tmpbuf;
+ m = (int)strlen(soap->tmpbuf);
+#endif
+ if (soap->body)
+ n = 1;
+ f = 1;
+ soap->peeked = 0;
+ }
+#ifdef WITH_CDATA
+ if (!flag)
+ { register int state = 0;
+#ifdef WITH_FAST
+ soap->labidx = 0; /* use look-aside buffer */
+#else
+ if (soap_new_block(soap) == NULL)
+ return NULL;
+#endif
+ for (;;)
+ {
+#ifdef WITH_FAST
+ register size_t k;
+ if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */
+ return NULL;
+ s = soap->labbuf + soap->labidx; /* space to populate */
+ k = soap->lablen - soap->labidx; /* number of bytes available */
+ soap->labidx = soap->lablen; /* claim this space */
+#else
+ register size_t k = SOAP_BLKLEN;
+ if (!(s = (char*)soap_push_block(soap, NULL, k)))
+ return NULL;
+#endif
+ for (i = 0; i < k; i++)
+ { if (m > 0)
+ { *s++ = *t++; /* copy multibyte characters */
+ m--;
+ continue;
+ }
+ c = soap_getchar(soap);
+ if ((int)c == EOF)
+ goto end;
+ if (c >= 0x80 && state != 1 && !(soap->mode & SOAP_ENC_LATIN))
+ { soap_unget(soap, c);
+ c = soap_getutf8(soap);
+ if (soap->mode & SOAP_C_UTFSTRING)
+ { c &= 0x7FFFFFFF;
+ t = buf;
+ if (c < 0x0800)
+ *t++ = (char)(0xC0 | ((c >> 6) & 0x1F));
+ else
+ { if (c < 0x010000)
+ *t++ = (char)(0xE0 | ((c >> 12) & 0x0F));
+ else
+ { if (c < 0x200000)
+ *t++ = (char)(0xF0 | ((c >> 18) & 0x07));
+ else
+ { if (c < 0x04000000)
+ *t++ = (char)(0xF8 | ((c >> 24) & 0x03));
+ else
+ { *t++ = (char)(0xFC | ((c >> 30) & 0x01));
+ *t++ = (char)(0x80 | ((c >> 24) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 18) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 12) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 6) & 0x3F));
+ }
+ *t++ = (char)(0x80 | (c & 0x3F));
+ m = (int)(t - buf) - 1;
+ t = buf;
+ *s++ = *t++;
+ continue;
+ }
+ }
+ switch (state)
+ { case 1:
+ if (c == ']')
+ state = 4;
+ *s++ = c;
+ continue;
+ case 2:
+ if (c == '-')
+ state = 6;
+ *s++ = c;
+ continue;
+ case 3:
+ if (c == '?')
+ state = 8;
+ *s++ = c;
+ continue;
+ /* CDATA */
+ case 4:
+ if (c == ']')
+ state = 5;
+ else
+ state = 1;
+ *s++ = c;
+ continue;
+ case 5:
+ if (c == '>')
+ state = 0;
+ else
+ state = 1;
+ *s++ = c;
+ continue;
+ /* comment */
+ case 6:
+ if (c == '-')
+ state = 7;
+ else
+ state = 2;
+ *s++ = c;
+ continue;
+ case 7:
+ if (c == '>')
+ state = 0;
+ else
+ state = 2;
+ *s++ = c;
+ continue;
+ /* PI */
+ case 8:
+ if (c == '>')
+ state = 0;
+ else
+ state = 3;
+ *s++ = c;
+ continue;
+ }
+ switch (c)
+ {
+ case SOAP_TT:
+ if (n == 0)
+ goto end;
+ n--;
+ *s++ = '<';
+ t = (char*)"/";
+ m = 1;
+ break;
+ case SOAP_LT:
+ if (f && n == 0)
+ goto end;
+ n++;
+ *s++ = '<';
+ break;
+ case '/':
+ if (n > 0)
+ { c = soap_getchar(soap);
+ if (c == '>')
+ n--;
+ soap_unget(soap, c);
+ }
+ *s++ = '/';
+ break;
+ case '<':
+ c = soap_getchar(soap);
+ if (c == '/')
+ { if (n == 0)
+ { c = SOAP_TT;
+ goto end;
+ }
+ n--;
+ }
+ else if (c == '!')
+ { c = soap_getchar(soap);
+ if (c == '[')
+ { do c = soap_getchar(soap);
+ while ((int)c != EOF && c != '[');
+ if ((int)c == EOF)
+ goto end;
+ t = (char*)"![CDATA[";
+ m = 8;
+ state = 1;
+ }
+ else if (c == '-')
+ { if ((c = soap_getchar(soap)) == '-')
+ state = 2;
+ t = (char*)"!-";
+ m = 2;
+ soap_unget(soap, c);
+ }
+ else
+ { t = (char*)"!";
+ m = 1;
+ soap_unget(soap, c);
+ }
+ *s++ = '<';
+ break;
+ }
+ else if (c == '?')
+ state = 3;
+ else if (f && n == 0)
+ { soap_revget1(soap);
+ c = '<';
+ goto end;
+ }
+ else
+ n++;
+ soap_unget(soap, c);
+ *s++ = '<';
+ break;
+ case '>':
+ *s++ = '>';
+ break;
+ case '"':
+ *s++ = '"';
+ break;
+ default:
+#ifndef WITH_LEANER
+#ifdef HAVE_WCTOMB
+ if (soap->mode & SOAP_C_MBSTRING)
+ { m = wctomb(buf, c & 0x7FFFFFFF);
+ if (m >= 1 && m <= (int)MB_CUR_MAX)
+ { t = buf;
+ *s++ = *t++;
+ m--;
+ }
+ else
+ { *s++ = SOAP_UNKNOWN_CHAR;
+ m = 0;
+ }
+ }
+ else
+#endif
+#endif
+ *s++ = (char)(c & 0xFF);
+ }
+ l++;
+ if (maxlen >= 0 && l > maxlen)
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen));
+ soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+ }
+ }
+ }
+#endif
+#ifdef WITH_FAST
+ soap->labidx = 0; /* use look-aside buffer */
+#else
+ if (soap_new_block(soap) == NULL)
+ return NULL;
+#endif
+ for (;;)
+ {
+#ifdef WITH_FAST
+ register size_t k;
+ if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */
+ return NULL;
+ s = soap->labbuf + soap->labidx; /* space to populate */
+ k = soap->lablen - soap->labidx; /* number of bytes available */
+ soap->labidx = soap->lablen; /* claim this space */
+#else
+ register size_t k = SOAP_BLKLEN;
+ if (!(s = (char*)soap_push_block(soap, NULL, k)))
+ return NULL;
+#endif
+ for (i = 0; i < k; i++)
+ { if (m > 0)
+ { *s++ = *t++; /* copy multibyte characters */
+ m--;
+ continue;
+ }
+ if (soap->mode & SOAP_C_UTFSTRING)
+ { if (((c = soap_get(soap)) & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP)
+ { c &= 0x7FFFFFFF;
+ t = buf;
+ if (c < 0x0800)
+ *t++ = (char)(0xC0 | ((c >> 6) & 0x1F));
+ else
+ { if (c < 0x010000)
+ *t++ = (char)(0xE0 | ((c >> 12) & 0x0F));
+ else
+ { if (c < 0x200000)
+ *t++ = (char)(0xF0 | ((c >> 18) & 0x07));
+ else
+ { if (c < 0x04000000)
+ *t++ = (char)(0xF8 | ((c >> 24) & 0x03));
+ else
+ { *t++ = (char)(0xFC | ((c >> 30) & 0x01));
+ *t++ = (char)(0x80 | ((c >> 24) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 18) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 12) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 6) & 0x3F));
+ }
+ *t++ = (char)(0x80 | (c & 0x3F));
+ m = (int)(t - buf) - 1;
+ t = buf;
+ *s++ = *t++;
+ continue;
+ }
+ }
+ else
+ c = soap_getutf8(soap);
+ switch (c)
+ {
+ case SOAP_TT:
+ if (n == 0)
+ goto end;
+ n--;
+ *s++ = '<';
+ t = (char*)"/";
+ m = 1;
+ break;
+ case SOAP_LT:
+ if (f && n == 0)
+ goto end;
+ n++;
+ *s++ = '<';
+ break;
+ case SOAP_GT:
+ *s++ = '>';
+ break;
+ case SOAP_QT:
+ *s++ = '"';
+ break;
+ case SOAP_AP:
+ *s++ = '\'';
+ break;
+ case '/':
+ if (n > 0)
+ { c = soap_get(soap);
+ if (c == SOAP_GT)
+ n--;
+ soap_unget(soap, c);
+ }
+ *s++ = '/';
+ break;
+ case (soap_wchar)('<' | 0x80000000):
+ if (flag)
+ *s++ = '<';
+ else
+ { *s++ = '&';
+ t = (char*)"lt;";
+ m = 3;
+ }
+ break;
+ case (soap_wchar)('>' | 0x80000000):
+ if (flag)
+ *s++ = '>';
+ else
+ { *s++ = '&';
+ t = (char*)"gt;";
+ m = 3;
+ }
+ break;
+ case (soap_wchar)('&' | 0x80000000):
+ if (flag)
+ *s++ = '&';
+ else
+ { *s++ = '&';
+ t = (char*)"amp;";
+ m = 4;
+ }
+ break;
+ case (soap_wchar)('"' | 0x80000000):
+ if (flag)
+ *s++ = '"';
+ else
+ { *s++ = '&';
+ t = (char*)"quot;";
+ m = 5;
+ }
+ break;
+ case (soap_wchar)('\'' | 0x80000000):
+ if (flag)
+ *s++ = '\'';
+ else
+ { *s++ = '&';
+ t = (char*)"apos;";
+ m = 5;
+ }
+ break;
+ default:
+ if ((int)c == EOF)
+ goto end;
+#ifndef WITH_LEANER
+#ifdef HAVE_WCTOMB
+ if (soap->mode & SOAP_C_MBSTRING)
+ { m = wctomb(buf, c & 0x7FFFFFFF);
+ if (m >= 1 && m <= (int)MB_CUR_MAX)
+ { t = buf;
+ *s++ = *t++;
+ m--;
+ }
+ else
+ { *s++ = SOAP_UNKNOWN_CHAR;
+ m = 0;
+ }
+ }
+ else
+#endif
+#endif
+ *s++ = (char)(c & 0xFF);
+ }
+ l++;
+ if (maxlen >= 0 && l > maxlen)
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen));
+ soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+ }
+ }
+end:
+ soap_unget(soap, c);
+ *s = '\0';
+#ifdef WITH_FAST
+ t = soap_strdup(soap, soap->labbuf);
+#else
+ soap_size_block(soap, NULL, i+1);
+ t = soap_save_block(soap, NULL, 0);
+#endif
+ if (l < minlen)
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen));
+ soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { if (flag == 3)
+ soap->dom->tail = t;
+ else
+ soap->dom->data = t;
+ }
+#endif
+ if (flag == 2)
+ if (soap_s2QName(soap, t, &t, minlen, maxlen))
+ return NULL;
+ return t;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_wstring_out(struct soap *soap, const wchar_t *s, int flag)
+{ const char *t;
+ char tmp;
+ register soap_wchar c;
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ { wchar_t *r = (wchar_t*)s;
+ int n = 1;
+ while (*r++)
+ n++;
+ soap->dom->wide = r = (wchar_t*)soap_malloc(soap, n * sizeof(wchar_t));
+ while (n--)
+ *r++ = *s++;
+ return SOAP_OK;
+ }
+#endif
+ while ((c = *s++))
+ { switch (c)
+ {
+ case 0x09:
+ if (flag)
+ t = "&#x9;";
+ else
+ t = "\t";
+ break;
+ case 0x0A:
+ if (flag || !(soap->mode & SOAP_XML_CANONICAL))
+ t = "&#xA;";
+ else
+ t = "\n";
+ break;
+ case 0x0D:
+ t = "&#xD;";
+ break;
+ case '&':
+ t = "&amp;";
+ break;
+ case '<':
+ t = "&lt;";
+ break;
+ case '>':
+ if (flag)
+ t = ">";
+ else
+ t = "&gt;";
+ break;
+ case '"':
+ if (flag)
+ t = "&quot;";
+ else
+ t = "\"";
+ break;
+ default:
+ if (c >= 0x20 && c < 0x80)
+ { tmp = (char)c;
+ if (soap_send_raw(soap, &tmp, 1))
+ return soap->error;
+ }
+ else if (soap_pututf8(soap, (unsigned long)c))
+ return soap->error;
+ continue;
+ }
+ if (soap_send(soap, t))
+ return soap->error;
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_2
+SOAP_FMAC1
+wchar_t *
+SOAP_FMAC2
+soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen)
+{ wchar_t *s;
+ register int i, n = 0, f = 0;
+ register long l = 0;
+ register soap_wchar c;
+ char *t = NULL;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reading wide string content\n"));
+ if (soap->peeked)
+ { if (*soap->tag)
+ {
+#ifndef WITH_LEAN
+ struct soap_attribute *tp;
+ t = soap->tmpbuf;
+ *t = '<';
+ t[sizeof(soap->tmpbuf)-1] = '\0';
+ strncpy(t + 1, soap->tag, sizeof(soap->tmpbuf) - 2);
+ t += strlen(t);
+ for (tp = soap->attributes; tp; tp = tp->next)
+ { if (tp->visible)
+ { if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2)
+ break;
+ *t++ = ' ';
+ strcpy(t, tp->name);
+ t += strlen(t);
+ if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2)
+ break;
+ if (tp->value)
+ { *t++ = '=';
+ *t++ = '"';
+ strcpy(t, tp->value);
+ t += strlen(t);
+ *t++ = '"';
+ }
+ }
+ }
+ if (!soap->body)
+ *t++ = '/';
+ *t++ = '>';
+ *t = '\0';
+ t = soap->tmpbuf;
+#endif
+ if (soap->body)
+ n = 1;
+ f = 1;
+ soap->peeked = 0;
+ }
+ }
+ if (soap_new_block(soap) == NULL)
+ return NULL;
+ for (;;)
+ { if (!(s = (wchar_t*)soap_push_block(soap, NULL, sizeof(wchar_t)*SOAP_BLKLEN)))
+ return NULL;
+ for (i = 0; i < SOAP_BLKLEN; i++)
+ { if (t)
+ { *s++ = (wchar_t)*t++;
+ if (!*t)
+ t = NULL;
+ continue;
+ }
+ c = soap_getutf8(soap);
+ switch (c)
+ {
+ case SOAP_TT:
+ if (n == 0)
+ goto end;
+ n--;
+ *s++ = '<';
+ soap_unget(soap, '/');
+ break;
+ case SOAP_LT:
+ if (f && n == 0)
+ goto end;
+ n++;
+ *s++ = '<';
+ break;
+ case SOAP_GT:
+ *s++ = '>';
+ break;
+ case SOAP_QT:
+ *s++ = '"';
+ break;
+ case SOAP_AP:
+ *s++ = '\'';
+ break;
+ case '/':
+ if (n > 0)
+ { c = soap_getutf8(soap);
+ if (c == SOAP_GT)
+ n--;
+ soap_unget(soap, c);
+ }
+ *s++ = '/';
+ break;
+ case '<':
+ if (flag)
+ *s++ = (soap_wchar)'<';
+ else
+ { *s++ = (soap_wchar)'&';
+ t = (char*)"lt;";
+ }
+ break;
+ case '>':
+ if (flag)
+ *s++ = (soap_wchar)'>';
+ else
+ { *s++ = (soap_wchar)'&';
+ t = (char*)"gt;";
+ }
+ break;
+ case '"':
+ if (flag)
+ *s++ = (soap_wchar)'"';
+ else
+ { *s++ = (soap_wchar)'&';
+ t = (char*)"quot;";
+ }
+ break;
+ default:
+ if ((int)c == EOF)
+ goto end;
+ *s++ = (wchar_t)c & 0x7FFFFFFF;
+ }
+ l++;
+ if (maxlen >= 0 && l > maxlen)
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen));
+ soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+ }
+ }
+end:
+ soap_unget(soap, c);
+ *s = '\0';
+ soap_size_block(soap, NULL, sizeof(wchar_t) * (i + 1));
+ if (l < minlen)
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen));
+ soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+ s = (wchar_t*)soap_save_block(soap, NULL, NULL, 0);
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ soap->dom->wide = s;
+#endif
+ return s;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_int2s(struct soap *soap, int n)
+{ return soap_long2s(soap, (long)n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outint(struct soap *soap, const char *tag, int id, const int *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_long2s(soap, (long)*p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2int(struct soap *soap, const char *s, int *p)
+{ if (s)
+ { char *r;
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ soap_reset_errno;
+#endif
+#endif
+ *p = (int)soap_strtol(s, &r, 10);
+ if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ || soap_errno == SOAP_ERANGE
+#endif
+#endif
+ )
+ soap->error = SOAP_TYPE;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int *
+SOAP_FMAC2
+soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":int")
+ && soap_match_tag(soap, soap->type, ":short")
+ && soap_match_tag(soap, soap->type, ":byte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (int*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(int), 0, NULL);
+ else if (p)
+ { if (soap_s2int(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_long2s(struct soap *soap, long n)
+{ sprintf(soap->tmpbuf, "%ld", n);
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outlong(struct soap *soap, const char *tag, int id, const long *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_long2s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2long(struct soap *soap, const char *s, long *p)
+{ if (s)
+ { char *r;
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ soap_reset_errno;
+#endif
+#endif
+ *p = soap_strtol(s, &r, 10);
+ if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ || soap_errno == SOAP_ERANGE
+#endif
+#endif
+ )
+ soap->error = SOAP_TYPE;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+long *
+SOAP_FMAC2
+soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":int")
+ && soap_match_tag(soap, soap->type, ":short")
+ && soap_match_tag(soap, soap->type, ":byte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (long*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(long), 0, NULL);
+ else if (p)
+ { if (soap_s2long(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_LONG642s(struct soap *soap, LONG64 n)
+{ sprintf(soap->tmpbuf, SOAP_LONG_FORMAT, n);
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outLONG64(struct soap *soap, const char *tag, int id, const LONG64 *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_LONG642s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p)
+{ if (s)
+ {
+#ifdef HAVE_STRTOLL
+ char *r;
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ soap_reset_errno;
+#endif
+#endif
+ *p = strtoll(s, &r, 10);
+ if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ || soap_errno == SOAP_ERANGE
+#endif
+#endif
+ )
+#else
+# ifdef HAVE_SSCANF
+ if (sscanf(s, SOAP_LONG_FORMAT, p) != 1)
+# endif
+#endif
+ soap->error = SOAP_TYPE;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+LONG64 *
+SOAP_FMAC2
+soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":integer")
+ && soap_match_tag(soap, soap->type, ":positiveInteger")
+ && soap_match_tag(soap, soap->type, ":negativeInteger")
+ && soap_match_tag(soap, soap->type, ":nonPositiveInteger")
+ && soap_match_tag(soap, soap->type, ":nonNegativeInteger")
+ && soap_match_tag(soap, soap->type, ":long")
+ && soap_match_tag(soap, soap->type, ":int")
+ && soap_match_tag(soap, soap->type, ":short")
+ && soap_match_tag(soap, soap->type, ":byte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (LONG64*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(LONG64), 0, NULL);
+ else if (p)
+ { if (soap_s2LONG64(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_byte2s(struct soap *soap, char n)
+{ return soap_long2s(soap, (long)n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outbyte(struct soap *soap, const char *tag, int id, const char *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_long2s(soap, (long)*p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2byte(struct soap *soap, const char *s, char *p)
+{ if (s)
+ { long n;
+ char *r;
+ n = soap_strtol(s, &r, 10);
+ if (s == r || *r || n < -128 || n > 127)
+ soap->error = SOAP_TYPE;
+ *p = (char)n;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":byte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (char*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(char), 0, NULL);
+ else if (p)
+ { if (soap_s2byte(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_short2s(struct soap *soap, short n)
+{ return soap_long2s(soap, (long)n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outshort(struct soap *soap, const char *tag, int id, const short *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_long2s(soap, (long)*p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2short(struct soap *soap, const char *s, short *p)
+{ if (s)
+ { long n;
+ char *r;
+ n = soap_strtol(s, &r, 10);
+ if (s == r || *r || n < -32768 || n > 32767)
+ soap->error = SOAP_TYPE;
+ *p = (short)n;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+short *
+SOAP_FMAC2
+soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":short")
+ && soap_match_tag(soap, soap->type, ":byte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (short*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(short), 0, NULL);
+ else if (p)
+ { if (soap_s2short(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_float2s(struct soap *soap, float n)
+{ char *s;
+ if (soap_isnan((double)n))
+ return "NaN";
+ if (soap_ispinff(n))
+ return "INF";
+ if (soap_isninff(n))
+ return "-INF";
+ s = soap->tmpbuf;
+#if defined(HAVE_SPRINTF_L)
+ sprintf_l(s, soap->c_locale, soap->float_format, n);
+#else
+ sprintf(s, soap->float_format, n);
+ s = strchr(s, ','); /* convert decimal comma to DP */
+ if (s)
+ *s = '.';
+#endif
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outfloat(struct soap *soap, const char *tag, int id, const float *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_float2s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2float(struct soap *soap, const char *s, float *p)
+{ if (s)
+ { if (!*s)
+ return soap->error = SOAP_TYPE;
+ if (!soap_tag_cmp(s, "INF"))
+ *p = FLT_PINFTY;
+ else if (!soap_tag_cmp(s, "+INF"))
+ *p = FLT_PINFTY;
+ else if (!soap_tag_cmp(s, "-INF"))
+ *p = FLT_NINFTY;
+ else if (!soap_tag_cmp(s, "NaN"))
+ *p = FLT_NAN;
+ else
+ {
+/* On some systems strtof requires -std=c99 or does not even link: so we try to use strtod first */
+#if defined(HAVE_STRTOD_L)
+ char *r;
+ *p = (float)strtod_l(s, &r, soap->c_locale);
+ if (*r)
+#elif defined(HAVE_STRTOD)
+ char *r;
+ *p = (float)strtod(s, &r);
+ if (*r)
+#elif defined(HAVE_STRTOF_L)
+ char *r;
+ *p = strtof_l((char*)s, &r, soap->c_locale);
+ if (*r)
+#elif defined(HAVE_STRTOF)
+ char *r;
+ *p = strtof((char*)s, &r);
+ if (*r)
+#endif
+ {
+#if defined(HAVE_SSCANF_L) && !defined(HAVE_STRTOF_L) && !defined(HAVE_STRTOD_L)
+ if (sscanf_l(s, soap->c_locale, "%g", p) != 1)
+ soap->error = SOAP_TYPE;
+#elif defined(HAVE_SSCANF)
+ if (sscanf(s, "%g", p) != 1)
+ soap->error = SOAP_TYPE;
+#else
+ soap->error = SOAP_TYPE;
+#endif
+ }
+ }
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+static int soap_isnumeric(struct soap *soap, const char *type)
+{ if (soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":float")
+ && soap_match_tag(soap, soap->type, ":double")
+ && soap_match_tag(soap, soap->type, ":decimal")
+ && soap_match_tag(soap, soap->type, ":integer")
+ && soap_match_tag(soap, soap->type, ":positiveInteger")
+ && soap_match_tag(soap, soap->type, ":negativeInteger")
+ && soap_match_tag(soap, soap->type, ":nonPositiveInteger")
+ && soap_match_tag(soap, soap->type, ":nonNegativeInteger")
+ && soap_match_tag(soap, soap->type, ":long")
+ && soap_match_tag(soap, soap->type, ":int")
+ && soap_match_tag(soap, soap->type, ":short")
+ && soap_match_tag(soap, soap->type, ":byte")
+ && soap_match_tag(soap, soap->type, ":unsignedLong")
+ && soap_match_tag(soap, soap->type, ":unsignedInt")
+ && soap_match_tag(soap, soap->type, ":unsignedShort")
+ && soap_match_tag(soap, soap->type, ":unsignedByte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return SOAP_ERR;
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+float *
+SOAP_FMAC2
+soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type != '\0' && soap_isnumeric(soap, type))
+ return NULL;
+#endif
+ p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (float*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(float), 0, NULL);
+ else if (p)
+ { if (soap_s2float(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_double2s(struct soap *soap, double n)
+{ char *s;
+ if (soap_isnan(n))
+ return "NaN";
+ if (soap_ispinfd(n))
+ return "INF";
+ if (soap_isninfd(n))
+ return "-INF";
+ s = soap->tmpbuf;
+#if defined(HAVE_SPRINTF_L)
+ sprintf_l(s, soap->c_locale, soap->double_format, n);
+#else
+ sprintf(s, soap->double_format, n);
+ s = strchr(s, ','); /* convert decimal comma to DP */
+ if (s)
+ *s = '.';
+#endif
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outdouble(struct soap *soap, const char *tag, int id, const double *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_double2s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2double(struct soap *soap, const char *s, double *p)
+{ if (s)
+ { if (!*s)
+ return soap->error = SOAP_TYPE;
+ if (!soap_tag_cmp(s, "INF"))
+ *p = DBL_PINFTY;
+ else if (!soap_tag_cmp(s, "+INF"))
+ *p = DBL_PINFTY;
+ else if (!soap_tag_cmp(s, "-INF"))
+ *p = DBL_NINFTY;
+ else if (!soap_tag_cmp(s, "NaN"))
+ *p = DBL_NAN;
+ else
+ {
+#if defined(HAVE_STRTOD_L)
+ char *r;
+ *p = strtod_l(s, &r, soap->c_locale);
+ if (*r)
+#elif defined(HAVE_STRTOD)
+ char *r;
+ *p = strtod(s, &r);
+ if (*r)
+#endif
+ {
+#if defined(HAVE_SSCANF_L) && !defined(HAVE_STRTOF_L) && !defined(HAVE_STRTOD_L)
+ if (sscanf_l(s, soap->c_locale, "%lg", p) != 1)
+ soap->error = SOAP_TYPE;
+#elif defined(HAVE_SSCANF)
+ if (sscanf(s, "%lg", p) != 1)
+ soap->error = SOAP_TYPE;
+#else
+ soap->error = SOAP_TYPE;
+#endif
+ }
+ }
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+double *
+SOAP_FMAC2
+soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type != '\0' && soap_isnumeric(soap, type))
+ return NULL;
+#endif
+ p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (double*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(double), 0, NULL);
+ else if (p)
+ { if (soap_s2double(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_unsignedByte2s(struct soap *soap, unsigned char n)
+{ return soap_unsignedLong2s(soap, (unsigned long)n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outunsignedByte(struct soap *soap, const char *tag, int id, const unsigned char *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p)
+{ if (s)
+ { unsigned long n;
+ char *r;
+ n = soap_strtoul(s, &r, 10);
+ if (s == r || *r || n > 255)
+ soap->error = SOAP_TYPE;
+ *p = (unsigned char)n;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+unsigned char *
+SOAP_FMAC2
+soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":unsignedByte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (unsigned char*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned char), 0, NULL);
+ else if (p)
+ { if (soap_s2unsignedByte(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_unsignedShort2s(struct soap *soap, unsigned short n)
+{ return soap_unsignedLong2s(soap, (unsigned long)n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outunsignedShort(struct soap *soap, const char *tag, int id, const unsigned short *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p)
+{ if (s)
+ { unsigned long n;
+ char *r;
+ n = soap_strtoul(s, &r, 10);
+ if (s == r || *r || n > 65535)
+ soap->error = SOAP_TYPE;
+ *p = (unsigned short)n;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+unsigned short *
+SOAP_FMAC2
+soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":unsignedShort")
+ && soap_match_tag(soap, soap->type, ":unsignedByte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (unsigned short*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned short), 0, NULL);
+ else if (p)
+ { if (soap_s2unsignedShort(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_unsignedInt2s(struct soap *soap, unsigned int n)
+{ return soap_unsignedLong2s(soap, (unsigned long)n);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outunsignedInt(struct soap *soap, const char *tag, int id, const unsigned int *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_unsignedLong2s(soap, (unsigned long)*p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p)
+{ if (s)
+ { char *r;
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ soap_reset_errno;
+#endif
+#endif
+ *p = (unsigned int)soap_strtoul(s, &r, 10);
+ if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ || soap_errno == SOAP_ERANGE
+#endif
+#endif
+ )
+ soap->error = SOAP_TYPE;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+unsigned int *
+SOAP_FMAC2
+soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":unsignedInt")
+ && soap_match_tag(soap, soap->type, ":unsignedShort")
+ && soap_match_tag(soap, soap->type, ":unsignedByte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (unsigned int*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned int), 0, NULL);
+ else if (p)
+ { if (soap_s2unsignedInt(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_unsignedLong2s(struct soap *soap, unsigned long n)
+{ sprintf(soap->tmpbuf, "%lu", n);
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outunsignedLong(struct soap *soap, const char *tag, int id, const unsigned long *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_unsignedLong2s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p)
+{ if (s)
+ { char *r;
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ soap_reset_errno;
+#endif
+#endif
+ *p = soap_strtoul(s, &r, 10);
+ if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ || soap_errno == SOAP_ERANGE
+#endif
+#endif
+ )
+ soap->error = SOAP_TYPE;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+unsigned long *
+SOAP_FMAC2
+soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+#ifndef WITH_LEAN
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":unsignedInt")
+ && soap_match_tag(soap, soap->type, ":unsignedShort")
+ && soap_match_tag(soap, soap->type, ":unsignedByte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+#endif
+ p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (unsigned long*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned long), 0, NULL);
+ else if (p)
+ { if (soap_s2unsignedLong(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_ULONG642s(struct soap *soap, ULONG64 n)
+{ sprintf(soap->tmpbuf, SOAP_ULONG_FORMAT, n);
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outULONG64(struct soap *soap, const char *tag, int id, const ULONG64 *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_ULONG642s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p)
+{ if (s)
+ {
+#ifdef HAVE_STRTOULL
+ char *r;
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ soap_reset_errno;
+#endif
+#endif
+ *p = strtoull(s, &r, 10);
+ if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r
+#ifndef WITH_NOIO
+#ifndef WITH_LEAN
+ || soap_errno == SOAP_ERANGE
+#endif
+#endif
+ )
+#else
+#ifdef HAVE_SSCANF
+ if (sscanf(s, SOAP_ULONG_FORMAT, p) != 1)
+#endif
+#endif
+ soap->error = SOAP_TYPE;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+ULONG64 *
+SOAP_FMAC2
+soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":positiveInteger")
+ && soap_match_tag(soap, soap->type, ":nonNegativeInteger")
+ && soap_match_tag(soap, soap->type, ":unsignedLong")
+ && soap_match_tag(soap, soap->type, ":unsignedInt")
+ && soap_match_tag(soap, soap->type, ":unsignedShort")
+ && soap_match_tag(soap, soap->type, ":unsignedByte"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+ p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (ULONG64*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(ULONG64), 0, NULL);
+ else if (p)
+ { if (soap_s2ULONG64(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2string(struct soap *soap, const char *s, char **t, long minlen, long maxlen)
+{ if (s)
+ { long l = (long)strlen(s);
+ if ((maxlen >= 0 && l > maxlen) || l < minlen)
+ return soap->error = SOAP_LENGTH;
+ if (!(*t = soap_strdup(soap, s)))
+ return soap->error = SOAP_EOM;
+ if (!(soap->mode & (SOAP_ENC_LATIN | SOAP_C_UTFSTRING)))
+ { char *r = *t;
+ /* remove non-ASCII chars */
+ for (s = *t; *s; s++)
+ if (!(*s & 0x80))
+ *r++ = *s;
+ *r = '\0';
+ }
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxlen)
+{ if (s)
+ { long l = (long)strlen(s);
+ if ((maxlen >= 0 && l > maxlen) || l < minlen)
+ return soap->error = SOAP_LENGTH;
+ soap->labidx = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Normalized namespace(s) of QNames '%s'", s));
+ /* convert (by prefix normalize prefix) all QNames in s */
+ for (;;)
+ { size_t n;
+ struct soap_nlist *np;
+ register const char *p;
+ /* skip blanks */
+ while (*s && soap_blank(*s))
+ s++;
+ if (!*s)
+ break;
+ /* find next QName */
+ n = 1;
+ while (s[n] && !soap_blank(s[n]))
+ n++;
+ np = soap->nlist;
+ /* if there is no namespace stack, or prefix is "xml" then copy string */
+ if (!np || !strncmp(s, "xml:", 4))
+ { soap_append_lab(soap, s, n);
+ }
+ else /* we normalize the QName by replacing its prefix */
+ { for (p = s; *p && p < s + n; p++)
+ if (*p == ':')
+ break;
+ if (*p == ':')
+ { size_t k = p - s;
+ while (np && (strncmp(np->id, s, k) || np->id[k]))
+ np = np->next;
+ p++;
+ }
+ else
+ { while (np && *np->id)
+ np = np->next;
+ p = s;
+ }
+ /* replace prefix */
+ if (np)
+ { if (np->index >= 0 && soap->local_namespaces)
+ { const char *q = soap->local_namespaces[np->index].id;
+ if (q)
+ soap_append_lab(soap, q, strlen(q));
+ }
+ else if (np->ns)
+ { soap_append_lab(soap, "\"", 1);
+ soap_append_lab(soap, np->ns, strlen(np->ns));
+ soap_append_lab(soap, "\"", 1);
+ }
+ else
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\nNamespace prefix of '%s' not defined (index=%d, URI=%s)\n", s, np->index, np->ns?np->ns:SOAP_STR_EOS));
+ return soap->error = SOAP_NAMESPACE;
+ }
+ }
+ else if (s[n]) /* no namespace, part of string */
+ { soap_append_lab(soap, s, n);
+ }
+ else /* no namespace: assume "" namespace */
+ { soap_append_lab(soap, "\"\"", 2);
+ }
+ soap_append_lab(soap, ":", 1);
+ soap_append_lab(soap, p, n - (p-s));
+ }
+ /* advance to next and add spacing */
+ s += n;
+ if (*s)
+ soap_append_lab(soap, " ", 1);
+ }
+ soap_append_lab(soap, SOAP_STR_EOS, 1);
+ *t = soap_strdup(soap, soap->labbuf);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, " into '%s'\n", *t));
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_QName2s(struct soap *soap, const char *s)
+{ const char *t = NULL;
+ if (s)
+ { soap->labidx = 0;
+ for (;;)
+ { size_t n;
+ /* skip blanks */
+ while (*s && soap_blank(*s))
+ s++;
+ if (!*s)
+ break;
+ /* find next QName */
+ n = 1;
+ while (s[n] && !soap_blank(s[n]))
+ n++;
+ /* normal prefix: pass string as is */
+ if (*s != '"')
+ { soap_append_lab(soap, s, n);
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_XML_CANONICAL))
+ { const char *r = strchr(s, ':');
+ if (r)
+ soap_utilize_ns(soap, s, r - s);
+ }
+#endif
+ }
+ else /* URL-based string prefix */
+ { const char *q;
+ s++;
+ q = strchr(s, '"');
+ if (q)
+ { struct Namespace *p = soap->local_namespaces;
+ if (p)
+ { for (; p->id; p++)
+ { if (p->ns)
+ if (!soap_tag_cmp(s, p->ns))
+ break;
+ if (p->in)
+ if (!soap_tag_cmp(s, p->in))
+ break;
+ }
+ }
+ /* URL is in the namespace table? */
+ if (p && p->id)
+ { soap_append_lab(soap, p->id, strlen(p->id));
+ }
+ else /* not in namespace table: create xmlns binding */
+ { char *r = soap_strdup(soap, s);
+ r[q-s] = '\0';
+ sprintf(soap->tmpbuf, "xmlns:_%d", soap->idnum++);
+ soap_set_attr(soap, soap->tmpbuf, r, 1);
+ soap_append_lab(soap, soap->tmpbuf + 6, strlen(soap->tmpbuf + 6));
+ }
+ soap_append_lab(soap, q + 1, n - (q-s) - 1);
+ }
+ }
+ /* advance to next and add spacing */
+ s += n;
+ if (*s)
+ soap_append_lab(soap, " ", 1);
+ }
+ soap_append_lab(soap, SOAP_STR_EOS, 1);
+ t = soap_strdup(soap, soap->labbuf);
+ }
+ return t;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2wchar(struct soap *soap, const char *s, wchar_t **t, long minlen, long maxlen)
+{ if (s)
+ { long l;
+ wchar_t *r;
+ *t = r = (wchar_t*)soap_malloc(soap, sizeof(wchar_t) * (strlen(s) + 1));
+ if (!r)
+ return soap->error = SOAP_EOM;
+ if (soap->mode & SOAP_ENC_LATIN)
+ { while (*s)
+ *r++ = (wchar_t)*s++;
+ }
+ else
+ { /* Convert UTF8 to wchar */
+ while (*s)
+ { register soap_wchar c, c1, c2, c3, c4;
+ c = (unsigned char)*s++;
+ if (c < 0x80)
+ *r++ = (wchar_t)c;
+ else
+ { c1 = (soap_wchar)*s++ & 0x3F;
+ if (c < 0xE0)
+ *r++ = (wchar_t)(((soap_wchar)(c & 0x1F) << 6) | c1);
+ else
+ { c2 = (soap_wchar)*s++ & 0x3F;
+ if (c < 0xF0)
+ *r++ = (wchar_t)(((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2);
+ else
+ { c3 = (soap_wchar)*s++ & 0x3F;
+ if (c < 0xF8)
+ *r++ = (wchar_t)(((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3);
+ else
+ { c4 = (soap_wchar)*s++ & 0x3F;
+ if (c < 0xFC)
+ *r++ = (wchar_t)(((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4);
+ else
+ *r++ = (wchar_t)(((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(*s++ & 0x3F));
+ }
+ }
+ }
+ }
+ }
+ }
+ *r = L'\0';
+ l = (long)(r - *t);
+ if ((maxlen >= 0 && l > maxlen) || l < minlen)
+ return soap->error = SOAP_LENGTH;
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_wchar2s(struct soap *soap, const wchar_t *s)
+{ register soap_wchar c;
+ register char *r, *t;
+ const wchar_t *q = s;
+ size_t n = 0;
+ while ((c = *q++))
+ { if (c > 0 && c < 0x80)
+ n++;
+ else
+ n += 6;
+ }
+ r = t = (char*)soap_malloc(soap, n + 1);
+ if (r)
+ { /* Convert wchar to UTF8 */
+ while ((c = *s++))
+ { if (c > 0 && c < 0x80)
+ *t++ = (char)c;
+ else
+ { if (c < 0x0800)
+ *t++ = (char)(0xC0 | ((c >> 6) & 0x1F));
+ else
+ { if (c < 0x010000)
+ *t++ = (char)(0xE0 | ((c >> 12) & 0x0F));
+ else
+ { if (c < 0x200000)
+ *t++ = (char)(0xF0 | ((c >> 18) & 0x07));
+ else
+ { if (c < 0x04000000)
+ *t++ = (char)(0xF8 | ((c >> 24) & 0x03));
+ else
+ { *t++ = (char)(0xFC | ((c >> 30) & 0x01));
+ *t++ = (char)(0x80 | ((c >> 24) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 18) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 12) & 0x3F));
+ }
+ *t++ = (char)(0x80 | ((c >> 6) & 0x3F));
+ }
+ *t++ = (char)(0x80 | (c & 0x3F));
+ }
+ }
+ *t = '\0';
+ }
+ return r;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const char *type, int n)
+{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n);
+ if (id < 0)
+ return soap->error;
+ if (!**p && (soap->mode & SOAP_C_NILSTRING))
+ return soap_element_null(soap, tag, id, type);
+ if (soap_element_begin_out(soap, tag, id, type)
+ || soap_string_out(soap, *p, 0)
+ || soap_element_end_out(soap, tag))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char **
+SOAP_FMAC2
+soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen)
+{ if (soap_element_begin_in(soap, tag, 1, NULL))
+ { if (!tag || *tag != '-' || soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ }
+ if (!p)
+ { if (!(p = (char**)soap_malloc(soap, sizeof(char*))))
+ return NULL;
+ }
+ if (soap->null)
+ *p = NULL;
+ else if (soap->body)
+ { *p = soap_string_in(soap, flag, minlen, maxlen);
+ if (!*p || !(char*)soap_id_enter(soap, soap->id, *p, t, sizeof(char*), 0, NULL, NULL, NULL))
+ return NULL;
+ if (!**p && tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ }
+ else if (tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ else if (!*soap->href && minlen > 0)
+ { soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+ else
+ *p = soap_strdup(soap, SOAP_STR_EOS);
+ if (*soap->href)
+ p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char**), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, const char *type, int n)
+{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n);
+ if (id < 0)
+ return soap->error;
+ if (!**p && (soap->mode & SOAP_C_NILSTRING))
+ return soap_element_null(soap, tag, id, type);
+ if (soap_element_begin_out(soap, tag, id, type)
+ || soap_wstring_out(soap, *p, 0)
+ || soap_element_end_out(soap, tag))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_2
+SOAP_FMAC1
+wchar_t **
+SOAP_FMAC2
+soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen)
+{ if (soap_element_begin_in(soap, tag, 1, NULL))
+ { if (!tag || *tag != '-' || soap->error != SOAP_NO_TAG)
+ return NULL;
+ soap->error = SOAP_OK;
+ }
+ if (!p)
+ { if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*))))
+ return NULL;
+ }
+ if (soap->body)
+ { *p = soap_wstring_in(soap, 1, minlen, maxlen);
+ if (!*p || !(wchar_t*)soap_id_enter(soap, soap->id, *p, t, sizeof(wchar_t*), 0, NULL, NULL, NULL))
+ return NULL;
+ if (!**p && tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ }
+ else if (tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ else if (soap->null)
+ *p = NULL;
+ else
+ *p = soap_wstrdup(soap, (wchar_t*)SOAP_STR_EOS);
+ if (*soap->href)
+ p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t**), 0);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+time_t
+SOAP_FMAC2
+soap_timegm(struct tm *T)
+{
+#if defined(HAVE_TIMEGM)
+ return timegm(T);
+#else
+ time_t t, g, z;
+ struct tm tm;
+ t = mktime(T);
+ if (t == (time_t)-1)
+ return (time_t)-1;
+#ifdef HAVE_GMTIME_R
+ gmtime_r(&t, &tm);
+#else
+ tm = *gmtime(&t);
+#endif
+ tm.tm_isdst = 0;
+ g = mktime(&tm);
+ if (g == (time_t)-1)
+ return (time_t)-1;
+ z = g - t;
+ return t - z;
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_dateTime2s(struct soap *soap, time_t n)
+{ struct tm T, *pT = &T;
+#if defined(HAVE_GMTIME_R)
+ if (gmtime_r(&n, pT))
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT);
+#elif defined(HAVE_GMTIME)
+ if ((pT = gmtime(&n)))
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT);
+#elif defined(HAVE_GETTIMEOFDAY)
+ struct timezone tz;
+ memset((void*)&tz, 0, sizeof(tz));
+#if defined(HAVE_LOCALTIME_R)
+ if (localtime_r(&n, pT))
+ { struct timeval tv;
+ gettimeofday(&tv, &tz);
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT);
+ sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60);
+ }
+#else
+ if ((pT = localtime(&n)))
+ { struct timeval tv;
+ gettimeofday(&tv, &tz);
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT);
+ sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60);
+ }
+#endif
+#elif defined(HAVE_FTIME)
+ struct timeb t;
+ memset((void*)&t, 0, sizeof(t));
+#if defined(HAVE_LOCALTIME_R)
+ if (localtime_r(&n, pT))
+ {
+#ifdef __BORLANDC__
+ ::ftime(&t);
+#else
+ ftime(&t);
+#endif
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT);
+ sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60);
+ }
+#else
+ if ((pT = localtime(&n)))
+ {
+#ifdef __BORLANDC__
+ ::ftime(&t);
+#else
+ ftime(&t);
+#endif
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT);
+ sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60);
+ }
+#endif
+#elif defined(HAVE_LOCALTIME_R)
+ if (localtime_r(&n, pT))
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT);
+#else
+ if ((pT = localtime(&n)))
+ strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT);
+#endif
+ else
+ strcpy(soap->tmpbuf, "1969-12-31T23:59:59Z");
+ return soap->tmpbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outdateTime(struct soap *soap, const char *tag, int id, const time_t *p, const char *type, int n)
+{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
+ || soap_string_out(soap, soap_dateTime2s(soap, *p), 0))
+ return soap->error;
+ return soap_element_end_out(soap, tag);
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_s2dateTime(struct soap *soap, const char *s, time_t *p)
+{ if (s)
+ { char zone[32];
+ struct tm T;
+ const char *t;
+ *zone = '\0';
+ memset((void*)&T, 0, sizeof(T));
+ if (strchr(s, '-'))
+ t = "%d-%d-%dT%d:%d:%d%31s";
+ else if (strchr(s, ':'))
+ t = "%4d%2d%2dT%d:%d:%d%31s";
+ else /* parse non-XSD-standard alternative ISO 8601 format */
+ t = "%4d%2d%2dT%2d%2d%2d%31s";
+ if (sscanf(s, t, &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, zone) < 6)
+ return soap->error = SOAP_TYPE;
+ if (T.tm_year == 1)
+ T.tm_year = 70;
+ else
+ T.tm_year -= 1900;
+ T.tm_mon--;
+ if (*zone == '.')
+ { for (s = zone + 1; *s; s++)
+ if (*s < '0' || *s > '9')
+ break;
+ }
+ else
+ s = zone;
+ if (*s)
+ {
+#ifndef WITH_NOZONE
+ if (*s == '+' || *s == '-')
+ { int h = 0, m = 0;
+ if (s[3] == ':')
+ { /* +hh:mm */
+ sscanf(s, "%d:%d", &h, &m);
+ if (h < 0)
+ m = -m;
+ }
+ else /* +hhmm */
+ { m = (int)soap_strtol(s, NULL, 10);
+ h = m / 100;
+ m = m % 100;
+ }
+ T.tm_min -= m;
+ T.tm_hour -= h;
+ /* put hour and min in range */
+ T.tm_hour += T.tm_min / 60;
+ T.tm_min %= 60;
+ if (T.tm_min < 0)
+ { T.tm_min += 60;
+ T.tm_hour--;
+ }
+ T.tm_mday += T.tm_hour / 24;
+ T.tm_hour %= 24;
+ if (T.tm_hour < 0)
+ { T.tm_hour += 24;
+ T.tm_mday--;
+ }
+ /* note: day of the month may be out of range, timegm() handles it */
+ }
+#endif
+ *p = soap_timegm(&T);
+ }
+ else /* no UTC or timezone, so assume we got a localtime */
+ { T.tm_isdst = -1;
+ *p = mktime(&T);
+ }
+ }
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+time_t *
+SOAP_FMAC2
+soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char *type, int t)
+{ if (soap_element_begin_in(soap, tag, 0, NULL))
+ return NULL;
+ if (*soap->type
+ && soap_match_tag(soap, soap->type, type)
+ && soap_match_tag(soap, soap->type, ":dateTime"))
+ { soap->error = SOAP_TYPE;
+ soap_revert(soap);
+ return NULL;
+ }
+ p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), 0, NULL, NULL, NULL);
+ if (*soap->href)
+ p = (time_t*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(time_t), 0, NULL);
+ else if (p)
+ { if (soap_s2dateTime(soap, soap_value(soap), p))
+ return NULL;
+ }
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outliteral(struct soap *soap, const char *tag, char *const*p, const char *type)
+{ int i;
+ const char *t = NULL;
+ if (tag && *tag != '-')
+ { if (soap->local_namespaces && (t = strchr(tag, ':')))
+ { strncpy(soap->tmpbuf, tag, t-tag);
+ soap->tmpbuf[t-tag] = '\0';
+ for (i = 0; soap->local_namespaces[i].id; i++)
+ if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id))
+ break;
+ t++;
+ if (soap_element(soap, t, 0, type)
+ || soap_attribute(soap, "xmlns", soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS)
+ || soap_element_start_end_out(soap, NULL))
+ return soap->error;
+ }
+ else
+ { t = tag;
+ if (soap_element_begin_out(soap, t, 0, type))
+ return soap->error;
+ }
+ }
+ if (p && *p)
+ { if (soap_send(soap, *p))
+ return soap->error;
+ }
+ if (t)
+ return soap_element_end_out(soap, t);
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+char **
+SOAP_FMAC2
+soap_inliteral(struct soap *soap, const char *tag, char **p)
+{ if (soap_element_begin_in(soap, tag, 1, NULL))
+ { if (soap->error != SOAP_NO_TAG || soap_unget(soap, soap_get(soap)) == SOAP_TT)
+ return NULL;
+ soap->error = SOAP_OK;
+ }
+ if (!p)
+ { if (!(p = (char**)soap_malloc(soap, sizeof(char*))))
+ return NULL;
+ }
+ if (soap->body || (tag && *tag == '-'))
+ { *p = soap_string_in(soap, 0, -1, -1);
+ if (!*p)
+ return NULL;
+ if (!**p && tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ }
+ else if (soap->null)
+ *p = NULL;
+ else
+ *p = soap_strdup(soap, SOAP_STR_EOS);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p, const char *type)
+{ int i;
+ const char *t = NULL;
+ if (tag && *tag != '-')
+ { if (soap->local_namespaces && (t = strchr(tag, ':')))
+ { strncpy(soap->tmpbuf, tag, t-tag);
+ soap->tmpbuf[t-tag] = '\0';
+ for (i = 0; soap->local_namespaces[i].id; i++)
+ if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id))
+ break;
+ t++;
+ if (soap_element(soap, t, 0, type)
+ || soap_attribute(soap, "xmlns", soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS)
+ || soap_element_start_end_out(soap, NULL))
+ return soap->error;
+ }
+ else
+ { t = tag;
+ if (soap_element_begin_out(soap, t, 0, type))
+ return soap->error;
+ }
+ if (soap_send(soap, soap->tmpbuf))
+ return soap->error;
+ }
+ if (p)
+ { wchar_t c;
+ const wchar_t *s = *p;
+ while ((c = *s++))
+ { if (soap_pututf8(soap, (unsigned long)c))
+ return soap->error;
+ }
+ }
+ if (t)
+ return soap_element_end_out(soap, t);
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_2
+SOAP_FMAC1
+wchar_t **
+SOAP_FMAC2
+soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p)
+{ if (soap_element_begin_in(soap, tag, 1, NULL))
+ { if (soap->error != SOAP_NO_TAG || soap_unget(soap, soap_get(soap)) == SOAP_TT)
+ return NULL;
+ soap->error = SOAP_OK;
+ }
+ if (!p)
+ { if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*))))
+ return NULL;
+ }
+ if (soap->body)
+ { *p = soap_wstring_in(soap, 0, -1, -1);
+ if (!*p)
+ return NULL;
+ if (!**p && tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ }
+ else if (tag && *tag == '-')
+ { soap->error = SOAP_NO_TAG;
+ return NULL;
+ }
+ else if (soap->null)
+ *p = NULL;
+ else
+ *p = soap_wstrdup(soap, (wchar_t*)SOAP_STR_EOS);
+ if (soap->body && soap_element_end_in(soap, tag))
+ return NULL;
+ return p;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+const char *
+SOAP_FMAC2
+soap_value(struct soap *soap)
+{ register size_t i;
+ register soap_wchar c = 0;
+ register char *s = soap->tmpbuf;
+ if (!soap->body)
+ return SOAP_STR_EOS;
+ do c = soap_get(soap);
+ while (soap_blank(c));
+ for (i = 0; i < sizeof(soap->tmpbuf) - 1; i++)
+ { if (c == SOAP_TT || c == SOAP_LT || (int)c == EOF)
+ break;
+ *s++ = (char)c;
+ c = soap_get(soap);
+ }
+ for (s--; i > 0; i--, s--)
+ { if (!soap_blank(*s))
+ break;
+ }
+ s[1] = '\0';
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element content value='%s'\n", soap->tmpbuf));
+ if (c == SOAP_TT || c == SOAP_LT || (int)c == EOF)
+ soap_unget(soap, c);
+ else if (soap->mode & SOAP_XML_STRICT)
+ { soap->error = SOAP_LENGTH;
+ return NULL;
+ }
+#ifdef WITH_DOM
+ if ((soap->mode & SOAP_XML_DOM) && soap->dom)
+ soap->dom->data = soap_strdup(soap, soap->tmpbuf);
+#endif
+ return soap->tmpbuf; /* return non-null pointer */
+}
+#endif
+
+/******************************************************************************/
+#if !defined(WITH_LEANER) || !defined(WITH_NOHTTP)
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getline(struct soap *soap, char *s, int len)
+{ int i = len;
+ soap_wchar c = 0;
+ for (;;)
+ { while (--i > 0)
+ { c = soap_getchar(soap);
+ if (c == '\r' || c == '\n')
+ break;
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ *s++ = (char)c;
+ }
+ if (c != '\n')
+ c = soap_getchar(soap); /* got \r or something else, now get \n */
+ if (c == '\n')
+ { *s = '\0';
+ if (i+1 == len) /* empty line: end of HTTP/MIME header */
+ break;
+ c = soap_get0(soap);
+ if (c != ' ' && c != '\t') /* HTTP line continuation? */
+ break;
+ }
+ else if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ if (i < 0)
+ return soap->error = SOAP_HDR;
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static size_t
+soap_count_attachments(struct soap *soap)
+{
+#ifndef WITH_LEANER
+ register struct soap_multipart *content;
+ register size_t count = soap->count;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the message size with attachments, current count=%lu\n", (unsigned long)count));
+ if ((soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of DIME attachments\n"));
+ for (content = soap->dime.first; content; content = content->next)
+ { count += 12 + ((content->size+3)&(~3));
+ if (content->id)
+ count += ((strlen(content->id)+3)&(~3));
+ if (content->type)
+ count += ((strlen(content->type)+3)&(~3));
+ if (content->options)
+ count += ((((unsigned char)content->options[2] << 8) | ((unsigned char)content->options[3]))+7)&(~3);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of DIME attachment content is %lu bytes\n", (unsigned long)content->size));
+ }
+ }
+ if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary)
+ { register size_t n = strlen(soap->mime.boundary);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of MIME attachments\n"));
+ for (content = soap->mime.first; content; content = content->next)
+ { register const char *s;
+ /* count \r\n--boundary\r\n */
+ count += 6 + n;
+ /* count Content-Type: ...\r\n */
+ if (content->type)
+ count += 16 + strlen(content->type);
+ /* count Content-Transfer-Encoding: ...\r\n */
+ s = soap_code_str(mime_codes, content->encoding);
+ if (s)
+ count += 29 + strlen(s);
+ /* count Content-ID: ...\r\n */
+ if (content->id)
+ count += 14 + strlen(content->id);
+ /* count Content-Location: ...\r\n */
+ if (content->location)
+ count += 20 + strlen(content->location);
+ /* count Content-Description: ...\r\n */
+ if (content->description)
+ count += 23 + strlen(content->description);
+ /* count \r\n...content */
+ count += 2 + content->size;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of MIME attachment content is %lu bytes\n", (unsigned long)content->size));
+ }
+ /* count \r\n--boundary-- */
+ count += 6 + n;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New count is %lu bytes\n", (unsigned long)count));
+ return count;
+#else
+ return soap->count;
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static int
+soap_putdimefield(struct soap *soap, const char *s, size_t n)
+{ if (soap_send_raw(soap, s, n))
+ return soap->error;
+ return soap_send_raw(soap, SOAP_STR_PADDING, -(long)n&3);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+char *
+SOAP_FMAC2
+soap_dime_option(struct soap *soap, unsigned short optype, const char *option)
+{ size_t n;
+ char *s = NULL;
+ if (option)
+ { n = strlen(option);
+ s = (char*)soap_malloc(soap, n + 5);
+ if (s)
+ { s[0] = (char)(optype >> 8);
+ s[1] = (char)(optype & 0xFF);
+ s[2] = (char)(n >> 8);
+ s[3] = (char)(n & 0xFF);
+ strcpy(s + 4, option);
+ }
+ }
+ return s;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putdimehdr(struct soap *soap)
+{ unsigned char tmp[12];
+ size_t optlen = 0, idlen = 0, typelen = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Put DIME header id='%s'\n", soap->dime.id?soap->dime.id:SOAP_STR_EOS));
+ if (soap->dime.options)
+ optlen = (((unsigned char)soap->dime.options[2] << 8) | ((unsigned char)soap->dime.options[3])) + 4;
+ if (soap->dime.id)
+ { idlen = strlen(soap->dime.id);
+ if (idlen > 0x0000FFFF)
+ idlen = 0x0000FFFF;
+ }
+ if (soap->dime.type)
+ { typelen = strlen(soap->dime.type);
+ if (typelen > 0x0000FFFF)
+ typelen = 0x0000FFFF;
+ }
+ tmp[0] = SOAP_DIME_VERSION | (soap->dime.flags & 0x7);
+ tmp[1] = soap->dime.flags & 0xF0;
+ tmp[2] = (char)(optlen >> 8);
+ tmp[3] = (char)(optlen & 0xFF);
+ tmp[4] = (char)(idlen >> 8);
+ tmp[5] = (char)(idlen & 0xFF);
+ tmp[6] = (char)(typelen >> 8);
+ tmp[7] = (char)(typelen & 0xFF);
+ tmp[8] = (char)(soap->dime.size >> 24);
+ tmp[9] = (char)((soap->dime.size >> 16) & 0xFF);
+ tmp[10] = (char)((soap->dime.size >> 8) & 0xFF);
+ tmp[11] = (char)(soap->dime.size & 0xFF);
+ if (soap_send_raw(soap, (char*)tmp, 12)
+ || soap_putdimefield(soap, soap->dime.options, optlen)
+ || soap_putdimefield(soap, soap->dime.id, idlen)
+ || soap_putdimefield(soap, soap->dime.type, typelen))
+ return soap->error;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putdime(struct soap *soap)
+{ struct soap_multipart *content;
+ if (!(soap->mode & SOAP_ENC_DIME))
+ return SOAP_OK;
+ for (content = soap->dime.first; content; content = content->next)
+ { void *handle;
+ soap->dime.size = content->size;
+ soap->dime.id = content->id;
+ soap->dime.type = content->type;
+ soap->dime.options = content->options;
+ soap->dime.flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA;
+ if (soap->fdimereadopen && ((handle = soap->fdimereadopen(soap, (void*)content->ptr, content->id, content->type, content->options)) || soap->error))
+ { size_t size = content->size;
+ if (!handle)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n"));
+ return soap->error;
+ }
+ if (!size && ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE))
+ { size_t chunksize = sizeof(soap->tmpbuf);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming DIME\n"));
+ do
+ { size = soap->fdimeread(soap, handle, soap->tmpbuf, chunksize);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread returned %lu bytes\n", (unsigned long)size));
+ if (size < chunksize)
+ { soap->dime.flags &= ~SOAP_DIME_CF;
+ if (!content->next)
+ soap->dime.flags |= SOAP_DIME_ME;
+ }
+ else
+ soap->dime.flags |= SOAP_DIME_CF;
+ soap->dime.size = size;
+ if (soap_putdimehdr(soap)
+ || soap_putdimefield(soap, soap->tmpbuf, size))
+ break;
+ if (soap->dime.id)
+ { soap->dime.flags &= ~(SOAP_DIME_MB | SOAP_DIME_MEDIA);
+ soap->dime.id = NULL;
+ soap->dime.type = NULL;
+ soap->dime.options = NULL;
+ }
+ } while (size >= chunksize);
+ }
+ else
+ { if (!content->next)
+ soap->dime.flags |= SOAP_DIME_ME;
+ if (soap_putdimehdr(soap))
+ return soap->error;
+ do
+ { size_t bufsize;
+ if (size < sizeof(soap->tmpbuf))
+ bufsize = size;
+ else
+ bufsize = sizeof(soap->tmpbuf);
+ if (!(bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize)))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)content->size));
+ soap->error = SOAP_EOF;
+ break;
+ }
+ if (soap_send_raw(soap, soap->tmpbuf, bufsize))
+ break;
+ size -= bufsize;
+ } while (size);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n"));
+ soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3);
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n"));
+ if (soap->fdimereadclose)
+ soap->fdimereadclose(soap, handle);
+ }
+ else
+ { if (!content->next)
+ soap->dime.flags |= SOAP_DIME_ME;
+ if (soap_putdimehdr(soap)
+ || soap_putdimefield(soap, (char*)content->ptr, content->size))
+ return soap->error;
+ }
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static char *
+soap_getdimefield(struct soap *soap, size_t n)
+{ register soap_wchar c;
+ register size_t i;
+ register char *s;
+ register char *p = NULL;
+ if (n)
+ { p = (char*)soap_malloc(soap, n + 1);
+ if (p)
+ { s = p;
+ for (i = n; i > 0; i--)
+ { if ((int)(c = soap_get1(soap)) == EOF)
+ { soap->error = SOAP_EOF;
+ return NULL;
+ }
+ *s++ = (char)c;
+ }
+ *s = '\0';
+ if ((soap->error = soap_move(soap, -(long)n&3)))
+ return NULL;
+ }
+ else
+ soap->error = SOAP_EOM;
+ }
+ return p;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getdimehdr(struct soap *soap)
+{ register soap_wchar c;
+ register char *s;
+ register int i;
+ unsigned char tmp[12];
+ size_t optlen, idlen, typelen;
+ if (!(soap->mode & SOAP_ENC_DIME))
+ return soap->error = SOAP_DIME_END;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get DIME header\n"));
+ if (soap->dime.buflen || soap->dime.chunksize)
+ { if (soap_move(soap, (long)(soap->dime.size - soap_tell(soap))))
+ return soap->error = SOAP_EOF;
+ soap_unget(soap, soap_getchar(soap)); /* skip padding and get hdr */
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... From chunked\n"));
+ return SOAP_OK;
+ }
+ s = (char*)tmp;
+ for (i = 12; i > 0; i--)
+ { if ((int)(c = soap_getchar(soap)) == EOF)
+ return soap->error = SOAP_EOF;
+ *s++ = (char)c;
+ }
+ if ((tmp[0] & 0xF8) != SOAP_DIME_VERSION)
+ return soap->error = SOAP_DIME_MISMATCH;
+ soap->dime.flags = (tmp[0] & 0x7) | (tmp[1] & 0xF0);
+ optlen = (tmp[2] << 8) | tmp[3];
+ idlen = (tmp[4] << 8) | tmp[5];
+ typelen = (tmp[6] << 8) | tmp[7];
+ soap->dime.size = (tmp[8] << 24) | (tmp[9] << 16) | (tmp[10] << 8) | tmp[11];
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%lu flags=0x%X\n", (unsigned long)soap->dime.size, soap->dime.flags));
+ if (!(soap->dime.options = soap_getdimefield(soap, optlen)) && soap->error)
+ return soap->error;
+ if (!(soap->dime.id = soap_getdimefield(soap, idlen)) && soap->error)
+ return soap->error;
+ if (!(soap->dime.type = soap_getdimefield(soap, typelen)) && soap->error)
+ return soap->error;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id=%s, type=%s, options=%s\n", soap->dime.id?soap->dime.id:SOAP_STR_EOS, soap->dime.type?soap->dime.type:"", soap->dime.options?soap->dime.options+4:SOAP_STR_EOS));
+ if (soap->dime.flags & SOAP_DIME_ME)
+ soap->mode &= ~SOAP_ENC_DIME;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getdime(struct soap *soap)
+{ while (soap->dime.flags & SOAP_DIME_CF)
+ { if (soap_getdimehdr(soap))
+ return soap->error;
+ if (soap_move(soap, (long)soap->dime.size))
+ return soap->error = SOAP_EOF;
+ }
+ if (soap_move(soap, (long)(((soap->dime.size+3)&(~3))-soap_tell(soap))))
+ return soap->error = SOAP_EOF;
+ for (;;)
+ { register struct soap_multipart *content;
+ if (soap_getdimehdr(soap))
+ break;
+ if (soap->fdimewriteopen && ((soap->dime.ptr = (char*)soap->fdimewriteopen(soap, soap->dime.id, soap->dime.type, soap->dime.options)) || soap->error))
+ { const char *id, *type, *options;
+ size_t size, n;
+ if (!soap->dime.ptr)
+ return soap->error;
+ id = soap->dime.id;
+ type = soap->dime.type;
+ options = soap->dime.options;
+ for (;;)
+ { size = soap->dime.size;
+ for (;;)
+ { n = soap->buflen - soap->bufidx;
+ if (size < n)
+ n = size;
+ if ((soap->error = soap->fdimewrite(soap, (void*)soap->dime.ptr, soap->buf + soap->bufidx, n)))
+ break;
+ size -= n;
+ if (!size)
+ { soap->bufidx += n;
+ break;
+ }
+ if (soap_recv(soap))
+ { soap->error = SOAP_EOF;
+ goto end;
+ }
+ }
+ if (soap_move(soap, -(long)soap->dime.size&3))
+ { soap->error = SOAP_EOF;
+ break;
+ }
+ if (!(soap->dime.flags & SOAP_DIME_CF))
+ break;
+ if (soap_getdimehdr(soap))
+ break;
+ }
+end:
+ if (soap->fdimewriteclose)
+ soap->fdimewriteclose(soap, (void*)soap->dime.ptr);
+ soap->dime.size = 0;
+ soap->dime.id = id;
+ soap->dime.type = type;
+ soap->dime.options = options;
+ }
+ else if (soap->dime.flags & SOAP_DIME_CF)
+ { const char *id, *type, *options;
+ id = soap->dime.id;
+ type = soap->dime.type;
+ options = soap->dime.options;
+ if (soap_new_block(soap) == NULL)
+ return SOAP_EOM;
+ for (;;)
+ { register soap_wchar c;
+ register size_t i;
+ register char *s;
+ s = (char*)soap_push_block(soap, NULL, soap->dime.size);
+ if (!s)
+ return soap->error = SOAP_EOM;
+ for (i = soap->dime.size; i > 0; i--)
+ { if ((int)(c = soap_get1(soap)) == EOF)
+ return soap->error = SOAP_EOF;
+ *s++ = (char)c;
+ }
+ if (soap_move(soap, -(long)soap->dime.size&3))
+ return soap->error = SOAP_EOF;
+ if (!(soap->dime.flags & SOAP_DIME_CF))
+ break;
+ if (soap_getdimehdr(soap))
+ return soap->error;
+ }
+ soap->dime.size = soap->blist->size++; /* allocate one more for '\0' */
+ if (!(soap->dime.ptr = soap_save_block(soap, NULL, NULL, 0)))
+ return soap->error;
+ soap->dime.ptr[soap->dime.size] = '\0'; /* force 0-terminated */
+ soap->dime.id = id;
+ soap->dime.type = type;
+ soap->dime.options = options;
+ }
+ else
+ soap->dime.ptr = soap_getdimefield(soap, soap->dime.size);
+ content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, soap->dime.ptr, soap->dime.size);
+ if (!content)
+ return soap->error = SOAP_EOM;
+ content->id = soap->dime.id;
+ content->type = soap->dime.type;
+ content->options = soap->dime.options;
+ if (soap->error)
+ return soap->error;
+ soap_resolve_attachment(soap, content);
+ }
+ if (soap->error != SOAP_DIME_END)
+ return soap->error;
+ return soap->error = SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getmimehdr(struct soap *soap)
+{ struct soap_multipart *content;
+ do
+ { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf)))
+ return soap->error;
+ }
+ while (!*soap->msgbuf);
+ if (soap->msgbuf[0] == '-' && soap->msgbuf[1] == '-')
+ { char *s = soap->msgbuf + strlen(soap->msgbuf) - 1;
+ /* remove white space */
+ while (soap_blank(*s))
+ s--;
+ s[1] = '\0';
+ if (soap->mime.boundary)
+ { if (strcmp(soap->msgbuf + 2, soap->mime.boundary))
+ return soap->error = SOAP_MIME_ERROR;
+ }
+ else
+ soap->mime.boundary = soap_strdup(soap, soap->msgbuf + 2);
+ if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf)))
+ return soap->error;
+ }
+ if (soap_set_mime_attachment(soap, NULL, 0, SOAP_MIME_NONE, NULL, NULL, NULL, NULL))
+ return soap->error = SOAP_EOM;
+ content = soap->mime.last;
+ for (;;)
+ { register char *key = soap->msgbuf;
+ register char *val;
+ if (!*key)
+ break;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "MIME header: %s\n", key));
+ val = strchr(soap->msgbuf, ':');
+ if (val)
+ { *val = '\0';
+ do val++;
+ while (*val && *val <= 32);
+ if (!soap_tag_cmp(key, "Content-ID"))
+ content->id = soap_strdup(soap, val);
+ else if (!soap_tag_cmp(key, "Content-Location"))
+ content->location = soap_strdup(soap, val);
+ else if (!soap_tag_cmp(key, "Content-Disposition"))
+ content->id = soap_strdup(soap, soap_get_header_attribute(soap, val, "name"));
+ else if (!soap_tag_cmp(key, "Content-Type"))
+ content->type = soap_strdup(soap, val);
+ else if (!soap_tag_cmp(key, "Content-Description"))
+ content->description = soap_strdup(soap, val);
+ else if (!soap_tag_cmp(key, "Content-Transfer-Encoding"))
+ content->encoding = (enum soap_mime_encoding)soap_code_int(mime_codes, val, (long)SOAP_MIME_NONE);
+ }
+ if (soap_getline(soap, key, sizeof(soap->msgbuf)))
+ return soap->error;
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_getmime(struct soap *soap)
+{ while (soap_get_mime_attachment(soap, NULL))
+ ;
+ return soap->error;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_post_check_mime_attachments(struct soap *soap)
+{ soap->imode |= SOAP_MIME_POSTCHECK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_check_mime_attachments(struct soap *soap)
+{ if (soap->mode & SOAP_MIME_POSTCHECK)
+ return soap_get_mime_attachment(soap, NULL) != NULL;
+ return 0;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap_multipart *
+SOAP_FMAC2
+soap_get_mime_attachment(struct soap *soap, void *handle)
+{ register soap_wchar c = 0;
+ register size_t i, m = 0;
+ register char *s, *t = NULL;
+ register struct soap_multipart *content;
+ register short flag = 0;
+ if (!(soap->mode & SOAP_ENC_MIME))
+ return NULL;
+ content = soap->mime.last;
+ if (!content)
+ { if (soap_getmimehdr(soap))
+ return NULL;
+ content = soap->mime.last;
+ }
+ else if (content != soap->mime.first)
+ { if (soap->fmimewriteopen && ((content->ptr = (char*)soap->fmimewriteopen(soap, (void*)handle, content->id, content->type, content->description, content->encoding)) || soap->error))
+ { if (!content->ptr)
+ return NULL;
+ }
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Parsing MIME content id=%s type=%s\n", content->id?content->id:SOAP_STR_EOS, content->type?content->type:SOAP_STR_EOS));
+ if (!content->ptr && soap_new_block(soap) == NULL)
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ for (;;)
+ { if (content->ptr)
+ s = soap->tmpbuf;
+ else if (!(s = (char*)soap_push_block(soap, NULL, sizeof(soap->tmpbuf))))
+ { soap->error = SOAP_EOM;
+ return NULL;
+ }
+ for (i = 0; i < sizeof(soap->tmpbuf); i++)
+ { if (m > 0)
+ { *s++ = *t++;
+ m--;
+ }
+ else
+ { if (!flag)
+ { c = soap_get1(soap);
+ if ((int)c == EOF)
+ { soap->error = SOAP_EOF;
+ return NULL;
+ }
+ }
+ if (flag || c == '\r')
+ { t = soap->msgbuf;
+ memset(t, 0, sizeof(soap->msgbuf));
+ strcpy(t, "\n--");
+ if (soap->mime.boundary)
+ strncat(t, soap->mime.boundary, sizeof(soap->msgbuf)-4);
+ do c = soap_getchar(soap);
+ while (c == *t++);
+ if ((int)c == EOF)
+ { soap->error = SOAP_EOF;
+ return NULL;
+ }
+ if (!*--t)
+ goto end;
+ *t = (char)c;
+ flag = (c == '\r');
+ m = t - soap->msgbuf + 1 - flag;
+ t = soap->msgbuf;
+ c = '\r';
+ }
+ *s++ = (char)c;
+ }
+ }
+ if (content->ptr && soap->fmimewrite)
+ { if ((soap->error = soap->fmimewrite(soap, (void*)content->ptr, soap->tmpbuf, i)))
+ break;
+ }
+ }
+end:
+ *s = '\0'; /* force 0-terminated */
+ if (content->ptr)
+ { if (!soap->error && soap->fmimewrite)
+ soap->error = soap->fmimewrite(soap, (void*)content->ptr, soap->tmpbuf, i);
+ if (soap->fmimewriteclose)
+ soap->fmimewriteclose(soap, (void*)content->ptr);
+ if (soap->error)
+ return NULL;
+ }
+ else
+ { content->size = soap_size_block(soap, NULL, i+1)-1;
+ content->ptr = soap_save_block(soap, NULL, NULL, 0);
+ }
+ soap_resolve_attachment(soap, content);
+ if (c == '-' && soap_getchar(soap) == '-')
+ { soap->mode &= ~SOAP_ENC_MIME;
+ if ((soap->mode & SOAP_MIME_POSTCHECK) && soap_end_recv(soap))
+ return NULL;
+ }
+ else
+ { while (c != '\r' && (int)c != EOF && soap_blank(c))
+ c = soap_getchar(soap);
+ if (c != '\r' || soap_getchar(soap) != '\n')
+ { soap->error = SOAP_MIME_ERROR;
+ return NULL;
+ }
+ if (soap_getmimehdr(soap))
+ return NULL;
+ }
+ return content;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_match_cid(struct soap *soap, const char *s, const char *t)
+{ register size_t n;
+ if (!s)
+ return 1;
+ if (!strcmp(s, t))
+ return 0;
+ if (!strncmp(s, "cid:", 4))
+ s += 4;
+ n = strlen(t);
+ if (*t == '<')
+ { t++;
+ n -= 2;
+ }
+ if (!strncmp(s, t, n) && !s[n])
+ return 0;
+ soap_decode(soap->tmpbuf, sizeof(soap->tmpbuf), s, SOAP_STR_EOS);
+ if (!strncmp(soap->tmpbuf, t, n) && !soap->tmpbuf[n])
+ return 0;
+ return 1;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static void
+soap_resolve_attachment(struct soap *soap, struct soap_multipart *content)
+{ if (content->id)
+ { register struct soap_xlist **xp = &soap->xlist;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving attachment data for id=%s\n", content->id));
+ while (*xp)
+ { register struct soap_xlist *xq = *xp;
+ if (!soap_match_cid(soap, xq->id, content->id))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Found matching attachment %s for content id=%s\n", xq->id, content->id));
+ *xp = xq->next;
+ *xq->ptr = (unsigned char*)content->ptr;
+ *xq->size = (int)content->size;
+ *xq->type = (char*)content->type;
+ if (content->options)
+ *xq->options = (char*)content->options;
+ else
+ *xq->options = (char*)content->description;
+ SOAP_FREE(soap, xq);
+ }
+ else
+ xp = &(*xp)->next;
+ }
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putmimehdr(struct soap *soap, struct soap_multipart *content)
+{ const char *s;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MIME attachment type=%s\n", content->type?content->type:SOAP_STR_EOS));
+ if (soap_send3(soap, "\r\n--", soap->mime.boundary, "\r\n"))
+ return soap->error;
+ if (content->type && soap_send3(soap, "Content-Type: ", content->type, "\r\n"))
+ return soap->error;
+ s = soap_code_str(mime_codes, content->encoding);
+ if (s && soap_send3(soap, "Content-Transfer-Encoding: ", s, "\r\n"))
+ return soap->error;
+ if (content->id && soap_send3(soap, "Content-ID: ", content->id, "\r\n"))
+ return soap->error;
+ if (content->location && soap_send3(soap, "Content-Location: ", content->location, "\r\n"))
+ return soap->error;
+ if (content->description && soap_send3(soap, "Content-Description: ", content->description, "\r\n"))
+ return soap->error;
+ return soap_send_raw(soap, "\r\n", 2);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_putmime(struct soap *soap)
+{ struct soap_multipart *content;
+ if (!(soap->mode & SOAP_ENC_MIME) || !soap->mime.boundary)
+ return SOAP_OK;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending MIME attachments\n"));
+ for (content = soap->mime.first; content; content = content->next)
+ { void *handle;
+ if (soap->fmimereadopen && ((handle = soap->fmimereadopen(soap, (void*)content->ptr, content->id, content->type, content->description)) || soap->error))
+ { size_t size = content->size;
+ if (!handle)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimereadopen failed\n"));
+ return soap->error;
+ }
+ if (soap_putmimehdr(soap, content))
+ return soap->error;
+ if (!size)
+ { if ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming MIME\n"));
+ do
+ { size = soap->fmimeread(soap, handle, soap->tmpbuf, sizeof(soap->tmpbuf));
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimeread returned %lu bytes\n", (unsigned long)size));
+ if (soap_send_raw(soap, soap->tmpbuf, size))
+ break;
+ } while (size);
+ }
+ else
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error: cannot chunk streaming MIME (no HTTP chunking)\n"));
+ }
+ }
+ else
+ { do
+ { size_t bufsize;
+ if (size < sizeof(soap->tmpbuf))
+ bufsize = size;
+ else
+ bufsize = sizeof(soap->tmpbuf);
+ if (!(bufsize = soap->fmimeread(soap, handle, soap->tmpbuf, bufsize)))
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)content->size));
+ soap->error = SOAP_EOF;
+ break;
+ }
+ if (soap_send_raw(soap, soap->tmpbuf, bufsize))
+ break;
+ size -= bufsize;
+ } while (size);
+ }
+ if (soap->fmimereadclose)
+ soap->fmimereadclose(soap, handle);
+ }
+ else
+ { if (soap_putmimehdr(soap, content)
+ || soap_send_raw(soap, content->ptr, content->size))
+ return soap->error;
+ }
+ }
+ return soap_send3(soap, "\r\n--", soap->mime.boundary, "--");
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_dime(struct soap *soap)
+{ soap->omode |= SOAP_ENC_DIME;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_mime(struct soap *soap, const char *boundary, const char *start)
+{ soap->omode |= SOAP_ENC_MIME;
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->mime.boundary = soap_strdup(soap, boundary);
+ soap->mime.start = soap_strdup(soap, start);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_clr_dime(struct soap *soap)
+{ soap->omode &= ~SOAP_ENC_DIME;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_clr_mime(struct soap *soap)
+{ soap->omode &= ~SOAP_ENC_MIME;
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->mime.boundary = NULL;
+ soap->mime.start = NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static struct soap_multipart*
+soap_new_multipart(struct soap *soap, struct soap_multipart **first, struct soap_multipart **last, char *ptr, size_t size)
+{ struct soap_multipart *content;
+ content = (struct soap_multipart*)soap_malloc(soap, sizeof(struct soap_multipart));
+ if (content)
+ { content->next = NULL;
+ content->ptr = ptr;
+ content->size = size;
+ content->id = NULL;
+ content->type = NULL;
+ content->options = NULL;
+ content->encoding = SOAP_MIME_NONE;
+ content->location = NULL;
+ content->description = NULL;
+ if (!*first)
+ *first = content;
+ if (*last)
+ (*last)->next = content;
+ *last = content;
+ }
+ return content;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_dime_attachment(struct soap *soap, char *ptr, size_t size, const char *type, const char *id, unsigned short optype, const char *option)
+{ struct soap_multipart *content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, ptr, size);
+ if (!content)
+ return SOAP_EOM;
+ content->id = soap_strdup(soap, id);
+ content->type = soap_strdup(soap, type);
+ content->options = soap_dime_option(soap, optype, option);
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_mime_attachment(struct soap *soap, char *ptr, size_t size, enum soap_mime_encoding encoding, const char *type, const char *id, const char *location, const char *description)
+{ struct soap_multipart *content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, ptr, size);
+ if (!content)
+ return SOAP_EOM;
+ content->id = soap_strdup(soap, id);
+ content->type = soap_strdup(soap, type);
+ content->encoding = encoding;
+ content->location = soap_strdup(soap, location);
+ content->description = soap_strdup(soap, description);
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+SOAP_FMAC1
+struct soap_multipart*
+SOAP_FMAC2
+soap_next_multipart(struct soap_multipart *content)
+{ if (content)
+ return content->next;
+ return NULL;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static void
+soap_select_mime_boundary(struct soap *soap)
+{ while (!soap->mime.boundary || soap_valid_mime_boundary(soap))
+ { register char *s = soap->mime.boundary;
+ register size_t n = 0;
+ if (s)
+ n = strlen(s);
+ if (n < 16)
+ { n = 64;
+ s = soap->mime.boundary = (char*)soap_malloc(soap, n + 1);
+ if (!s)
+ return;
+ }
+ strcpy(s, "==");
+ s += 2;
+ n -= 4;
+ while (n)
+ { *s++ = soap_base64o[soap_random & 0x3F];
+ n--;
+ }
+ strcpy(s, "==");
+ }
+ if (!soap->mime.start)
+ soap->mime.start = "<SOAP-ENV:Envelope>";
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEANER
+#ifndef PALM_1
+static int
+soap_valid_mime_boundary(struct soap *soap)
+{ register struct soap_multipart *content;
+ register size_t k;
+ if (soap->fmimeread)
+ return SOAP_OK;
+ k = strlen(soap->mime.boundary);
+ for (content = soap->mime.first; content; content = content->next)
+ { if (content->ptr && content->size >= k)
+ { register const char *p = (const char*)content->ptr;
+ register size_t i;
+ for (i = 0; i < content->size - k; i++, p++)
+ { if (!strncmp(p, soap->mime.boundary, k))
+ return SOAP_ERR;
+ }
+ }
+ }
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef WITH_GZIP
+#ifndef PALM_1
+static int
+soap_getgziphdr(struct soap *soap)
+{ int i;
+ soap_wchar c = 0, f = 0;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n"));
+ for (i = 0; i < 9; i++)
+ { if ((int)(c = soap_get1(soap) == EOF))
+ return soap->error = SOAP_EOF;
+ if (i == 1 && c == 8)
+ soap->z_dict = 0;
+ if (i == 2)
+ f = c;
+ }
+ if (f & 0x04) /* FEXTRA */
+ { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--)
+ { if ((int)soap_get1(soap) == EOF)
+ return soap->error = SOAP_EOF;
+ }
+ }
+ if (f & 0x08) /* skip FNAME */
+ { do
+ c = soap_get1(soap);
+ while (c && (int)c != EOF);
+ }
+ if ((int)c != EOF && (f & 0x10)) /* skip FCOMMENT */
+ { do
+ c = soap_get1(soap);
+ while (c && (int)c != EOF);
+ }
+ if ((int)c != EOF && (f & 0x02)) /* skip FHCRC (CRC32 is used) */
+ { if ((int)(c = soap_get1(soap)) != EOF)
+ c = soap_get1(soap);
+ }
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ return SOAP_OK;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_begin_recv(struct soap *soap)
+{ soap_wchar c;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for input\n"));
+ soap->error = SOAP_OK;
+ soap_free_temp(soap);
+ soap_set_local_namespaces(soap);
+ soap->version = 0; /* don't assume we're parsing SOAP content by default */
+#ifndef WITH_NOIDREF
+ soap_free_iht(soap);
+#endif
+ if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
+ soap->omode |= SOAP_IO_CHUNK;
+ soap->imode &= ~(SOAP_IO | SOAP_ENC_MIME);
+ soap->mode = soap->imode;
+ if (!soap->keep_alive)
+ { soap->buflen = 0;
+ soap->bufidx = 0;
+ }
+ if (!(soap->mode & SOAP_IO_KEEPALIVE))
+ soap->keep_alive = 0;
+ soap->ahead = 0;
+ soap->peeked = 0;
+ soap->level = 0;
+ soap->part = SOAP_BEGIN;
+ soap->alloced = 0;
+ soap->count = 0;
+ soap->length = 0;
+ soap->cdata = 0;
+ *soap->endpoint = '\0';
+ soap->action = NULL;
+ soap->header = NULL;
+ soap->fault = NULL;
+ soap->status = 0;
+#ifndef WITH_LEANER
+ soap->dom = NULL;
+ soap->dime.chunksize = 0;
+ soap->dime.buflen = 0;
+ soap->dime.list = NULL;
+ soap->dime.first = NULL;
+ soap->dime.last = NULL;
+ soap->mime.list = NULL;
+ soap->mime.first = NULL;
+ soap->mime.last = NULL;
+ soap->mime.boundary = NULL;
+ soap->mime.start = NULL;
+#endif
+#ifdef WIN32
+#ifndef UNDER_CE
+#ifndef WITH_FASTCGI
+ if (!soap_valid_socket(soap->socket))
+#ifdef __BORLANDC__
+ setmode(soap->recvfd, _O_BINARY);
+#else
+ _setmode(soap->recvfd, _O_BINARY);
+#endif
+#endif
+#endif
+#endif
+#ifdef WITH_ZLIB
+ soap->mode &= ~SOAP_ENC_ZLIB;
+ soap->zlib_in = SOAP_ZLIB_NONE;
+ soap->zlib_out = SOAP_ZLIB_NONE;
+ soap->d_stream->next_in = Z_NULL;
+ soap->d_stream->avail_in = 0;
+ soap->d_stream->next_out = (Byte*)soap->buf;
+ soap->d_stream->avail_out = SOAP_BUFLEN;
+ soap->z_ratio_in = 1.0;
+#endif
+#ifdef WITH_OPENSSL
+ if (soap->ssl)
+ ERR_clear_error();
+#endif
+#ifndef WITH_LEANER
+ if (soap->fprepareinitrecv && (soap->error = soap->fprepareinitrecv(soap)))
+ return soap->error;
+#endif
+ c = soap_getchar(soap);
+#ifdef WITH_GZIP
+ if (c == 0x1F)
+ { if (soap_getgziphdr(soap))
+ return soap->error;
+ if (inflateInit2(soap->d_stream, -MAX_WBITS) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ if (soap->z_dict)
+ { if (inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ soap->zlib_state = SOAP_ZLIB_INFLATE;
+ soap->mode |= SOAP_ENC_ZLIB;
+ soap->zlib_in = SOAP_ZLIB_GZIP;
+ soap->z_crc = crc32(0L, NULL, 0);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n"));
+ if (!soap->z_buf)
+ soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
+ memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
+ /* should not chunk over plain transport, so why bother to check? */
+ /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */
+ /* soap->z_buflen = soap->bufidx; */
+ /* else */
+ soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
+ soap->d_stream->avail_in = soap->buflen - soap->bufidx;
+ soap->z_buflen = soap->buflen;
+ soap->buflen = soap->bufidx;
+ c = ' ';
+ }
+#endif
+ while (soap_blank(c))
+ c = soap_getchar(soap);
+#ifndef WITH_LEANER
+ if (c == '-' && soap_get0(soap) == '-')
+ soap->mode |= SOAP_ENC_MIME;
+ else if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20)
+ soap->mode |= SOAP_ENC_DIME;
+ else
+#endif
+ { /* skip BOM */
+ if (c == 0xEF && (c = soap_getchar(soap)) == 0xBB && (c = soap_getchar(soap)) == 0xBF)
+ c = soap_getchar(soap);
+ /* skip space */
+ while (soap_blank(c))
+ c = soap_getchar(soap);
+ }
+ if ((int)c == EOF)
+ return soap->error = SOAP_EOF;
+ soap_unget(soap, c);
+#ifndef WITH_NOHTTP
+ /* if not XML or MIME/DIME/ZLIB, assume HTTP header */
+ if (c != '<' && !(soap->mode & (SOAP_ENC_MIME | SOAP_ENC_DIME | SOAP_ENC_ZLIB)))
+ { soap_mode m = soap->imode;
+ soap->mode &= ~SOAP_IO;
+ soap->error = soap->fparse(soap);
+ if (soap->error && soap->error < SOAP_STOP)
+ { soap->keep_alive = 0; /* force close later */
+ return soap->error;
+ }
+ if (soap->error == SOAP_STOP)
+ return soap->error;
+ soap->mode = soap->imode; /* if imode is changed, effectuate */
+ soap->imode = m; /* restore imode */
+#ifdef WITH_ZLIB
+ soap->mode &= ~SOAP_ENC_ZLIB;
+#endif
+ if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
+ { soap->chunkbuflen = soap->buflen;
+ soap->buflen = soap->bufidx;
+ soap->chunksize = 0;
+ }
+ /* Note: fparse should not use soap_unget to push back last char */
+ if (soap_get0(soap) == (int)EOF)
+ { if (soap->status == 200)
+ return soap->error = SOAP_NO_DATA; /* HTTP OK: always expect data */
+ return soap->error = soap->status;
+ }
+#ifdef WITH_ZLIB
+ if (soap->zlib_in != SOAP_ZLIB_NONE)
+ {
+#ifdef WITH_GZIP
+ if (soap->zlib_in != SOAP_ZLIB_DEFLATE)
+ { c = soap_get1(soap);
+ if (c == 0x1F)
+ { if (soap_getgziphdr(soap))
+ return soap->error;
+ if (inflateInit2(soap->d_stream, -MAX_WBITS) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ soap->z_crc = crc32(0L, NULL, 0);
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n"));
+ }
+ else
+ { soap_revget1(soap);
+ if (inflateInit(soap->d_stream) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ soap->zlib_in = SOAP_ZLIB_DEFLATE;
+ }
+ }
+ else
+#endif
+ if (inflateInit(soap->d_stream) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ if (soap->z_dict)
+ { if (inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len) != Z_OK)
+ return soap->error = SOAP_ZLIB_ERROR;
+ }
+ soap->zlib_state = SOAP_ZLIB_INFLATE;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n"));
+ soap->mode |= SOAP_ENC_ZLIB;
+ if (!soap->z_buf)
+ soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
+ memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
+ soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
+ soap->d_stream->avail_in = soap->buflen - soap->bufidx;
+ soap->z_buflen = soap->buflen;
+ soap->buflen = soap->bufidx;
+ }
+#endif
+#ifndef WITH_LEANER
+ if (soap->fpreparerecv && (soap->mode & SOAP_IO) != SOAP_IO_CHUNK && soap->buflen > soap->bufidx)
+ { int r;
+ if ((r = soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx)))
+ return soap->error = r;
+ }
+#endif
+ if (soap->error)
+ { if (soap->error == SOAP_FORM && soap->fform)
+ { soap->error = soap->fform(soap);
+ if (soap->error == SOAP_OK)
+ soap->error = SOAP_STOP; /* prevents further processing */
+ }
+ return soap->error;
+ }
+ }
+#endif
+#ifndef WITH_LEANER
+ if (soap->mode & SOAP_ENC_MIME)
+ { if (soap_getmimehdr(soap))
+ return soap->error;
+ if (soap->mime.start)
+ { do
+ { if (!soap->mime.last->id)
+ break;
+ if (!soap_match_cid(soap, soap->mime.start, soap->mime.last->id))
+ break;
+ } while (soap_get_mime_attachment(soap, NULL));
+ }
+ if (soap_get_header_attribute(soap, soap->mime.first->type, "application/dime"))
+ soap->mode |= SOAP_ENC_DIME;
+ }
+ if (soap->mode & SOAP_ENC_DIME)
+ { if (soap_getdimehdr(soap))
+ return soap->error;
+ if (soap->dime.flags & SOAP_DIME_CF)
+ { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n"));
+ soap->dime.chunksize = soap->dime.size;
+ if (soap->buflen - soap->bufidx >= soap->dime.chunksize)
+ { soap->dime.buflen = soap->buflen;
+ soap->buflen = soap->bufidx + soap->dime.chunksize;
+ }
+ else
+ soap->dime.chunksize -= soap->buflen - soap->bufidx;
+ }
+ soap->count = soap->buflen - soap->bufidx;
+ }
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_envelope_begin_out(struct soap *soap)
+{
+#ifndef WITH_LEANER
+ size_t n = 0;
+ if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start && strlen(soap->mime.boundary) + strlen(soap->mime.start) < sizeof(soap->tmpbuf) - 80 )
+ { const char *s;
+ if ((soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM))
+ s = "application/dime";
+ else if (soap->version == 2)
+ { if (soap->mode & SOAP_ENC_MTOM)
+ s = "application/xop+xml; charset=utf-8; type=\"application/soap+xml\"";
+ else
+ s = "application/soap+xml; charset=utf-8";
+ }
+ else if (soap->mode & SOAP_ENC_MTOM)
+ s = "application/xop+xml; charset=utf-8; type=\"text/xml\"";
+ else
+ s = "text/xml; charset=utf-8";
+ sprintf(soap->tmpbuf, "--%s\r\nContent-Type: %s\r\nContent-Transfer-Encoding: binary\r\nContent-ID: %s\r\n\r\n", soap->mime.boundary, s, soap->mime.start);
+ n = strlen(soap->tmpbuf);
+ if (soap_send_raw(soap, soap->tmpbuf, n))
+ return soap->error;
+ }
+ if (soap->mode & SOAP_IO_LENGTH)
+ soap->dime.size = soap->count; /* DIME in MIME correction */
+ if (!(soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME))
+ { if (soap_putdimehdr(soap))
+ return soap->error;
+ }
+#endif
+ soap->part = SOAP_IN_ENVELOPE;
+ return soap_element_begin_out(soap, "SOAP-ENV:Envelope", 0, NULL);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_envelope_end_out(struct soap *soap)
+{ if (soap_element_end_out(soap, "SOAP-ENV:Envelope") || ((soap->mode & SOAP_XML_INDENT) && soap_send_raw(soap, "\r\n", 2)))
+ return soap->error;
+#ifndef WITH_LEANER
+ if ((soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM))
+ { soap->dime.size = soap->count - soap->dime.size; /* DIME in MIME correction */
+ sprintf(soap->id, soap->dime_id_format, 0);
+ soap->dime.id = soap->id;
+ if (soap->local_namespaces)
+ { if (soap->local_namespaces[0].out)
+ soap->dime.type = (char*)soap->local_namespaces[0].out;
+ else
+ soap->dime.type = (char*)soap->local_namespaces[0].ns;
+ }
+ soap->dime.options = NULL;
+ soap->dime.flags = SOAP_DIME_MB | SOAP_DIME_ABSURI;
+ if (!soap->dime.first)
+ soap->dime.flags |= SOAP_DIME_ME;
+ soap->count += 12 + ((strlen(soap->dime.id)+3)&(~3)) + (soap->dime.type ? ((strlen(soap->dime.type)+3)&(~3)) : 0);
+ }
+ if ((soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM))
+ return soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3);
+#endif
+ soap->part = SOAP_END_ENVELOPE;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static char*
+soap_get_http_body(struct soap *soap)
+{
+#ifndef WITH_LEAN
+ register size_t l = 0, n = 0;
+ register char *s;
+ /* get HTML body of HTTP error content */
+ if (!(soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) != SOAP_IO_CHUNK)
+ { n = soap->length;
+ if (!n)
+ return NULL;
+ }
+#ifdef WITH_FAST
+ soap->labidx = 0; /* use look-aside buffer */
+#else
+ if (soap_new_block(soap) == NULL)
+ return NULL;
+#endif
+ for (;;)
+ {
+#ifdef WITH_FAST
+ register size_t i, k;
+ if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */
+ return NULL;
+ s = soap->labbuf + soap->labidx; /* space to populate */
+ k = soap->lablen - soap->labidx; /* number of bytes available */
+ soap->labidx = soap->lablen; /* claim this space */
+#else
+ register size_t i, k = SOAP_BLKLEN;
+ if (!(s = (char*)soap_push_block(soap, NULL, k)))
+ return NULL;
+#endif
+ for (i = 0; i < k; i++)
+ { register soap_wchar c = soap_getchar(soap);
+ if ((int)c == EOF)
+ goto end;
+ *s++ = (char)(c & 0xFF);
+ l++;
+ if (n > 0 && l >= n)
+ goto end;
+ }
+ }
+end:
+ *s = '\0';
+#ifdef WITH_FAST
+ s = soap_strdup(soap, soap->labbuf);
+#else
+ soap_size_block(soap, NULL, i+1);
+ s = soap_save_block(soap, NULL, 0);
+#endif
+ return s;
+#else
+ return NULL;
+#endif
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_envelope_begin_in(struct soap *soap)
+{ register struct Namespace *p;
+ soap->part = SOAP_IN_ENVELOPE;
+ if (soap_element_begin_in(soap, "SOAP-ENV:Envelope", 0, NULL))
+ { if (soap->error == SOAP_TAG_MISMATCH
+ && !soap_element_begin_in(soap, "Envelope", 0, NULL))
+ soap->error = SOAP_VERSIONMISMATCH;
+ else if (soap->status)
+ soap->error = soap->status;
+ return soap->error;
+ }
+ p = soap->local_namespaces;
+ if (p)
+ { const char *ns = p[0].out;
+ if (!ns)
+ ns = p[0].ns;
+ if (!strcmp(ns, soap_env1))
+ { soap->version = 1; /* make sure we use SOAP 1.1 */
+ if (p[1].out)
+ SOAP_FREE(soap, p[1].out);
+ if ((p[1].out = (char*)SOAP_MALLOC(soap, sizeof(soap_enc1))))
+ strcpy(p[1].out, soap_enc1);
+ }
+ else if (!strcmp(ns, soap_env2))
+ { soap->version = 2; /* make sure we use SOAP 1.2 */
+ if (p[1].out)
+ SOAP_FREE(soap, p[1].out);
+ if ((p[1].out = (char*)SOAP_MALLOC(soap, sizeof(soap_enc2))))
+ strcpy(p[1].out, soap_enc2);
+ }
+ }
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_envelope_end_in(struct soap *soap)
+{ soap->part = SOAP_END_ENVELOPE;
+ return soap_element_end_in(soap, "SOAP-ENV:Envelope");
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_body_begin_out(struct soap *soap)
+{ soap->part = SOAP_IN_BODY;
+ if (soap->version == 1)
+ soap->encoding = 1;
+#ifndef WITH_LEAN
+ if ((soap->mode & SOAP_XML_SEC) && soap_set_attr(soap, "wsu:Id", "Body", 1))
+ return soap->error;
+#endif
+ if (soap_element(soap, "SOAP-ENV:Body", 0, NULL))
+ return soap->error;
+ return soap_element_start_end_out(soap, NULL);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_body_end_out(struct soap *soap)
+{ if (soap_element_end_out(soap, "SOAP-ENV:Body"))
+ return soap->error;
+ soap->part = SOAP_END_BODY;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_body_begin_in(struct soap *soap)
+{ soap->part = SOAP_IN_BODY;
+ if (soap_element_begin_in(soap, "SOAP-ENV:Body", 0, NULL))
+ return soap->error;
+ if (!soap->body)
+ soap->part = SOAP_NO_BODY;
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_body_end_in(struct soap *soap)
+{ if (soap->part == SOAP_NO_BODY)
+ return soap->error = SOAP_OK;
+ soap->part = SOAP_END_BODY;
+ return soap_element_end_in(soap, "SOAP-ENV:Body");
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_recv_header(struct soap *soap)
+{ if (soap_getheader(soap) && soap->error == SOAP_TAG_MISMATCH)
+ soap->error = SOAP_OK;
+ if (soap->error == SOAP_OK && soap->fheader)
+ soap->error = soap->fheader(soap);
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_endpoint(struct soap *soap, const char *endpoint)
+{ register const char *s;
+ register size_t i, n;
+ soap->endpoint[0] = '\0';
+ soap->host[0] = '\0';
+ soap->path[0] = '/';
+ soap->path[1] = '\0';
+ soap->port = 80;
+ if (!endpoint || !*endpoint)
+ return;
+#ifdef WITH_OPENSSL
+ if (!soap_tag_cmp(endpoint, "https:*"))
+ soap->port = 443;
+#endif
+ strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint) - 1);
+ soap->endpoint[sizeof(soap->endpoint) - 1] = '\0';
+ s = strchr(endpoint, ':');
+ if (s && s[1] == '/' && s[2] == '/')
+ s += 3;
+ else
+ s = endpoint;
+ n = strlen(s);
+ if (n >= sizeof(soap->host))
+ n = sizeof(soap->host) - 1;
+#ifdef WITH_IPV6
+ if (s[0] == '[')
+ { s++;
+ for (i = 0; i < n; i++)
+ { if (s[i] == ']')
+ { s++;
+ --n;
+ break;
+ }
+ soap->host[i] = s[i];
+ }
+ }
+ else
+ { for (i = 0; i < n; i++)
+ { soap->host[i] = s[i];
+ if (s[i] == '/' || s[i] == ':')
+ break;
+ }
+ }
+#else
+ for (i = 0; i < n; i++)
+ { soap->host[i] = s[i];
+ if (s[i] == '/' || s[i] == ':')
+ break;
+ }
+#endif
+ soap->host[i] = '\0';
+ if (s[i] == ':')
+ { soap->port = (int)soap_strtol(s + i + 1, NULL, 10);
+ for (i++; i < n; i++)
+ if (s[i] == '/')
+ break;
+ }
+ if (i < n && s[i])
+ { strncpy(soap->path, s + i, sizeof(soap->path));
+ soap->path[sizeof(soap->path) - 1] = '\0';
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_connect(struct soap *soap, const char *endpoint, const char *action)
+{ return soap_connect_command(soap, SOAP_POST, endpoint, action);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_connect_command(struct soap *soap, int http_command, const char *endpoints, const char *action)
+{ char *endpoint;
+ const char *s;
+ if (endpoints && (s = strchr(endpoints, ' ')))
+ { endpoint = (char*)SOAP_MALLOC(soap, strlen(endpoints) + 1);
+ for (;;)
+ { strncpy(endpoint, endpoints, s - endpoints);
+ endpoint[s - endpoints] = '\0';
+ if (soap_try_connect_command(soap, http_command, endpoint, action) != SOAP_TCP_ERROR)
+ break;
+ if (!*s)
+ break;
+ soap->error = SOAP_OK;
+ while (*s == ' ')
+ s++;
+ endpoints = s;
+ s = strchr(endpoints, ' ');
+ if (!s)
+ s = endpoints + strlen(endpoints);
+ }
+ SOAP_FREE(soap, endpoint);
+ }
+ else
+ soap_try_connect_command(soap, http_command, endpoints, action);
+ return soap->error;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static int
+soap_try_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action)
+{ char host[sizeof(soap->host)];
+ int port;
+ size_t count;
+ soap->error = SOAP_OK;
+ strcpy(host, soap->host); /* save previous host name: if != then reconnect */
+ port = soap->port; /* save previous port to compare */
+ soap->status = http_command;
+ soap_set_endpoint(soap, endpoint);
+#ifndef WITH_LEANER
+ if (soap->fconnect)
+ { if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port)))
+ return soap->error;
+ }
+ else
+#endif
+ if (soap->fopen && *soap->host)
+ { if (!soap->keep_alive || !soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port || !soap->fpoll || soap->fpoll(soap))
+ { soap->keep_alive = 0; /* to force close */
+ soap->omode &= ~SOAP_IO_UDP; /* to force close */
+ soap_closesock(soap);
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect/reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port));
+#ifndef WITH_LEAN
+ if (!strncmp(endpoint, "soap.udp:", 9))
+ soap->omode |= SOAP_IO_UDP;
+#endif
+ soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port);
+ if (soap->error)
+ return soap->error;
+ soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0);
+ }
+ }
+ count = soap_count_attachments(soap);
+ if (soap_begin_send(soap))
+ return soap->error;
+ if (http_command == SOAP_GET)
+ { soap->mode &= ~SOAP_IO;
+ soap->mode |= SOAP_IO_BUFFER;
+ }
+#ifndef WITH_NOHTTP
+ soap->action = soap_strdup(soap, action);
+ if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint)
+ { unsigned int k = soap->mode;
+ soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB);
+ if ((k & SOAP_IO) != SOAP_IO_FLUSH)
+ soap->mode |= SOAP_IO_BUFFER;
+ if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count)))
+ return soap->error;
+#ifndef WITH_LEANER
+ if ((k & SOAP_IO) == SOAP_IO_CHUNK)
+ { if (soap_flush(soap))
+ return soap->error;
+ }
+#endif
+ soap->mode = k;
+ }
+ if (http_command == SOAP_GET)
+ return soap_end_send(soap);
+#endif
+ return SOAP_OK;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_s2base64(struct soap *soap, const unsigned char *s, char *t, int n)
+{ register int i;
+ register unsigned long m;
+ register char *p;
+ if (!t)
+ t = (char*)soap_malloc(soap, (n + 2) / 3 * 4 + 1);
+ if (!t)
+ return NULL;
+ p = t;
+ t[0] = '\0';
+ if (!s)
+ return p;
+ for (; n > 2; n -= 3, s += 3)
+ { m = s[0];
+ m = (m << 8) | s[1];
+ m = (m << 8) | s[2];
+ for (i = 4; i > 0; m >>= 6)
+ t[--i] = soap_base64o[m & 0x3F];
+ t += 4;
+ }
+ t[0] = '\0';
+ if (n > 0)
+ { m = 0;
+ for (i = 0; i < n; i++)
+ m = (m << 8) | *s++;
+ for (; i < 3; i++)
+ m <<= 8;
+ for (i++; i > 0; m >>= 6)
+ t[--i] = soap_base64o[m & 0x3F];
+ for (i = 3; i > n; i--)
+ t[i] = '=';
+ t[4] = '\0';
+ }
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n)
+{ register int i, j, c;
+ register unsigned long m;
+ register const char *p;
+ if (!s || !*s)
+ { if (n)
+ *n = 0;
+ if (soap->error)
+ return NULL;
+ return SOAP_NON_NULL;
+ }
+ if (!t)
+ { l = (strlen(s) + 3) / 4 * 3;
+ t = (char*)soap_malloc(soap, l);
+ }
+ if (!t)
+ return NULL;
+ p = t;
+ if (n)
+ *n = 0;
+ for (;;)
+ { for (i = 0; i < SOAP_BLKLEN; i++)
+ { m = 0;
+ j = 0;
+ while (j < 4)
+ { c = *s++;
+ if (c == '=' || !c)
+ { i *= 3;
+ switch (j)
+ { case 2:
+ *t++ = (char)((m >> 4) & 0xFF);
+ i++;
+ break;
+ case 3:
+ *t++ = (char)((m >> 10) & 0xFF);
+ *t++ = (char)((m >> 2) & 0xFF);
+ i += 2;
+ }
+ if (n)
+ *n += i;
+ return p;
+ }
+ c -= '+';
+ if (c >= 0 && c <= 79)
+ { int b = soap_base64i[c];
+ if (b >= 64)
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ m = (m << 6) + b;
+ j++;
+ }
+ else if (!soap_blank(c + '+'))
+ { soap->error = SOAP_TYPE;
+ return NULL;
+ }
+ }
+ *t++ = (char)((m >> 16) & 0xFF);
+ *t++ = (char)((m >> 8) & 0xFF);
+ *t++ = (char)(m & 0xFF);
+ if (l < 3)
+ { if (n)
+ *n += i;
+ return p;
+ }
+ l -= 3;
+ }
+ if (n)
+ *n += 3 * SOAP_BLKLEN;
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_s2hex(struct soap *soap, const unsigned char *s, char *t, int n)
+{ register char *p;
+ if (!t)
+ t = (char*)soap_malloc(soap, 2 * n + 1);
+ if (!t)
+ return NULL;
+ p = t;
+ t[0] = '\0';
+ if (s)
+ { for (; n > 0; n--)
+ { register int m = *s++;
+ *t++ = (char)((m >> 4) + (m > 159 ? 'a' - 10 : '0'));
+ m &= 0x0F;
+ *t++ = (char)(m + (m > 9 ? 'a' - 10 : '0'));
+ }
+ }
+ *t++ = '\0';
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+SOAP_FMAC1
+const char*
+SOAP_FMAC2
+soap_hex2s(struct soap *soap, const char *s, char *t, size_t l, int *n)
+{ register const char *p;
+ if (!s || !*s)
+ { if (n)
+ *n = 0;
+ if (soap->error)
+ return NULL;
+ return SOAP_NON_NULL;
+ }
+ if (!t)
+ { l = strlen(s) / 2;
+ t = (char*)soap_malloc(soap, l);
+ }
+ if (!t)
+ return NULL;
+ p = t;
+ while (l)
+ { register int d1, d2;
+ d1 = *s++;
+ if (!d1)
+ break;
+ d2 = *s++;
+ if (!d2)
+ break;
+ *t++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0');
+ l--;
+ }
+ if (n)
+ *n = (int)(t - p);
+ return p;
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_puthttphdr(struct soap *soap, int status, size_t count)
+{ if (soap->status != SOAP_GET)
+ { register const char *s = "text/xml; charset=utf-8";
+ register int err = SOAP_OK;
+#ifndef WITH_LEANER
+ register const char *r = NULL;
+#endif
+ if ((status == SOAP_FILE || soap->status == SOAP_POST_FILE) && soap->http_content)
+ s = soap->http_content;
+ else if (status == SOAP_HTML)
+ s = "text/html; charset=utf-8";
+ else if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK))
+ { if (soap->version == 2)
+ s = "application/soap+xml; charset=utf-8";
+ }
+#ifndef WITH_LEANER
+ if (soap->mode & (SOAP_ENC_DIME | SOAP_ENC_MTOM))
+ { if (soap->mode & SOAP_ENC_MTOM)
+ { if (soap->version == 2)
+ r = "application/soap+xml";
+ else
+ r = "text/xml";
+ s = "application/xop+xml";
+ }
+ else
+ s = "application/dime";
+ }
+ if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && strlen(soap->mime.boundary) + strlen(soap->mime.start ? soap->mime.start : SOAP_STR_EOS) < sizeof(soap->tmpbuf) - 80)
+ { register const char *t = strchr(s, ';');
+ sprintf(soap->tmpbuf, "multipart/related; charset=utf-8; boundary=\"%s\"; type=\"", soap->mime.boundary);
+ if (t)
+ { strncat(soap->tmpbuf, s, t - s);
+ soap->tmpbuf[sizeof(soap->tmpbuf)-1] = '\0';
+ }
+ else
+ strcat(soap->tmpbuf, s);
+ if (soap->mime.start)
+ { strcat(soap->tmpbuf, "\"; start=\"");
+ strcat(soap->tmpbuf, soap->mime.start);
+ }
+ strcat(soap->tmpbuf, "\"");
+ if (r)
+ { strcat(soap->tmpbuf, "; start-info=\"");
+ strcat(soap->tmpbuf, r);
+ strcat(soap->tmpbuf, "\"");
+ }
+ s = soap->tmpbuf;
+ }
+#endif
+ if (s && (err = soap->fposthdr(soap, "Content-Type", s)))
+ return err;
+#ifdef WITH_ZLIB
+ if ((soap->omode & SOAP_ENC_ZLIB))
+ {
+#ifdef WITH_GZIP
+ err = soap->fposthdr(soap, "Content-Encoding", soap->zlib_out == SOAP_ZLIB_DEFLATE ? "deflate" : "gzip");
+#else
+ err = soap->fposthdr(soap, "Content-Encoding", "deflate");
+#endif
+ if (err)
+ return err;
+ }
+#endif
+#ifndef WITH_LEANER
+ if ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK)
+ err = soap->fposthdr(soap, "Transfer-Encoding", "chunked");
+ else
+#endif
+ if (s)
+ { sprintf(soap->tmpbuf, "%lu", (unsigned long)count);
+ err = soap->fposthdr(soap, "Content-Length", soap->tmpbuf);
+ }
+ if (err)
+ return err;
+ }
+ return soap->fposthdr(soap, "Connection", soap->keep_alive ? "keep-alive" : "close");
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+static const char*
+soap_set_validation_fault(struct soap *soap, const char *s, const char *t)
+{ if (*soap->tag)
+ sprintf(soap->msgbuf, "Validation constraint violation: %s%s in element '%s'", s, t?t:SOAP_STR_EOS, soap->tag);
+ else
+ sprintf(soap->msgbuf, "Validation constraint violation: %s%s", s, t?t:SOAP_STR_EOS);
+ return soap->msgbuf;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_set_fault(struct soap *soap)
+{ const char **c = soap_faultcode(soap);
+ const char **s = soap_faultstring(soap);
+ if (soap->fseterror)
+ soap->fseterror(soap, c, s);
+ if (!*c)
+ { if (soap->version == 2)
+ *c = "SOAP-ENV:Sender";
+ else
+ *c = "SOAP-ENV:Client";
+ }
+ if (*s)
+ return;
+ switch (soap->error)
+ {
+#ifndef WITH_LEAN
+ case SOAP_CLI_FAULT:
+ *s = "Client fault";
+ break;
+ case SOAP_SVR_FAULT:
+ *s = "Server fault";
+ break;
+ case SOAP_TAG_MISMATCH:
+ *s = soap_set_validation_fault(soap, "tag name or namespace mismatch", NULL);
+ break;
+ case SOAP_TYPE:
+ *s = soap_set_validation_fault(soap, "data type mismatch ", soap->type);
+ break;
+ case SOAP_SYNTAX_ERROR:
+ *s = "Well-formedness violation";
+ break;
+ case SOAP_NO_TAG:
+ *s = "No XML root element";
+ break;
+ case SOAP_MUSTUNDERSTAND:
+ *c = "SOAP-ENV:MustUnderstand";
+ sprintf(soap->msgbuf, "The data in element '%s' must be understood but cannot be handled", soap->tag);
+ *s = soap->msgbuf;
+ break;
+ case SOAP_VERSIONMISMATCH:
+ *c = "SOAP-ENV:VersionMismatch";
+ *s = "Invalid SOAP message or SOAP version mismatch";
+ break;
+ case SOAP_DATAENCODINGUNKNOWN:
+ *c = "SOAP-ENV:DataEncodingUnknown";
+ *s = "Unsupported SOAP data encoding";
+ break;
+ case SOAP_NAMESPACE:
+ *s = soap_set_validation_fault(soap, "namespace error", NULL);
+ break;
+ case SOAP_USER_ERROR:
+ *s = "User error";
+ break;
+ case SOAP_FATAL_ERROR:
+ *s = "Fatal error";
+ break;
+ case SOAP_NO_METHOD:
+ sprintf(soap->msgbuf, "Method '%s' not implemented: method name or namespace not recognized", soap->tag);
+ *s = soap->msgbuf;
+ break;
+ case SOAP_NO_DATA:
+ *s = "Data required for operation";
+ break;
+ case SOAP_GET_METHOD:
+ *s = "HTTP GET method not implemented";
+ break;
+ case SOAP_PUT_METHOD:
+ *s = "HTTP PUT method not implemented";
+ break;
+ case SOAP_HEAD_METHOD:
+ *s = "HTTP HEAD method not implemented";
+ break;
+ case SOAP_HTTP_METHOD:
+ *s = "HTTP method not implemented";
+ break;
+ case SOAP_EOM:
+ *s = "Out of memory";
+ break;
+ case SOAP_MOE:
+ *s = "Memory overflow or memory corruption error";
+ break;
+ case SOAP_HDR:
+ *s = "Header line too long";
+ break;
+ case SOAP_IOB:
+ *s = "Array index out of bounds";
+ break;
+ case SOAP_NULL:
+ *s = soap_set_validation_fault(soap, "nil not allowed", NULL);
+ break;
+ case SOAP_DUPLICATE_ID:
+ *s = soap_set_validation_fault(soap, "multiple definitions of id ", soap->id);
+ if (soap->version == 2)
+ *soap_faultsubcode(soap) = "SOAP-ENC:DuplicateID";
+ break;
+ case SOAP_MISSING_ID:
+ *s = soap_set_validation_fault(soap, "missing id for ref ", soap->id);
+ if (soap->version == 2)
+ *soap_faultsubcode(soap) = "SOAP-ENC:MissingID";
+ break;
+ case SOAP_HREF:
+ *s = soap_set_validation_fault(soap, "incompatible object type ref/id pair ", soap->id);
+ break;
+ case SOAP_FAULT:
+ break;
+#ifndef WITH_NOIO
+ case SOAP_UDP_ERROR:
+ *s = "Message too large for UDP packet";
+ break;
+ case SOAP_TCP_ERROR:
+ *s = tcp_error(soap);
+ break;
+#endif
+ case SOAP_HTTP_ERROR:
+ *s = "An HTTP processing error occurred";
+ break;
+ case SOAP_SSL_ERROR:
+#ifdef WITH_OPENSSL
+ *s = "SSL error";
+#else
+ *s = "OpenSSL not installed: recompile with -DWITH_OPENSSL";
+#endif
+ break;
+ case SOAP_PLUGIN_ERROR:
+ *s = "Plugin registry error";
+ break;
+ case SOAP_DIME_ERROR:
+ *s = "DIME format error";
+ break;
+ case SOAP_DIME_HREF:
+ *s = "DIME href to missing attachment";
+ break;
+ case SOAP_DIME_MISMATCH:
+ *s = "DIME version/transmission error";
+ break;
+ case SOAP_DIME_END:
+ *s = "End of DIME error";
+ break;
+ case SOAP_MIME_ERROR:
+ *s = "MIME format error";
+ break;
+ case SOAP_MIME_HREF:
+ *s = "MIME href to missing attachment";
+ break;
+ case SOAP_MIME_END:
+ *s = "End of MIME error";
+ break;
+ case SOAP_ZLIB_ERROR:
+#ifdef WITH_ZLIB
+ sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream->msg?soap->d_stream->msg:SOAP_STR_EOS);
+ *s = soap->msgbuf;
+#else
+ *s = "Zlib/gzip not installed for (de)compression: recompile with -DWITH_GZIP";
+#endif
+ break;
+ case SOAP_REQUIRED:
+ *s = soap_set_validation_fault(soap, "missing required attribute", NULL);
+ break;
+ case SOAP_PROHIBITED:
+ *s = soap_set_validation_fault(soap, "prohibited attribute present", NULL);
+ break;
+ case SOAP_OCCURS:
+ *s = soap_set_validation_fault(soap, "occurrence violation", NULL);
+ break;
+ case SOAP_LENGTH:
+ *s = soap_set_validation_fault(soap, "content range or length violation", NULL);
+ break;
+ case SOAP_FD_EXCEEDED:
+ *s = "Maximum number of open connections was reached (no define HAVE_POLL): increase FD_SETSIZE";
+ break;
+ case SOAP_STOP:
+ *s = "Stopped: no response to be sent or received (informative)";
+ break;
+#endif
+ case SOAP_EOF:
+#ifndef WITH_NOIO
+ strcpy(soap->msgbuf, soap_strerror(soap));
+#ifndef WITH_LEAN
+ if (strlen(soap->msgbuf) + 25 < sizeof(soap->msgbuf))
+ { memmove(soap->msgbuf + 25, soap->msgbuf, strlen(soap->msgbuf) + 1);
+ memcpy(soap->msgbuf, "End of file or no input: ", 25);
+ }
+#endif
+ *s = soap->msgbuf;
+ break;
+#else
+ *s = "End of file or no input";
+ break;
+#endif
+ default:
+#ifndef WITH_NOHTTP
+#ifndef WITH_LEAN
+ if (soap->error > 200 && soap->error < 600)
+ { sprintf(soap->msgbuf, "HTTP Error: %d %s", soap->error, http_error(soap, soap->error));
+ *s = soap->msgbuf;
+ }
+ else
+#endif
+#endif
+ { sprintf(soap->msgbuf, "Error %d", soap->error);
+ *s = soap->msgbuf;
+ }
+ }
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_send_fault(struct soap *soap)
+{ register int status = soap->error;
+ if (status == SOAP_STOP)
+ return soap_closesock(soap);
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error));
+ soap->keep_alive = 0; /* to terminate connection */
+ soap_set_fault(soap);
+ if (soap->error < 200 && soap->error != SOAP_FAULT)
+ soap->header = NULL;
+ if (status != SOAP_EOF || (!soap->recv_timeout && !soap->send_timeout))
+ { int r = 1;
+#ifndef WITH_NOIO
+ if (soap->fpoll && soap->fpoll(soap))
+ r = 0;
+#ifndef WITH_LEAN
+ else if (soap_valid_socket(soap->socket))
+ { r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_SND, 0);
+ if (r > 0)
+ { if (!(r & SOAP_TCP_SELECT_SND)
+ || ((r & SOAP_TCP_SELECT_RCV)
+ && recv(soap->socket, soap->tmpbuf, 1, MSG_PEEK) < 0))
+ r = 0;
+ }
+ }
+#endif
+#endif
+ if (r > 0)
+ { soap->error = SOAP_OK;
+ soap_serializeheader(soap);
+ soap_serializefault(soap);
+ soap_begin_count(soap);
+ if (soap->mode & SOAP_IO_LENGTH)
+ { soap_envelope_begin_out(soap);
+ soap_putheader(soap);
+ soap_body_begin_out(soap);
+ soap_putfault(soap);
+ soap_body_end_out(soap);
+ soap_envelope_end_out(soap);
+ }
+ soap_end_count(soap);
+ if (soap_response(soap, status)
+ || soap_envelope_begin_out(soap)
+ || soap_putheader(soap)
+ || soap_body_begin_out(soap)
+ || soap_putfault(soap)
+ || soap_body_end_out(soap)
+ || soap_envelope_end_out(soap))
+ return soap_closesock(soap);
+ soap_end_send(soap);
+ }
+ }
+ soap->error = status;
+ return soap_closesock(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_recv_fault(struct soap *soap, int check)
+{ register int status = soap->error;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Check if receiving SOAP Fault\n"));
+ if (!check)
+ { /* try getfault when no tag or tag mismatched at level 2, otherwise ret */
+ if (soap->error != SOAP_NO_TAG
+ && (soap->error != SOAP_TAG_MISMATCH || soap->level != 2))
+ return soap->error;
+ }
+ soap->error = SOAP_OK;
+ if (soap_getfault(soap))
+ { /* check flag set: check if SOAP Fault is present, if not just return */
+ if (check && soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
+ return soap->error = SOAP_OK;
+ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed. Is this a SOAP message at all?\n"));
+ *soap_faultcode(soap) = (soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client");
+ soap->error = status;
+ soap_set_fault(soap);
+ }
+ else
+ { register const char *s = *soap_faultcode(soap);
+ if (!soap_match_tag(soap, s, "SOAP-ENV:Server") || !soap_match_tag(soap, s, "SOAP-ENV:Receiver"))
+ status = SOAP_SVR_FAULT;
+ else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") || !soap_match_tag(soap, s, "SOAP-ENV:Sender"))
+ status = SOAP_CLI_FAULT;
+ else if (!soap_match_tag(soap, s, "SOAP-ENV:MustUnderstand"))
+ status = SOAP_MUSTUNDERSTAND;
+ else if (!soap_match_tag(soap, s, "SOAP-ENV:VersionMismatch"))
+ status = SOAP_VERSIONMISMATCH;
+ else
+ { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Received SOAP Fault code %s\n", s));
+ status = SOAP_FAULT;
+ }
+ if (!soap_body_end_in(soap))
+ soap_envelope_end_in(soap);
+ }
+ soap_end_recv(soap);
+ soap->error = status;
+ return soap_closesock(soap);
+}
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_send_empty_response(struct soap *soap, int httpstatuscode)
+{ register soap_mode m = soap->omode;
+ soap->count = 0;
+ if ((m & SOAP_IO) == SOAP_IO_CHUNK)
+ soap->omode = (m & ~SOAP_IO) | SOAP_IO_BUFFER;
+ if (soap_response(soap, httpstatuscode) || soap_end_send(soap))
+ { soap->omode = m;
+ return soap_closesock(soap);
+ }
+ soap->omode = m;
+ return soap->error = SOAP_STOP; /* stops the server's response */
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOHTTP
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_recv_empty_response(struct soap *soap)
+{ if (!soap_begin_recv(soap))
+ soap_end_recv(soap);
+ else if (soap->error == SOAP_NO_DATA || soap->error == 202)
+ soap->error = SOAP_OK;
+ return soap_closesock(soap);
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_NOIO
+#ifndef PALM_1
+static const char*
+soap_strerror(struct soap *soap)
+{ register int err = soap->errnum;
+ if (err)
+ {
+#ifndef WIN32
+ return strerror(err);
+#else
+#ifndef UNDER_CE
+ DWORD len;
+ *soap->msgbuf = '\0';
+ len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)soap->msgbuf, (DWORD)sizeof(soap->msgbuf), NULL);
+#else
+ DWORD i, len;
+ *soap->msgbuf = '\0';
+ len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR)soap->msgbuf, (DWORD)(sizeof(soap->msgbuf)/sizeof(TCHAR)), NULL);
+ for (i = 0; i <= len; i++)
+ { if (((TCHAR*)soap->msgbuf)[i] < 0x80)
+ soap->msgbuf[i] = (char)((TCHAR*)soap->msgbuf)[i];
+ else
+ soap->msgbuf[i] = '?';
+ }
+#endif
+#endif
+ }
+ else
+ { char *s = soap->msgbuf;
+#ifndef WITH_LEAN
+ int rt = soap->recv_timeout, st = soap->send_timeout;
+ int ru = ' ', su = ' ';
+#endif
+ strcpy(s, "Operation interrupted or timed out");
+#ifndef WITH_LEAN
+ if (rt < 0)
+ { rt = -rt;
+ ru = 'u';
+ }
+ if (st < 0)
+ { st = -st;
+ su = 'u';
+ }
+ if (rt)
+ sprintf(s + strlen(s), " (%d%cs receive delay)", rt, ru);
+ if (st)
+ sprintf(s + strlen(s), " (%d%cs send delay)", st, su);
+#endif
+ }
+ return soap->msgbuf;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+static int
+soap_set_error(struct soap *soap, const char *faultcode, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML, int soaperror)
+{ *soap_faultcode(soap) = faultcode;
+ if (faultsubcodeQName)
+ *soap_faultsubcode(soap) = faultsubcodeQName;
+ *soap_faultstring(soap) = faultstring;
+ if (faultdetailXML && *faultdetailXML)
+ { register const char **s = soap_faultdetail(soap);
+ if (s)
+ *s = faultdetailXML;
+ }
+ return soap->error = soaperror;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
+{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", NULL, faultstring, faultdetailXML, soaperror);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
+{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", NULL, faultstring, faultdetailXML, soaperror);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+static int
+soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML)
+{ char *r = NULL, *s = NULL, *t = NULL;
+ if (faultsubcodeQName)
+ r = soap_strdup(soap, faultsubcodeQName);
+ if (faultstring)
+ s = soap_strdup(soap, faultstring);
+ if (faultdetailXML)
+ t = soap_strdup(soap, faultdetailXML);
+ return soap_set_error(soap, faultcode, r, s, t, SOAP_FAULT);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultdetailXML)
+{ return soap_sender_fault_subcode(soap, NULL, faultstring, faultdetailXML);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_sender_fault_subcode(struct soap *soap, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML)
+{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultsubcodeQName, faultstring, faultdetailXML);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_receiver_fault(struct soap *soap, const char *faultstring, const char *faultdetailXML)
+{ return soap_receiver_fault_subcode(soap, NULL, faultstring, faultdetailXML);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_receiver_fault_subcode(struct soap *soap, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML)
+{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultsubcodeQName, faultstring, faultdetailXML);
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+#ifndef WITH_NOSTDLIB
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_print_fault(struct soap *soap, FILE *fd)
+{ if (soap_check_state(soap))
+ fprintf(fd, "Error: soap struct state not initialized\n");
+ else if (soap->error)
+ { const char *c, *v = NULL, *s, **d;
+ d = soap_faultcode(soap);
+ if (!*d)
+ soap_set_fault(soap);
+ c = *d;
+ if (soap->version == 2)
+ v = *soap_faultsubcode(soap);
+ s = *soap_faultstring(soap);
+ d = soap_faultdetail(soap);
+ fprintf(fd, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]");
+ }
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifdef __cplusplus
+#ifndef WITH_LEAN
+#ifndef WITH_NOSTDLIB
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_stream_fault(struct soap *soap, std::ostream& os)
+{ if (soap_check_state(soap))
+ os << "Error: soap struct state not initialized\n";
+ else if (soap->error)
+ { const char *c, *v = NULL, *s, **d;
+ d = soap_faultcode(soap);
+ if (!*d)
+ soap_set_fault(soap);
+ c = *d;
+ if (soap->version == 2)
+ v = *soap_faultsubcode(soap);
+ s = *soap_faultstring(soap);
+ d = soap_faultdetail(soap);
+ os << (soap->version ? "SOAP 1." : "Error ")
+ << (soap->version ? (int)soap->version : soap->error)
+ << " fault: " << c
+ << "[" << (v ? v : "no subcode") << "]"
+ << std::endl
+ << "\"" << (s ? s : "[no reason]") << "\""
+ << std::endl
+ << "Detail: " << (d && *d ? *d : "[no detail]")
+ << std::endl;
+ }
+}
+#endif
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef WITH_LEAN
+#ifndef WITH_NOSTDLIB
+SOAP_FMAC1
+char*
+SOAP_FMAC2
+soap_sprint_fault(struct soap *soap, char *buf, size_t len)
+{ if (soap_check_state(soap))
+ strncpy(buf, "Error: soap struct not initialized", len);
+ else if (soap->error)
+ { const char *c, *v = NULL, *s, **d;
+ d = soap_faultcode(soap);
+ if (!*d)
+ soap_set_fault(soap);
+ c = *d;
+ if (soap->version == 2)
+ v = *soap_faultsubcode(soap);
+ s = *soap_faultstring(soap);
+ d = soap_faultdetail(soap);
+#ifdef HAVE_SNPRINTF
+# ifdef WIN32
+ _snprintf
+# else
+ snprintf
+# endif
+ (buf, len, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]");
+#else
+ if (len > 40 + (v ? strlen(v) : 0) + (s ? strlen(s) : 0) + (d && *d ? strlen(*d) : 0))
+ sprintf(buf, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c, v ? v : "no subcode", s ? s : "[no reason]", d && *d ? *d : "[no detail]");
+ else if (len > 40)
+ sprintf(buf, "%s%d fault: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, c);
+ else
+ buf[0] = '\0';
+#endif
+ }
+ return buf;
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+#ifndef WITH_NOSTDLIB
+SOAP_FMAC1
+void
+SOAP_FMAC2
+soap_print_fault_location(struct soap *soap, FILE *fd)
+{
+#ifndef WITH_LEAN
+ int i, j, c1, c2;
+ if (soap->error && soap->error != SOAP_STOP && soap->bufidx <= soap->buflen && soap->buflen > 0 && soap->buflen <= SOAP_BUFLEN)
+ { i = (int)soap->bufidx - 1;
+ if (i <= 0)
+ i = 0;
+ c1 = soap->buf[i];
+ soap->buf[i] = '\0';
+ if ((int)soap->buflen >= i + 1024)
+ j = i + 1023;
+ else
+ j = (int)soap->buflen - 1;
+ c2 = soap->buf[j];
+ soap->buf[j] = '\0';
+ fprintf(fd, "%s%c\n<!-- ** HERE ** -->\n", soap->buf, c1);
+ if (soap->bufidx < soap->buflen)
+ fprintf(fd, "%s\n", soap->buf + soap->bufidx);
+ soap->buf[i] = c1;
+ soap->buf[j] = c2;
+ }
+#endif
+}
+#endif
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+SOAP_FMAC1
+int
+SOAP_FMAC2
+soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void *arg)
+{ register struct soap_plugin *p;
+ register int r;
+ if (!(p = (struct soap_plugin*)SOAP_MALLOC(soap, sizeof(struct soap_plugin))))
+ return soap->error = SOAP_EOM;
+ p->id = NULL;
+ p->data = NULL;
+ p->fcopy = NULL;
+ p->fdelete = NULL;
+ r = fcreate(soap, p, arg);
+ if (!r && p->fdelete)
+ { p->next = soap->plugins;
+ soap->plugins = p;
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Registered '%s' plugin\n", p->id));
+ return SOAP_OK;
+ }
+ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not register plugin '%s': plugin returned error %d (or fdelete callback not set)\n", p->id?p->id:"?", r));
+ SOAP_FREE(soap, p);
+ return r;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_1
+static void *
+fplugin(struct soap *soap, const char *id)
+{ register struct soap_plugin *p;
+ for (p = soap->plugins; p; p = p->next)
+ if (p->id == id || !strcmp(p->id, id))
+ return p->data;
+ return NULL;
+}
+#endif
+
+/******************************************************************************/
+#ifndef PALM_2
+SOAP_FMAC1
+void *
+SOAP_FMAC2
+soap_lookup_plugin(struct soap *soap, const char *id)
+{ return soap->fplugin(soap, id);
+}
+#endif
+
+/******************************************************************************/
+#ifdef __cplusplus
+}
+#endif
+
+/******************************************************************************\
+ *
+ * C++ soap struct methods
+ *
+\******************************************************************************/
+
+#ifdef __cplusplus
+soap::soap()
+{ soap_init(this);
+}
+#endif
+
+/******************************************************************************/
+#ifdef __cplusplus
+soap::soap(soap_mode m)
+{ soap_init1(this, m);
+}
+#endif
+
+/******************************************************************************/
+#ifdef __cplusplus
+soap::soap(soap_mode im, soap_mode om)
+{ soap_init2(this, im, om);
+}
+#endif
+
+/******************************************************************************/
+#ifdef __cplusplus
+soap::soap(const struct soap& soap)
+{ soap_copy_context(this, &soap);
+}
+#endif
+
+/******************************************************************************/
+#ifdef __cplusplus
+soap::~soap()
+{ soap_destroy(this);
+ soap_end(this);
+ soap_done(this);
+}
+#endif
+
+/******************************************************************************/
diff --git a/usr/src/lib/libkmsagent/common/SOAP/stdsoap2.h b/usr/src/lib/libkmsagent/common/SOAP/stdsoap2.h
new file mode 100644
index 0000000000..a9161b80e6
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SOAP/stdsoap2.h
@@ -0,0 +1,2444 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*
+ stdsoap2.h 2.7.17
+
+ gSOAP runtime engine
+
+gSOAP XML Web services tools
+Copyright (C) 2000-2010, Robert van Engelen, Genivia Inc., All Rights Reserved.
+This part of the software is released under ONE of the following licenses:
+GPL, or the gSOAP public license, or Genivia's license for commercial use.
+--------------------------------------------------------------------------------
+Contributors:
+
+Wind River Systems, Inc., for the following additions
+ - vxWorks compatible
+--------------------------------------------------------------------------------
+gSOAP public license.
+
+The contents of this file are subject to the gSOAP Public License Version 1.3
+(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.cs.fsu.edu/~engelen/soaplicense.html
+Software distributed under the License is distributed on an "AS IS" basis,
+WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+for the specific language governing rights and limitations under the License.
+
+The Initial Developer of the Original Code is Robert A. van Engelen.
+Copyright (C) 2000-2010, Robert van Engelen, Genivia Inc., All Rights Reserved.
+--------------------------------------------------------------------------------
+GPL license.
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+
+Author contact information:
+engelen@genivia.com / engelen@acm.org
+
+This program is released under the GPL with the additional exemption that
+compiling, linking, and/or using OpenSSL is allowed.
+--------------------------------------------------------------------------------
+A commercial use license is available from Genivia, Inc., contact@genivia.com
+--------------------------------------------------------------------------------
+*/
+
+#ifdef WITH_SOAPDEFS_H
+# include "soapdefs.h" /* include user-defined stuff */
+#endif
+
+#ifndef _THREAD_SAFE
+# define _THREAD_SAFE
+#endif
+
+#ifndef OPENSERVER
+# ifndef _REENTRANT
+# define _REENTRANT
+# endif
+#endif
+
+#ifndef SOAP_FMAC1 /* stdsoap2.h declaration macro */
+# define SOAP_FMAC1
+#endif
+
+#ifndef SOAP_FMAC2 /* stdsoap2.h declaration macro */
+# define SOAP_FMAC2
+#endif
+
+#ifndef SOAP_FMAC3 /* (de)serializer declaration macro */
+# define SOAP_FMAC3
+#endif
+
+#ifndef SOAP_FMAC3S /* string converter for (de)serializer declaration macro */
+# define SOAP_FMAC3S SOAP_FMAC3
+#endif
+
+#ifndef SOAP_FMAC4 /* (de)serializer declaration macro */
+# define SOAP_FMAC4
+#endif
+
+#ifndef SOAP_FMAC4S /* string converter for (de)serializer declaration macro */
+# define SOAP_FMAC4S SOAP_FMAC4
+#endif
+
+#ifndef SOAP_FMAC5 /* stub/skeleton declaration macro */
+# define SOAP_FMAC5
+#endif
+
+#ifndef SOAP_FMAC6 /* stub/skeleton declaration macro */
+# define SOAP_FMAC6
+#endif
+
+#ifndef SOAP_CMAC /* class declaration macro */
+# define SOAP_CMAC
+#endif
+
+#ifndef SOAP_NMAC /* namespace table declaration macro */
+# define SOAP_NMAC
+#endif
+
+#ifndef SOAP_SOURCE_STAMP
+# define SOAP_SOURCE_STAMP(str)
+#endif
+
+/* gSOAP 2.7.4 and higher: fast look-aside buffering is stable */
+#ifndef WITH_FAST
+# define WITH_FAST
+#endif
+
+/* gSOAP 2.7.15 and higher: always retain CDATA in literal XML, unless WITH_LEAN or WITH_NOCDATA */
+#ifndef WITH_LEAN
+# ifndef WITH_NOCDATA
+# ifndef WITH_CDATA
+# define WITH_CDATA
+# endif
+# endif
+#endif
+
+#ifdef WITH_LEANER
+# ifndef WITH_LEAN
+# define WITH_LEAN
+# endif
+#endif
+
+#ifdef WITH_LEAN
+# ifdef WITH_COOKIES
+# error "Cannot build WITH_LEAN code WITH_COOKIES enabled"
+# endif
+#endif
+
+#ifndef STDSOAP_H
+#define STDSOAP_H
+
+#if defined(__vxworks) || defined(__VXWORKS__)
+# ifndef VXWORKS
+# define VXWORKS
+# endif
+#endif
+
+#ifdef _WIN32
+# ifndef WIN32
+# define WIN32
+# endif
+#endif
+
+#ifdef _WIN32_WCE
+# ifndef UNDER_CE
+# define UNDER_CE _WIN32_WCE
+# endif
+#endif
+
+#ifdef UNDER_CE
+# ifndef WIN32
+# define WIN32
+# endif
+#endif
+
+#ifdef __BORLANDC__
+# ifdef __WIN32__
+# ifndef WIN32
+# define WIN32
+# endif
+# endif
+#endif
+
+#ifdef __CYGWIN__
+# ifndef CYGWIN
+# define CYGWIN
+# endif
+#endif
+
+#ifdef __SYMBIAN32__
+# define SYMBIAN
+# undef WIN32
+#endif
+
+#if defined(__palmos__) || defined(PALM_GCC) || defined(__PALMOS_TRAPS__)
+# ifndef PALM
+# define PALM
+# endif
+#endif
+
+#if defined(__hpux)
+# ifndef HP_UX
+# define HP_UX
+# endif
+#endif
+
+#if defined(__digital__) && defined(__unix__)
+# ifndef TRU64
+# define TRU64
+# endif
+#endif
+
+#ifdef __MVS__
+# ifndef OS390
+# define OS390
+# endif
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+# if defined(WITH_OPENSSL)
+# ifndef HAVE_OPENSSL_SSL_H
+# undef WITH_OPENSSL
+# endif
+# endif
+# if defined(WITH_ZLIB) || defined(WITH_GZIP)
+# ifndef HAVE_ZLIB_H
+# undef WITH_ZLIB
+# undef WITH_GZIP
+# endif
+# endif
+#else
+# if defined(UNDER_CE)
+# define WITH_LEAN
+# define HAVE_SSCANF
+# elif defined(WIN32)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_GMTIME
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# define SOAP_LONG_FORMAT "%I64d"
+# define SOAP_ULONG_FORMAT "%I64u"
+# elif defined(CYGWIN)
+# define HAVE_POLL
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(__APPLE__)
+# define HAVE_POLL
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOD_L
+# define HAVE_SSCANF_L
+# define HAVE_SPRINTF_L
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_TIMEGM
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(_AIX43)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(_AIX41)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(HP_UX)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD)
+# define HAVE_POLL
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOD_L
+# define HAVE_SSCANF_L
+# define HAVE_SPRINTF_L
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_STRTOLL
+# define HAVE_STRTOULL
+# define HAVE_GETTIMEOFDAY
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# define SOAP_LONG_FORMAT "%qd"
+# define SOAP_ULONG_FORMAT "%qu"
+# elif defined(__VMS)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(__GLIBC__) || defined(__GNU__)
+# define HAVE_POLL
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOD_L
+# define HAVE_SSCANF_L
+# define HAVE_SPRINTF_L
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_STRTOLL
+# define HAVE_STRTOULL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_TIMEGM
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# define HAVE_ISNAN
+# elif defined(TRU64)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_GETTIMEOFDAY
+# define HAVE_SYS_TIMEB_H
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define __USE_STD_IOSTREAM
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# define SOAP_LONG_FORMAT "%ld"
+# define SOAP_ULONG_FORMAT "%lu"
+# elif defined(MAC_CARBON)
+# define WITH_NOIO
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOD_L
+# define HAVE_SSCANF_L
+# define HAVE_SPRINTF_L
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GETHOSTBYNAME_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(PALM)
+# define WITH_LEAN
+# define HAVE_STRTOD /* strtod() is defined in palmFunctions.h */
+# include <stdlib.h> /* Needs to be included before unix headers */
+# include <sys_types.h>
+# define IGNORE_STDIO_STUBS
+# include <StdIOPalm.h>
+# define O_NONBLOCK FNONBIO
+# include <sys_socket.h>
+# include "palmFunctions.h"
+# elif defined(SYMBIAN)
+# define WITH_LEAN
+# define WITH_NONAMESPACES
+# define HAVE_STRTOD /* use STRTOD since sscanf doesn't seem to work */
+# include <e32def.h>
+# include <sys/ioctl.h>
+# elif defined(VXWORKS)
+# ifdef _WRS_KERNEL
+# define _POSIX_THREADS 1
+# endif
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_GMTIME
+# define HAVE_LOCALTIME
+# define HAVE_MKTIME
+# elif defined(OS390)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(AS400)
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# elif defined(__QNX__) || defined(QNX)
+/* QNX does not have a working version of strtof */
+# undef HAVE_STRTOF
+# define HAVE_POLL
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GETHOSTBYNAME_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# define LONG64 long
+# define ULONG64 unsigned LONG64
+# define SOAP_LONG_FORMAT "%ld"
+# define SOAP_ULONG_FORMAT "%lu"
+# else
+/* Default assumptions for supported functions */
+# define HAVE_SNPRINTF
+# define HAVE_STRRCHR
+# define HAVE_STRTOD
+# define HAVE_SSCANF
+# define HAVE_STRTOL
+# define HAVE_STRTOUL
+# define HAVE_SYS_TIMEB_H
+# define HAVE_FTIME
+# define HAVE_RAND_R
+# define HAVE_GETHOSTBYNAME_R
+# define HAVE_GMTIME_R
+# define HAVE_LOCALTIME_R
+# ifdef MB_LEN_MAX
+# define HAVE_WCTOMB
+# define HAVE_MBTOWC
+# endif
+# endif
+#endif
+
+/* native Win and HP-UX compilers don't like empty structs */
+#if defined(WIN32) || defined(HP_UX) || defined(_AIX41) || defined(_AIX43) || defined(VXWORKS)
+# define WITH_NOEMPTYSTRUCT
+#endif
+
+#ifdef HP_UX
+# undef HAVE_STRTOLL
+# undef HAVE_STRTOULL
+#endif
+
+/* older OpenVMS TCP/IP stacks cannot handle 65536 bytes */
+#ifdef __VMS
+# ifndef SOAP_BUFLEN
+# define SOAP_BUFLEN (65535)
+# endif
+#endif
+
+#ifdef WITH_C_LOCALE
+# include <xlocale.h>
+#else
+# undef HAVE_STRTOF_L
+# undef HAVE_STRTOD_L
+# undef HAVE_SSCANF_L
+# undef HAVE_SPRINTF_L
+#endif
+
+#ifndef WITH_NOSTDLIB
+# include <stdlib.h>
+# ifndef PALM
+# include <stdio.h>
+# include <string.h>
+# endif
+# include <ctype.h>
+# include <limits.h>
+#endif
+
+#ifdef HAVE_POLL
+# include <poll.h>
+#endif
+
+#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
+# include <string>
+# include <iostream>
+#endif
+
+#ifdef WITH_NOHTTP
+# ifndef WITH_NOIO
+# define WITH_NOIO
+# undef WITH_COOKIES
+# endif
+#endif
+
+/* Suggestion when SOAP_FD_EXCEEDED error occurs:
+ Some systems allow increasing FD_SETSIZE before including sys/types.h:
+#define FD_SETSIZE (2048)
+*/
+
+#ifndef UNDER_CE
+# ifndef PALM
+# ifndef WITH_NOIO
+# include <errno.h>
+# include <sys/types.h>
+# endif
+# ifndef WITH_LEAN
+# ifdef HAVE_SYS_TIMEB_H
+# include <sys/timeb.h> /* for ftime() */
+# endif
+# include <time.h>
+# endif
+# endif
+#endif
+
+#ifdef OPENSERVER
+# include <sys/socket.h>
+# include <sys/stream.h>
+# include <sys/protosw.h>
+ extern int h_errno;
+#endif
+
+#ifndef WITH_NOIO
+# ifndef WIN32
+# ifndef PALM
+# include <sys/socket.h>
+# ifdef VXWORKS
+# include <sockLib.h>
+# include <selectLib.h>
+# ifndef _WRS_KERNEL
+# include <strings.h>
+# endif
+# else
+# ifndef SYMBIAN
+# include <strings.h>
+# endif
+# endif
+# ifdef SUN_OS
+# include <sys/stream.h> /* SUN */
+# include <sys/socketvar.h> /* SUN < 2.8 (?) */
+# endif
+# ifdef VXWORKS
+# ifdef _WRS_KERNEL
+# include <sys/times.h>
+# endif
+# else
+# include <sys/time.h>
+# endif
+# include <netinet/in.h>
+# ifdef OS390
+# include <netinet/tcp_var.h>
+# else
+# include <netinet/tcp.h> /* TCP_NODELAY */
+# endif
+# include <arpa/inet.h>
+# endif
+# endif
+#endif
+
+#ifdef WIN32
+# define SOAP_WINSOCKINT int
+#else
+# define SOAP_WINSOCKINT size_t
+#endif
+
+#ifdef WIN32
+# ifndef UNDER_CE
+# include <io.h>
+# include <fcntl.h>
+# endif
+# ifdef WITH_IPV6
+# include <winsock2.h> /* Visual Studio 2005 users: you must install the Platform SDK (R2) */
+# include <ws2tcpip.h>
+# include <wspiapi.h>
+# define SOAP_GAI_STRERROR gai_strerrorA
+# else
+# ifndef __BORLANDC__
+# include <winsock.h> /* Visual Studio 2005 users: you must install the Platform SDK (R2) */
+/* # include <winsock2.h> */ /* Alternative: use winsock2 (not available with eVC), enable this line and comment out the line above */
+# else
+# include <winsock2.h> /* Borland C */
+# endif
+# endif
+#else
+# ifdef VXWORKS
+# include <hostLib.h>
+# include <ioctl.h>
+# include <ioLib.h>
+# endif
+# ifndef WITH_NOIO
+# ifndef PALM
+# include <netdb.h>
+# include <netinet/in.h>
+# include <unistd.h>
+# include <fcntl.h>
+# ifdef _AIX41
+# include <sys/select.h>
+# endif
+# endif
+# endif
+#endif
+
+#ifdef WITH_FASTCGI
+# include <fcgi_stdio.h>
+#endif
+
+#ifdef WITH_OPENSSL
+# define OPENSSL_NO_KRB5
+# include <openssl/bio.h>
+# include <openssl/err.h>
+# include <openssl/rand.h>
+# include <openssl/ssl.h>
+# include <openssl/x509v3.h>
+# ifndef ALLOW_OLD_VERSIONS
+# if (OPENSSL_VERSION_NUMBER < 0x00905100L)
+# error "Must use OpenSSL 0.9.6 or later"
+# endif
+# endif
+#endif
+
+#ifdef WITH_GNUTLS
+# include <gnutls/gnutls.h>
+#endif
+
+#ifdef WITH_GZIP
+# ifndef WITH_ZLIB
+# define WITH_ZLIB
+# endif
+#endif
+
+#ifdef WITH_CASEINSENSITIVETAGS
+# define SOAP_STRCMP soap_tag_cmp /* case insensitve XML element/attribute names */
+#else
+# define SOAP_STRCMP strcmp /* case sensitive XML element/attribute names */
+#endif
+
+#ifdef WITH_ZLIB
+# include <zlib.h>
+#endif
+
+#ifndef WITH_NOSTDLIB
+# ifndef PALM
+# include <math.h> /* for isnan() */
+# endif
+#endif
+
+/* #define DEBUG */ /* Uncomment to debug sending (in file SENT.log) receiving (in file RECV.log) and messages (in file TEST.log) */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Portability: define SOAP_SOCKLEN_T */
+#if defined(_AIX)
+# if defined(_AIX43)
+# define SOAP_SOCKLEN_T socklen_t
+# else
+# define SOAP_SOCKLEN_T int
+# endif
+#elif defined(SOCKLEN_T)
+# define SOAP_SOCKLEN_T SOCKLEN_T
+#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) || defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__) || defined(QNX) || defined(OS390) || defined(HP_UX)
+# define SOAP_SOCKLEN_T socklen_t
+#elif defined(IRIX) || defined(WIN32) || defined(__APPLE__) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS)
+# define SOAP_SOCKLEN_T int
+#else
+# define SOAP_SOCKLEN_T size_t
+#endif
+
+#ifndef SOAP_SOCKET
+# ifdef WIN32
+# define SOAP_SOCKET SOCKET
+# define soap_closesocket(n) closesocket(n)
+# else
+# define SOAP_SOCKET int
+# define soap_closesocket(n) close(n)
+# endif
+#endif
+
+#define SOAP_INVALID_SOCKET ((SOAP_SOCKET)-1)
+#define soap_valid_socket(n) ((n) != SOAP_INVALID_SOCKET)
+
+#ifndef SOAP_GAI_STRERROR
+# define SOAP_GAI_STRERROR gai_strerror
+#endif
+
+#ifndef FD_SETSIZE
+# define FD_SETSIZE (1024)
+#endif
+
+#if defined(SYMBIAN)
+# define LONG64 long
+# define ULONG64 unsigned LONG64
+#elif !defined(WIN32) || defined(CYGWIN) || defined(__GLIBC__) || defined(__GNU__)
+# ifndef LONG64
+# if defined(HAVE_STDINT_H)
+# include <stdint.h>
+# define LONG64 int64_t
+# define ULONG64 uint64_t
+# elif defined(__GLIBC__)
+# include <bits/wordsize.h>
+# if (__WORDSIZE == 64)
+# define LONG64 int64_t
+# define ULONG64 uint64_t
+# ifndef SOAP_LONG_FORMAT
+# define SOAP_LONG_FORMAT "%ld"
+# endif
+# ifndef SOAP_ULONG_FORMAT
+# define SOAP_ULONG_FORMAT "%lu"
+# endif
+# else
+# define LONG64 long long
+# define ULONG64 unsigned LONG64
+# endif
+# else
+# define LONG64 long long
+# define ULONG64 unsigned LONG64
+# endif
+# endif
+#elif defined(UNDER_CE)
+# define LONG64 __int64
+# define ULONG64 unsigned LONG64
+#elif defined(__BORLANDC__)
+# define LONG64 __int64
+# define ULONG64 unsigned LONG64
+#endif
+
+#ifndef SOAP_LONG_FORMAT
+# define SOAP_LONG_FORMAT "%lld" /* printf format for 64 bit ints */
+#endif
+
+#ifndef SOAP_ULONG_FORMAT
+# define SOAP_ULONG_FORMAT "%llu" /* printf format for unsigned 64 bit ints */
+#endif
+
+#if defined(WIN32) && !defined(CYGWIN)
+# define soap_int32 __int32
+#elif defined(SYMBIAN)
+# define soap_int32 long
+#elif defined(PALM)
+# define soap_int32 Int32
+#elif defined(_AIX)
+# define SOAP_NEW(type) new type /* AIX compilers don't like new (t) */
+# if defined(_AIX43)
+# define soap_int32 int32_t
+# else
+# define soap_int32 signed int
+# endif
+#else
+# define soap_int32 int32_t
+#endif
+
+#ifdef WIN32
+# define SOAP_ERANGE ERANGE
+# define SOAP_EINTR WSAEINTR
+# define SOAP_EAGAIN WSAEWOULDBLOCK
+# define SOAP_EWOULDBLOCK WSAEWOULDBLOCK
+# define SOAP_EINPROGRESS WSAEINPROGRESS
+# define SOAP_EADDRINUSE WSAEADDRINUSE
+#else
+# define SOAP_ERANGE ERANGE
+# define SOAP_EINTR EINTR
+# define SOAP_EAGAIN EAGAIN
+# define SOAP_EADDRINUSE EADDRINUSE
+# ifdef SYMBIAN
+# define SOAP_EWOULDBLOCK 9898
+# define SOAP_EINPROGRESS 9899
+# else
+# define SOAP_EWOULDBLOCK EWOULDBLOCK
+# define SOAP_EINPROGRESS EINPROGRESS
+# endif
+#endif
+
+#ifdef WIN32
+# ifdef UNDER_CE
+# define soap_errno GetLastError()
+# define soap_socket_errno(s) GetLastError()
+# define soap_reset_errno SetLastError(0)
+# else
+# define soap_errno GetLastError()
+# define soap_socket_errno(s) WSAGetLastError()
+# define soap_reset_errno SetLastError(0)
+# endif
+#else
+# ifndef WITH_NOIO
+# define soap_errno errno
+# define soap_socket_errno(s) errno
+# define soap_reset_errno (errno = 0)
+# else
+# define soap_errno 0
+# define soap_socket_errno(s) 0
+# define soap_reset_errno
+# endif
+#endif
+
+#ifndef SOAP_BUFLEN
+# if !defined(WITH_LEAN)
+# define SOAP_BUFLEN (65536) /* buffer length for socket packets, also used by gethostbyname_r and UDP messages, so don't make this too small */
+# else
+# define SOAP_BUFLEN (2048) /* lean size */
+# endif
+#endif
+#ifndef SOAP_LABLEN
+# define SOAP_LABLEN (256) /* initial look-aside buffer length */
+#endif
+#ifndef SOAP_PTRBLK
+# define SOAP_PTRBLK (32) /* block allocation for pointer hash table chains */
+#endif
+#ifndef SOAP_PTRHASH
+# ifndef WITH_LEAN
+# define SOAP_PTRHASH (1024) /* size of pointer analysis hash table (must be power of 2) */
+# else
+# define SOAP_PTRHASH (32)
+# endif
+#endif
+#ifndef SOAP_IDHASH
+# ifndef WITH_LEAN
+# define SOAP_IDHASH (1999) /* prime size of hash table for parsed id/ref */
+# else
+# define SOAP_IDHASH (19) /* 19, 199 */
+# endif
+#endif
+#ifndef SOAP_BLKLEN
+# ifndef WITH_LEAN
+# define SOAP_BLKLEN (256) /* size of blocks to collect long strings and XML attributes */
+# else
+# define SOAP_BLKLEN (32)
+# endif
+#endif
+#ifndef SOAP_TAGLEN
+# ifndef WITH_LEAN
+# define SOAP_TAGLEN (1024) /* maximum length of XML element tag/attribute name or host/path name + 1 */
+# else
+# define SOAP_TAGLEN (64)
+# endif
+#endif
+#ifndef SOAP_HDRLEN
+# ifndef WITH_LEAN
+# define SOAP_HDRLEN (8192) /* maximum length of HTTP header line (must be >4096 to read cookies) */
+# else
+# define SOAP_HDRLEN (1024)
+# endif
+#endif
+#ifndef SOAP_MAXDIMS
+# ifndef WITH_LEAN
+# define SOAP_MAXDIMS (16) /* maximum array dimensions (array nestings) must be less than 64 to protect soap->tmpbuf */
+# else
+# define SOAP_MAXDIMS (4)
+# endif
+#endif
+
+#ifndef SOAP_MAXLOGS
+# define SOAP_MAXLOGS (3) /* max number of debug logs per struct soap environment */
+# define SOAP_INDEX_RECV (0)
+# define SOAP_INDEX_SENT (1)
+# define SOAP_INDEX_TEST (2)
+#endif
+
+/* Max iterations in soap_serve() to keep server connection alive */
+#ifndef SOAP_MAXKEEPALIVE
+# define SOAP_MAXKEEPALIVE (100)
+#endif
+
+/* Trusted max size of inbound SOAP array for compound array allocation.
+ Increase if necessary to allow larger arrays.
+*/
+#ifndef SOAP_MAXARRAYSIZE
+# define SOAP_MAXARRAYSIZE (1000000)
+#endif
+
+#ifdef VXWORKS
+# ifdef WMW_RPM_IO
+# include "httpLib.h"
+# endif
+# ifdef __INCmathh
+# include <private/mathP.h>
+# ifndef HAVE_ISNAN
+# define HAVE_ISNAN
+# endif
+# ifndef soap_isnan
+# define soap_isnan(num) isNan(num)
+# endif
+# endif
+# ifdef WM_SECURE_KEY_STORAGE
+# include <ipcom_key_db.h>
+# endif
+#endif
+
+#ifdef WIN32
+# include <float.h>
+# ifndef HAVE_ISNAN
+# define HAVE_ISNAN
+# endif
+# define soap_isnan(num) _isnan(num)
+#endif
+
+#ifdef SUN_OS
+# define HAVE_ISNAN
+#endif
+
+#ifdef __APPLE__
+# ifdef __cplusplus
+# ifndef isnan
+extern "C" int isnan(double);
+# endif
+# endif
+# define HAVE_ISNAN
+#endif
+
+#if !defined(HAVE_ISNAN) && (defined(_MATH_H) || defined(_MATH_INCLUDED))
+# define HAVE_ISNAN
+#endif
+
+extern const struct soap_double_nan { unsigned int n1, n2; } soap_double_nan;
+
+#ifdef VXWORKS
+# ifndef FLT_MAX
+# define FLT_MAX _ARCH_FLT_MAX
+# endif
+# ifndef DBL_MAX
+# define DBL_MAX _ARCH_DBL_MAX
+# endif
+#endif
+
+#ifndef FLT_NAN
+# define FLT_NAN (*(float*)(void*)&soap_double_nan)
+#endif
+
+#ifndef FLT_PINFTY
+# if defined(FLT_MAX)
+# define FLT_PINFTY FLT_MAX
+# elif defined(HUGE_VALF)
+# define FLT_PINFTY (float)HUGE_VALF
+# elif defined(HUGE_VAL)
+# define FLT_PINFTY (float)HUGE_VAL
+# elif defined(FLOAT_MAX)
+# define FLT_PINFTY FLOAT_MAX
+# else
+# define FLT_PINFTY (3.40282347e+38F)
+# endif
+#endif
+
+#ifndef FLT_NINFTY
+# define FLT_NINFTY (-FLT_PINFTY)
+#endif
+
+#ifndef DBL_NAN
+# define DBL_NAN (*(double*)(void*)&soap_double_nan)
+#endif
+
+#ifndef DBL_PINFTY
+# if defined(DBL_MAX)
+# define DBL_PINFTY DBL_MAX
+# elif defined(HUGE_VALF)
+# define DBL_PINFTY (double)HUGE_VALF
+# elif defined(HUGE_VAL)
+# define DBL_PINFTY (double)HUGE_VAL
+# elif defined(DOUBLE_MAX)
+# define DBL_PINFTY DOUBLE_MAX
+# else
+# define DBL_PINFTY (1.7976931348623157e+308)
+# endif
+#endif
+
+#ifndef DBL_NINFTY
+# define DBL_NINFTY (-DBL_PINFTY)
+#endif
+
+#ifndef soap_isnan
+# ifdef HAVE_ISNAN
+# define soap_isnan(n) isnan(n)
+# else
+# define soap_isnan(n) (0)
+# endif
+#endif
+
+#define soap_ispinfd(n) ((n) >= DBL_PINFTY)
+#define soap_ispinff(n) ((n) >= FLT_PINFTY)
+#define soap_isninfd(n) ((n) <= DBL_NINFTY)
+#define soap_isninff(n) ((n) <= FLT_NINFTY)
+
+/* gSOAP error codes */
+
+#define SOAP_EOF EOF
+#define SOAP_ERR EOF
+#define SOAP_OK 0
+#define SOAP_CLI_FAULT 1
+#define SOAP_SVR_FAULT 2
+#define SOAP_TAG_MISMATCH 3
+#define SOAP_TYPE 4
+#define SOAP_SYNTAX_ERROR 5
+#define SOAP_NO_TAG 6
+#define SOAP_IOB 7
+#define SOAP_MUSTUNDERSTAND 8
+#define SOAP_NAMESPACE 9
+#define SOAP_USER_ERROR 10
+#define SOAP_FATAL_ERROR 11
+#define SOAP_FAULT 12
+#define SOAP_NO_METHOD 13
+#define SOAP_NO_DATA 14
+#define SOAP_GET_METHOD 15
+#define SOAP_PUT_METHOD 16
+#define SOAP_DEL_METHOD 17
+#define SOAP_HEAD_METHOD 18
+#define SOAP_HTTP_METHOD 19
+#define SOAP_EOM 20
+#define SOAP_MOE 21
+#define SOAP_HDR 22
+#define SOAP_NULL 23
+#define SOAP_DUPLICATE_ID 24
+#define SOAP_MISSING_ID 25
+#define SOAP_HREF 26
+#define SOAP_UDP_ERROR 27
+#define SOAP_TCP_ERROR 28
+#define SOAP_HTTP_ERROR 29
+#define SOAP_SSL_ERROR 30
+#define SOAP_ZLIB_ERROR 31
+#define SOAP_DIME_ERROR 32
+#define SOAP_DIME_HREF 33
+#define SOAP_DIME_MISMATCH 34
+#define SOAP_DIME_END 35
+#define SOAP_MIME_ERROR 36
+#define SOAP_MIME_HREF 37
+#define SOAP_MIME_END 38
+#define SOAP_VERSIONMISMATCH 39
+#define SOAP_PLUGIN_ERROR 40
+#define SOAP_DATAENCODINGUNKNOWN 41
+#define SOAP_REQUIRED 42
+#define SOAP_PROHIBITED 43
+#define SOAP_OCCURS 44
+#define SOAP_LENGTH 45
+#define SOAP_FD_EXCEEDED 46
+
+#define soap_xml_error_check(e) ((e) == SOAP_TAG_MISMATCH || (e) == SOAP_NO_TAG || (e) == SOAP_SYNTAX_ERROR || (e) == SOAP_NAMESPACE || (e) == SOAP_DUPLICATE_ID || (e) == SOAP_MISSING_ID || (e) == SOAP_REQUIRED || (e) == SOAP_PROHIBITED || (e) == SOAP_OCCURS || (e) == SOAP_LENGTH || (e) == SOAP_NULL || (e) == SOAP_HREF)
+#define soap_soap_error_check(e) ((e) == SOAP_CLI_FAULT || (e) == SOAP_SVR_FAULT || (e) == SOAP_VERSIONMISMATCH || (e) == SOAP_MUSTUNDERSTAND || (e) == SOAP_FAULT || (e) == SOAP_NO_METHOD)
+#define soap_tcp_error_check(e) ((e) == SOAP_EOF || (e) == SOAP_TCP_ERROR)
+#define soap_ssl_error_check(e) ((e) == SOAP_SSL_ERROR)
+#define soap_zlib_error_check(e) ((e) == SOAP_ZLIB_ERROR)
+#define soap_http_error_check(e) ((e) == SOAP_HTTP_ERROR || (e) == SOAP_NO_DATA || ((e) >= SOAP_GET_METHOD && (e) <= SOAP_HTTP_METHOD) || ((e) >= 100 && (e) < 600))
+
+/* gSOAP HTTP response status codes 100 to 599 are reserved */
+
+/* Codes 600 to 999 are user definable */
+
+/* Exceptional gSOAP HTTP server response status codes >= 1000 */
+
+#define SOAP_STOP 1000 /* No HTTP response */
+#define SOAP_FORM 1001 /* Form request/response */
+#define SOAP_HTML 1002 /* Custom HTML response */
+#define SOAP_FILE 1003 /* Custom file-based response */
+
+/* gSOAP HTTP method codes (client) */
+
+#define SOAP_POST 2000 /* POST request */
+#define SOAP_POST_FILE 2001 /* Custom file-based POST request */
+#define SOAP_GET 2002 /* GET request */
+
+/* gSOAP DIME */
+
+#define SOAP_DIME_CF 0x01
+#define SOAP_DIME_ME 0x02
+#define SOAP_DIME_MB 0x04
+#define SOAP_DIME_VERSION 0x08 /* DIME version 1 */
+#define SOAP_DIME_MEDIA 0x10
+#define SOAP_DIME_ABSURI 0x20
+
+/* gSOAP ZLIB */
+
+#define SOAP_ZLIB_NONE 0x00
+#define SOAP_ZLIB_DEFLATE 0x01
+#define SOAP_ZLIB_INFLATE 0x02
+#define SOAP_ZLIB_GZIP 0x02
+
+/* gSOAP transport, connection, and content encoding modes */
+
+typedef soap_int32 soap_mode;
+
+#define SOAP_IO 0x00000003 /* IO mask */
+#define SOAP_IO_FLUSH 0x00000000 /* flush output immediately, no buffering */
+#define SOAP_IO_BUFFER 0x00000001 /* buffer output in packets of size SOAP_BUFLEN */
+#define SOAP_IO_STORE 0x00000002 /* store entire output to determine length for transport */
+#define SOAP_IO_CHUNK 0x00000003 /* use HTTP chunked transfer AND buffer packets */
+
+#define SOAP_IO_UDP 0x00000004 /* TCP or UDP */
+#define SOAP_IO_LENGTH 0x00000008 /* calc message length (internal) */
+#define SOAP_IO_KEEPALIVE 0x00000010 /* keep connection alive */
+
+#define SOAP_ENC 0x00000FFF /* IO and ENC mask */
+#define SOAP_ENC_LATIN 0x00000020 /* in: accept iso-8859-1 */
+#define SOAP_ENC_XML 0x00000040 /* out: plain XML encoding, no HTTP header */
+#define SOAP_ENC_DIME 0x00000080
+#define SOAP_ENC_MIME 0x00000100
+#define SOAP_ENC_MTOM 0x00000200
+#define SOAP_ENC_ZLIB 0x00000400
+#define SOAP_ENC_SSL 0x00000800
+
+#define SOAP_XML_STRICT 0x00001000 /* in: strict validation */
+#define SOAP_XML_INDENT 0x00002000 /* out: emit indented XML */
+#define SOAP_XML_IGNORENS 0x00004000 /* in: ignore namespaces */
+#define SOAP_XML_DEFAULTNS 0x00008000 /* out: emit xmlns="..." */
+#define SOAP_XML_CANONICAL 0x00010000 /* out: excC14N canonical XML */
+#define SOAP_XML_TREE 0x00020000 /* out: XML tree (no id/ref) */
+#define SOAP_XML_GRAPH 0x00040000 /* see DOM manual */
+#define SOAP_XML_NIL 0x00080000 /* out: NULLs as xsi:nil */
+
+#define SOAP_C_NOIOB 0x00100000 /* don't fault on array index out of bounds (just ignore) */
+#define SOAP_C_UTFSTRING 0x00200000 /* (de)serialize strings with UTF8 content */
+#define SOAP_C_MBSTRING 0x00400000 /* (de)serialize strings with multi-byte content */
+#define SOAP_C_NILSTRING 0x00800000 /* serialize empty strings as nil (omitted) */
+
+#define SOAP_XML_DOM 0x01000000
+
+#define SOAP_DOM_TREE 0x02000000
+#define SOAP_DOM_NODE 0x04000000
+#define SOAP_DOM_ASIS 0x08000000
+
+#define SOAP_MIME_POSTCHECK 0x10000000 /* MIME flag (internal) */
+
+#define SOAP_XML_SEC 0x80000000 /* reserved for WS security */
+
+/* WITH_XMLNS backward compatibility: always use XML default namespaces */
+#ifdef WITH_XMLNS
+# define SOAP_IO_DEFAULT (SOAP_IO_FLUSH | SOAP_XML_DEFAULTNS)
+#else
+# define SOAP_IO_DEFAULT SOAP_IO_FLUSH
+#endif
+
+/* SSL client/server authentication settings */
+
+#define SOAP_SSL_NO_AUTHENTICATION 0x00 /* for testing purposes */
+#define SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION 0x01 /* client requires server to authenticate */
+#define SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION 0x02 /* server requires client to authenticate */
+#define SOAP_SSL_SKIP_HOST_CHECK 0x04 /* client does not check the common name of the host in certificate */
+#define SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE 0x08 /* client does not check the expiration date of the host certificate */
+#define SOAP_SSL_NO_DEFAULT_CA_PATH 0x10 /* don't use default_verify_paths */
+#define SOAP_SSL_RSA 0x20 /* use RSA */
+#define SOAP_SSLv3 0x40 /* SSL v3 only */
+#define SOAP_TLSv1 0x80 /* TLS v1 only */
+#define SOAP_SSLv3_TLSv1 0x00 /* SSL v3 and TLS v1 support by default (no SSL v1/v2) */
+
+#define SOAP_SSL_DEFAULT (SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_SSLv3_TLSv1)
+
+/* state */
+
+#define SOAP_NONE 0
+#define SOAP_INIT 1
+#define SOAP_COPY 2
+
+#define soap_check_state(soap) (!(soap) || ((soap)->state != SOAP_INIT && (soap)->state != SOAP_COPY))
+
+/* part */
+
+#define SOAP_BEGIN 0
+#define SOAP_IN_ENVELOPE 2
+#define SOAP_IN_HEADER 3
+#define SOAP_END_HEADER 4
+#define SOAP_NO_BODY 5
+#define SOAP_IN_BODY 6
+#define SOAP_END_BODY 7
+#define SOAP_END_ENVELOPE 8
+#define SOAP_END 9
+#define SOAP_BEGIN_SECURITY 10
+#define SOAP_IN_SECURITY 11
+#define SOAP_END_SECURITY 12
+
+/* DEBUG macros */
+
+#ifndef WITH_LEAN
+# ifdef DEBUG
+# ifndef SOAP_DEBUG
+# define SOAP_DEBUG
+# endif
+# ifndef SOAP_MEM_DEBUG
+# define SOAP_MEM_DEBUG
+# endif
+# endif
+#endif
+
+#ifdef SOAP_MEM_DEBUG
+# ifndef SOAP_MALLOC
+# define SOAP_MALLOC(soap, size) soap_track_malloc(soap, __FILE__, __LINE__, size)
+# endif
+# ifndef SOAP_FREE
+# define SOAP_FREE(soap, ptr) soap_track_free(soap, __FILE__, __LINE__, ptr)
+# endif
+#endif
+
+#ifndef SOAP_MALLOC /* use libc malloc */
+# define SOAP_MALLOC(soap, size) malloc(size)
+#endif
+
+#ifndef SOAP_FREE /* use libc free */
+# define SOAP_FREE(soap, ptr) free(ptr)
+#endif
+
+#ifndef SOAP_NEW /* use C++ new operator */
+# if __GNUC__ < 2
+# define SOAP_NEW(type) new type /* old form w/o parenthesis */
+# else
+# define SOAP_NEW(type) new (type) /* with parenthesis */
+# endif
+#endif
+
+#ifndef SOAP_NEW_COPY /* use C++ new operator for ::copy() */
+# define SOAP_NEW_COPY(clas) new clas
+#endif
+
+#ifndef SOAP_DELETE /* use C++ delete operator */
+# define SOAP_DELETE(obj) delete obj
+#endif
+
+#ifndef SOAP_DELETE_ARRAY /* use C++ delete[] operator */
+# define SOAP_DELETE_ARRAY(obj) delete[] obj
+#endif
+
+#ifdef SOAP_DEBUG
+# ifndef SOAP_MESSAGE
+# define SOAP_MESSAGE fprintf
+# endif
+# ifndef DBGLOG
+# define DBGLOG(DBGFILE, CMD) \
+{ if (soap)\
+ { if (!soap->fdebug[SOAP_INDEX_##DBGFILE])\
+ soap_open_logfile((struct soap*)soap, SOAP_INDEX_##DBGFILE);\
+ if (soap->fdebug[SOAP_INDEX_##DBGFILE])\
+ { FILE *fdebug = soap->fdebug[SOAP_INDEX_##DBGFILE];\
+ CMD;\
+ fflush(fdebug);\
+ }\
+ }\
+}
+# endif
+# ifndef DBGMSG
+# define DBGMSG(DBGFILE, MSG, LEN) \
+{ if (soap)\
+ { if (!soap->fdebug[SOAP_INDEX_##DBGFILE])\
+ soap_open_logfile((struct soap*)soap, SOAP_INDEX_##DBGFILE);\
+ if (soap->fdebug[SOAP_INDEX_##DBGFILE])\
+ { fwrite((MSG), 1, (LEN), soap->fdebug[SOAP_INDEX_##DBGFILE]);\
+ fflush(soap->fdebug[SOAP_INDEX_##DBGFILE]);\
+ }\
+ }\
+}
+# endif
+# ifndef DBGFUN
+# define DBGFUN(FNAME) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): %s()\n", __FILE__, __LINE__, FNAME))
+# define DBGFUN1(FNAME, FMT, ARG) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): %s("FMT")\n", __FILE__, __LINE__, FNAME, (ARG)))
+# define DBGFUN2(FNAME, FMT1, ARG1, FMT2, ARG2) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): %s("FMT1", "FMT2")\n", __FILE__, __LINE__, FNAME, (ARG1), (ARG2)))
+# define DBGFUN3(FNAME, FMT1, ARG1, FMT2, ARG2, FMT3, ARG3) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): %s("FMT1", "FMT2", "FMT3")\n", __FILE__, __LINE__, FNAME, (ARG1), (ARG2), (ARG3)))
+# endif
+# ifndef DBGHEX
+# define DBGHEX(DBGFILE, MSG, LEN) \
+{ if (soap)\
+ { if (!soap->fdebug[SOAP_INDEX_##DBGFILE])\
+ soap_open_logfile(soap, SOAP_INDEX_##DBGFILE);\
+ if (soap->fdebug[SOAP_INDEX_##DBGFILE])\
+ { int i; char *s;\
+ for (s = (char*)(MSG), i = (LEN); i; i--)\
+ fprintf(soap->fdebug[SOAP_INDEX_##DBGFILE], "%2.2X ", (int)*s++&0xFF);\
+ fflush(soap->fdebug[SOAP_INDEX_##DBGFILE]);\
+ }\
+ }\
+}
+# endif
+#else
+# define DBGLOG(DBGFILE, CMD)
+# define DBGMSG(DBGFILE, MSG, LEN)
+# define DBGFUN(FNAME)
+# define DBGFUN1(FNAME, FMT, ARG)
+# define DBGFUN2(FNAME, FMT1, ARG1, FMT2, ARG2)
+# define DBGFUN3(FNAME, FMT1, ARG1, FMT2, ARG2, FMT3, ARG3)
+# define DBGHEX(DBGFILE, MSG, LEN)
+#endif
+
+/* UCS-4 requires 32 bits (0-7FFFFFFF, the sign bit is used by gSOAP to distinguish XML entities) */
+typedef soap_int32 soap_wchar;
+
+/* namespace table row */
+struct Namespace
+{ const char *id;
+ const char *ns;
+ const char *in;
+ char *out;
+};
+
+/* namespace stack */
+struct soap_nlist
+{ struct soap_nlist *next;
+ unsigned int level; /* nesting depth level */
+ short index; /* corresponding entry in ns mapping table */
+ const char *ns; /* only set when parsed ns URI is not in the ns mapping table */
+ char id[1]; /* the actual string value flows into the allocated region below this struct */
+};
+
+/* block stack for nested block allocations */
+struct soap_blist
+{ struct soap_blist *next;
+ char *ptr;
+ size_t size;
+};
+
+/* array layout */
+struct soap_array
+{ void *__ptr;
+ int __size;
+};
+
+/* pointer serialization management */
+struct soap_plist
+{ struct soap_plist *next;
+ const void *ptr;
+ const struct soap_array *array;
+ int type;
+ int id;
+ char mark1;
+ char mark2;
+};
+
+/* block allocation for pointer serialization management */
+struct soap_pblk
+{ struct soap_pblk *next;
+ struct soap_plist plist[SOAP_PTRBLK];
+};
+
+#ifdef SOAP_MEM_DEBUG
+/* malloc/free tracking for debugging */
+struct soap_mlist
+{ struct soap_mlist *next;
+ const void *ptr;
+ const char *file;
+ int line;
+ short live;
+};
+#endif
+
+/* class allocation list */
+struct soap_clist
+{ struct soap_clist *next;
+ void *ptr;
+ int type;
+ int size;
+ int (*fdelete)(struct soap_clist*);
+};
+
+/* attributes */
+struct soap_attribute
+{ struct soap_attribute *next;
+ short flag; /* soap_set_attr: 1 = normal, 2 = utf content */
+ char *value;
+ size_t size;
+ char *ns;
+ short visible;
+ char name[1]; /* the actual name string flows into the allocated region below this struct */
+};
+
+#ifndef WITH_LEAN
+struct soap_cookie
+{ struct soap_cookie *next;
+ char *name;
+ char *value;
+ char *domain;
+ char *path;
+ time_t expire; /* client-side: local time to expire */
+ long maxage; /* server-side: seconds to expire */
+ unsigned int version;
+ short secure;
+ short session; /* server-side */
+ short env; /* server-side: got cookie from client and should not be (re)send */
+ short modified; /* server-side: client cookie was modified and should be send */
+};
+#endif
+
+SOAP_FMAC1 struct soap_multipart* SOAP_FMAC2 soap_next_multipart(struct soap_multipart*);
+
+#ifdef __cplusplus
+
+class soap_multipart_iterator
+{ public:
+ struct soap_multipart *content;
+ bool operator==(const soap_multipart_iterator& iter) const
+ { return (bool)(content == iter.content); }
+ bool operator!=(const soap_multipart_iterator& iter) const
+ { return (bool)(content != iter.content); }
+ struct soap_multipart &operator*() const
+ { return *content; }
+ soap_multipart_iterator &operator++()
+ { content = soap_next_multipart(content); return *this; }
+ soap_multipart_iterator() : content(NULL)
+ { }
+ soap_multipart_iterator(struct soap_multipart *p) : content(p)
+ { }
+};
+#endif
+
+#ifndef WITH_LEANER
+struct soap_dime
+{ size_t count;
+ size_t size;
+ size_t chunksize;
+ size_t buflen;
+ char flags;
+ char *ptr;
+ const char *id;
+ const char *type;
+ const char *options;
+ struct soap_multipart *list; /* list of DIME attachments received */
+ struct soap_multipart *first, *last; /* temporary in/out queue */
+#ifdef __cplusplus
+ soap_multipart_iterator begin()
+ { soap_multipart_iterator iter(list); return iter; };
+ soap_multipart_iterator end()
+ { soap_multipart_iterator iter(NULL); return iter; };
+#endif
+};
+#endif
+
+#ifndef WITH_LEANER
+struct soap_mime
+{ char *boundary; /* MIME boundary */
+ const char *start; /* MIME start ID */
+ struct soap_multipart *list; /* list of MIME attachments received */
+ struct soap_multipart *first, *last; /* temporary in/out queue */
+#ifdef __cplusplus
+ soap_multipart_iterator begin()
+ { soap_multipart_iterator iter(list); return iter; };
+ soap_multipart_iterator end()
+ { soap_multipart_iterator iter(NULL); return iter; };
+#endif
+};
+#endif
+
+#ifndef WITH_LEANER
+/* RFC2045 MIME content transfer encodings */
+enum soap_mime_encoding
+{ SOAP_MIME_NONE,
+ SOAP_MIME_7BIT,
+ SOAP_MIME_8BIT,
+ SOAP_MIME_BINARY,
+ SOAP_MIME_QUOTED_PRINTABLE,
+ SOAP_MIME_BASE64,
+ SOAP_MIME_IETF_TOKEN,
+ SOAP_MIME_X_TOKEN
+};
+#endif
+
+#ifndef WITH_LEANER
+/* DIME/MIME multipart list */
+struct soap_multipart
+{ struct soap_multipart *next;
+ char *ptr; /* points to raw data content */
+ size_t size; /* size of data content */
+ const char *id; /* DIME/MIME content ID or form data name */
+ const char *type; /* DIME/MIME type (MIME type format) */
+ const char *options; /* DIME options */
+ enum soap_mime_encoding encoding; /* MIME Content-Transfer-Encoding */
+ const char *location; /* MIME Content-Location (optional) */
+ const char *description; /* MIME Content-Description (optional) */
+#ifdef __cplusplus
+ typedef soap_multipart_iterator iterator;
+#endif
+};
+#endif
+
+#ifndef WITH_LEANER
+/* attachment DIME and MTOM XOP forwarding */
+struct soap_xlist
+{ struct soap_xlist *next;
+ unsigned char **ptr;
+ int *size;
+ char *id;
+ char **type;
+ char **options;
+};
+#endif
+
+/******************************************************************************/
+
+#ifndef WITH_LEANER
+#ifdef __cplusplus
+class soap_dom_attribute_iterator
+{ public:
+ struct soap_dom_attribute *att;
+ const char *nstr;
+ const char *name;
+ bool operator==(const soap_dom_attribute_iterator&) const;
+ bool operator!=(const soap_dom_attribute_iterator&) const;
+ struct soap_dom_attribute &operator*() const;
+ soap_dom_attribute_iterator &operator++();
+ soap_dom_attribute_iterator();
+ soap_dom_attribute_iterator(struct soap_dom_attribute*);
+ ~soap_dom_attribute_iterator();
+};
+#endif
+#endif
+
+#ifndef WITH_LEANER
+struct soap_dom_attribute
+{ struct soap_dom_attribute *next;
+ const char *nstr;
+ char *name;
+ char *data;
+ wchar_t *wide;
+ struct soap *soap;
+#ifdef __cplusplus
+ typedef soap_dom_attribute_iterator iterator;
+ struct soap_dom_attribute &set(const char *nstr, const char *name); /* set namespace and name */
+ struct soap_dom_attribute &set(const char *data); /* set data */
+ soap_dom_attribute_iterator begin();
+ soap_dom_attribute_iterator end();
+ soap_dom_attribute_iterator find(const char *nstr, const char *name);
+ void unlink();
+ soap_dom_attribute();
+ soap_dom_attribute(struct soap *soap);
+ soap_dom_attribute(struct soap *soap, const char *nstr, const char *name, const char *data);
+ ~soap_dom_attribute();
+#endif
+};
+#endif
+
+#ifndef WITH_LEANER
+#ifdef __cplusplus
+class soap_dom_element_iterator
+{ public:
+ struct soap_dom_element *elt;
+ const char *nstr;
+ const char *name;
+ int type;
+ bool operator==(const soap_dom_element_iterator&) const;
+ bool operator!=(const soap_dom_element_iterator&) const;
+ struct soap_dom_element &operator*() const;
+ soap_dom_element_iterator &operator++();
+ soap_dom_element_iterator();
+ soap_dom_element_iterator(struct soap_dom_element*);
+ ~soap_dom_element_iterator();
+};
+#endif
+#endif
+
+#ifndef WITH_LEANER
+struct soap_dom_element
+{ struct soap_dom_element *next; /* next sibling */
+ struct soap_dom_element *prnt; /* parent */
+ struct soap_dom_element *elts; /* list of child elements */
+ struct soap_dom_attribute *atts; /* list of attributes */
+ const char *nstr; /* namespace string */
+ char *name; /* element tag name */
+ char *data; /* element content data (with SOAP_C_UTFSTRING flag set) */
+ wchar_t *wide; /* element content data */
+ int type; /* optional: serialized C/C++ data type */
+ void *node; /* optional: pointer to serialized C/C++ data */
+ char *head; /* leading content before start tag */
+ char *tail; /* leading content before end tag */
+ struct soap *soap; /* soap context that manages this node */
+#ifdef __cplusplus
+ typedef soap_dom_element_iterator iterator;
+ struct soap_dom_element &set(const char *nstr, const char *name);
+ struct soap_dom_element &set(const char *data);
+ struct soap_dom_element &set(void *node, int type);
+ struct soap_dom_element &add(struct soap_dom_element*);
+ struct soap_dom_element &add(struct soap_dom_element&);
+ struct soap_dom_element &add(struct soap_dom_attribute*);
+ struct soap_dom_element &add(struct soap_dom_attribute&);
+ soap_dom_element_iterator begin();
+ soap_dom_element_iterator end();
+ soap_dom_element_iterator find(const char *nstr, const char *name);
+ soap_dom_element_iterator find(int type);
+ void unlink();
+ soap_dom_element();
+ soap_dom_element(struct soap *soap);
+ soap_dom_element(struct soap *soap, const char *nstr, const char *name);
+ soap_dom_element(struct soap *soap, const char *nstr, const char *name, const char *data);
+ soap_dom_element(struct soap *soap, const char *nstr, const char *name, void *node, int type);
+ ~soap_dom_element();
+#endif
+};
+SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_dom_next_element(struct soap_dom_element *elt);
+SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_dom_next_attribute(struct soap_dom_attribute *att);
+#endif
+
+#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
+}
+extern std::ostream &operator<<(std::ostream&, const struct soap_dom_element&);
+extern std::istream &operator>>(std::istream&, struct soap_dom_element&);
+extern "C" {
+#endif
+
+/******************************************************************************/
+
+#ifdef WIN32
+# ifdef SOAP_STD_EXPORTS
+# define SOAP_STD_API __declspec(dllexport)
+# else
+# define SOAP_STD_API
+# endif
+#else
+# define SOAP_STD_API
+#endif
+
+struct SOAP_STD_API soap
+{ short state; /* 0 = uninitialized, 1 = initialized, 2 = copy of another soap struct */
+ short version; /* 1 = SOAP1.1 and 2 = SOAP1.2 (set automatically from namespace URI in nsmap table) */
+ soap_mode mode;
+ soap_mode imode;
+ soap_mode omode;
+ const char *float_format; /* user-definable format string for floats (<1024 chars) */
+ const char *double_format; /* user-definable format string for doubles (<1024 chars) */
+ const char *dime_id_format; /* user-definable format string for integer DIME id (<SOAP_TAGLEN chars) */
+ const char *http_version; /* HTTP version used "1.0" or "1.1" */
+ const char *http_content; /* optional custom response content type (with SOAP_FILE) */
+ const char *encodingStyle; /* default = NULL which means that SOAP encoding is used */
+ const char *actor; /* SOAP-ENV:actor or role attribute value */
+ const char *lang; /* xml:lang attribute value of SOAP-ENV:Text */
+ int recv_timeout; /* when > 0, gives socket recv timeout in seconds, < 0 in usec */
+ int send_timeout; /* when > 0, gives socket send timeout in seconds, < 0 in usec */
+ int connect_timeout; /* when > 0, gives socket connect() timeout in seconds, < 0 in usec */
+ int accept_timeout; /* when > 0, gives socket accept() timeout in seconds, < 0 in usec */
+#if defined(WITH_OPENSSL) && defined(KMS_SERVER)
+ /* Sun customization for Ultra 2 KMS Server */
+ int ssl_accept_timeout; /* default 10s unless overridden by this field, specified in seconds, time in SSL_Accept() */
+#endif
+ int socket_flags; /* socket recv() and send() flags, e.g. set to MSG_NOSIGNAL to disable sigpipe */
+ int connect_flags; /* connect() SOL_SOCKET sockopt flags, e.g. set to SO_DEBUG to debug socket */
+ int bind_flags; /* bind() SOL_SOCKET sockopt flags, e.g. set to SO_REUSEADDR to enable reuse */
+ int accept_flags; /* accept() SOL_SOCKET sockopt flags */
+ unsigned short linger_time; /* linger time for SO_LINGER option */
+ const struct Namespace *namespaces; /* Pointer to global namespace mapping table */
+ struct Namespace *local_namespaces; /* Local namespace mapping table */
+ struct soap_nlist *nlist; /* namespace stack */
+ struct soap_blist *blist; /* block allocation stack */
+ struct soap_clist *clist; /* class instance allocation list */
+ void *alist; /* memory allocation (malloc) list */
+ struct soap_ilist *iht[SOAP_IDHASH];
+ struct soap_plist *pht[SOAP_PTRHASH];
+ struct soap_pblk *pblk; /* plist block allocation */
+ short pidx; /* plist block allocation */
+ struct SOAP_ENV__Header *header;
+ struct SOAP_ENV__Fault *fault;
+ int idnum;
+ void *user; /* to pass user-defined data */
+ struct soap_plugin *plugins; /* linked list of plug-in data */
+ const char *userid; /* HTTP Basic authorization userid */
+ const char *passwd; /* HTTP Basic authorization passwd */
+ int (*fpost)(struct soap*, const char*, const char*, int, const char*, const char*, size_t);
+ int (*fget)(struct soap*);
+ int (*fput)(struct soap*);
+ int (*fdel)(struct soap*);
+ int (*fhead)(struct soap*);
+ int (*fform)(struct soap*);
+ int (*fposthdr)(struct soap*, const char*, const char*);
+ int (*fresponse)(struct soap*, int, size_t);
+ int (*fparse)(struct soap*);
+ int (*fparsehdr)(struct soap*, const char*, const char*);
+ int (*fheader)(struct soap*);
+ int (*fresolve)(struct soap*, const char*, struct in_addr* inaddr);
+ int (*fconnect)(struct soap*, const char*, const char*, int);
+ int (*fdisconnect)(struct soap*);
+ int (*fclosesocket)(struct soap*, SOAP_SOCKET);
+ int (*fshutdownsocket)(struct soap*, SOAP_SOCKET, int);
+ SOAP_SOCKET (*fopen)(struct soap*, const char*, const char*, int);
+ SOAP_SOCKET (*faccept)(struct soap*, SOAP_SOCKET, struct sockaddr*, int *n);
+ int (*fclose)(struct soap*);
+ int (*fsend)(struct soap*, const char*, size_t);
+ size_t (*frecv)(struct soap*, char*, size_t);
+ int (*fpoll)(struct soap*);
+ void (*fseterror)(struct soap*, const char **c, const char **s);
+ int (*fignore)(struct soap*, const char*);
+ int (*fserveloop)(struct soap*);
+ void *(*fplugin)(struct soap*, const char*);
+ void *(*fmalloc)(struct soap*, size_t);
+#ifndef WITH_LEANER
+ int (*fprepareinitsend)(struct soap*);
+ int (*fprepareinitrecv)(struct soap*);
+ int (*fpreparesend)(struct soap*, const char*, size_t);
+ int (*fpreparerecv)(struct soap*, const char*, size_t);
+ int (*fpreparefinalsend)(struct soap*);
+ int (*fpreparefinalrecv)(struct soap*);
+ void *(*fdimereadopen)(struct soap*, void*, const char*, const char*, const char*);
+ void *(*fdimewriteopen)(struct soap*, const char*, const char*, const char*);
+ void (*fdimereadclose)(struct soap*, void*);
+ void (*fdimewriteclose)(struct soap*, void*);
+ size_t (*fdimeread)(struct soap*, void*, char*, size_t);
+ int (*fdimewrite)(struct soap*, void*, const char*, size_t);
+ void *(*fmimereadopen)(struct soap*, void*, const char*, const char*, const char*);
+ void *(*fmimewriteopen)(struct soap*, void*, const char*, const char*, const char*, enum soap_mime_encoding);
+ void (*fmimereadclose)(struct soap*, void*);
+ void (*fmimewriteclose)(struct soap*, void*);
+ size_t (*fmimeread)(struct soap*, void*, char*, size_t);
+ int (*fmimewrite)(struct soap*, void*, const char*, size_t);
+#endif
+ SOAP_SOCKET master;
+ SOAP_SOCKET socket;
+#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
+ std::ostream *os;
+ std::istream *is;
+#else
+ void *os; /* preserve struct size */
+ void *is; /* preserve struct size */
+#endif
+#ifndef UNDER_CE
+ int sendfd;
+ int recvfd;
+#else
+ FILE *sendfd;
+ FILE *recvfd;
+#endif
+ size_t bufidx; /* index in soap.buf[] */
+ size_t buflen; /* length of soap.buf[] content */
+ soap_wchar ahead; /* parser lookahead */
+ short cdata; /* CDATA parser state */
+ short body; /* parsed XML element has a body or not */
+ unsigned int level; /* XML nesting level */
+ size_t count; /* message length counter */
+ size_t length; /* message length as set by HTTP header */
+ char *labbuf; /* look-aside buffer */
+ size_t lablen; /* look-aside buffer allocated length */
+ size_t labidx; /* look-aside buffer index to available part */
+ char buf[SOAP_BUFLEN];/* send and receive buffer */
+ char msgbuf[1024]; /* in/out buffer for HTTP/MIME headers >=1024 bytes */
+ char tmpbuf[1024]; /* in/out buffer for HTTP/MIME headers, simpleType values, element and attribute tag names, and DIME must be >=1024 bytes */
+ char tag[SOAP_TAGLEN];
+ char id[SOAP_TAGLEN];
+ char href[SOAP_TAGLEN];
+ char type[SOAP_TAGLEN];
+ char arrayType[SOAP_TAGLEN];
+ char arraySize[SOAP_TAGLEN];
+ char arrayOffset[SOAP_TAGLEN];
+ short other;
+ short position;
+ int positions[SOAP_MAXDIMS];
+ short root;
+ struct soap_attribute *attributes; /* attribute list */
+ short encoding; /* when set, output encodingStyle */
+ short mustUnderstand; /* a mustUnderstand element was parsed or is output */
+ short null; /* parsed XML is xsi:nil */
+ short ns; /* when not set, output full xmlns bindings */
+ short part; /* parsing state */
+ short alloced;
+ short peeked;
+ size_t chunksize;
+ size_t chunkbuflen;
+ char endpoint[SOAP_TAGLEN];
+ char path[SOAP_TAGLEN];
+ char host[SOAP_TAGLEN];
+ char *action;
+ char *authrealm; /* HTTP authentication realm */
+ char *prolog; /* XML declaration prolog */
+ unsigned long ip; /* IP number */
+ int port; /* port number */
+ short keep_alive; /* connection should be kept open */
+ short tcp_keep_alive; /* enable SO_KEEPALIVE */
+ unsigned int tcp_keep_idle; /* set TCP_KEEPIDLE */
+ unsigned int tcp_keep_intvl; /* set TCP_KEEPINTVL */
+ unsigned int tcp_keep_cnt; /* set TCP_KEEPCNT */
+ unsigned int max_keep_alive; /* maximum keep-alive session (default=100) */
+ const char *proxy_http_version;/* HTTP version of proxy "1.0" or "1.1" */
+ const char *proxy_host; /* Proxy Server host name */
+ int proxy_port; /* Proxy Server port (default = 8080) */
+ const char *proxy_userid; /* Proxy Authorization user name */
+ const char *proxy_passwd; /* Proxy Authorization password */
+ const char *proxy_from; /* X-Forwarding-For header returned by proxy */
+ int status; /* -1 when request, else error code to be returned by server */
+ int error;
+ int errmode;
+ int errnum;
+#ifndef WITH_LEANER
+ struct soap_dom_element *dom;
+ struct soap_dime dime;
+ struct soap_mime mime;
+ struct soap_xlist *xlist;
+#endif
+#if !defined(WITH_LEAN) || defined(SOAP_DEBUG)
+ const char *logfile[SOAP_MAXLOGS];
+ FILE *fdebug[SOAP_MAXLOGS];
+ struct soap_mlist *mht[SOAP_PTRHASH];
+#endif
+#ifndef WITH_LEAN
+ const char *wsuid; /* space-separated string of element tags */
+ const char *c14nexclude; /* space-separated string of prefixes */
+ struct soap_cookie *cookies;
+ const char *cookie_domain;
+ const char *cookie_path;
+ int cookie_max;
+#endif
+#ifndef WITH_NOIO
+ int ipv6_multicast_if; /* always include this to keep the soap struct size the same in v4 and v6 */
+ char* ipv4_multicast_if; /* always include this to keep the soap struct size the same in v4 and v6 */
+ int ipv4_multicast_ttl; /* multicast scope */
+#ifdef WITH_IPV6
+ struct sockaddr_storage peer; /* IPv6: set by soap_accept and by UDP recv */
+#else
+ struct sockaddr_in peer; /* IPv4: set by soap_connect/soap_accept and by UDP recv */
+#endif
+#endif
+ size_t peerlen;
+#if defined(WITH_OPENSSL) /* OpenSSL */
+ int (*fsslauth)(struct soap*);
+ int (*fsslverify)(int, X509_STORE_CTX*);
+ BIO *bio;
+ SSL *ssl;
+ SSL_CTX *ctx;
+ SSL_SESSION *session;
+#else /* No SSL/TLS */
+ void *fsslauth; /* dummy members, to preserve struct size */
+ void *fsslverify;
+ void *bio;
+ void *ssl;
+ void *ctx;
+ void *session;
+#endif
+ unsigned short ssl_flags;
+ const char *keyfile;
+ const char *password;
+ const char *dhfile;
+ const char *cafile;
+ const char *capath;
+ const char *crlfile;
+ const char *randfile;
+ char session_host[SOAP_TAGLEN];
+ int session_port;
+#ifdef WITH_C_LOCALE
+ locale_t c_locale; /* set to C locale by default */
+#else
+ void *c_locale;
+#endif
+#ifdef WITH_ZLIB
+ z_stream *d_stream; /* decompression stream */
+ uLong z_crc; /* internal gzip crc */
+#else
+ void *d_stream; /* dummy members, to preserve struct size */
+ soap_int32 z_crc;
+#endif
+ const char *z_dict; /* support for zlib static dictionaries */
+ unsigned int z_dict_len;
+ short zlib_state; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_INFLATE */
+ short zlib_in; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_GZIP */
+ short zlib_out; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_GZIP */
+ char *z_buf; /* buffer */
+ size_t z_buflen;
+ unsigned short z_level; /* compression level to be used (0=none, 1=fast to 9=best) */
+ float z_ratio_in; /* detected compression ratio compressed_length/length of inbound message */
+ float z_ratio_out; /* detected compression ratio compressed_length/length of outbound message */
+#ifdef WMW_RPM_IO /* VxWorks */
+ void *rpmreqid;
+#endif
+#ifdef __cplusplus
+ soap();
+ soap(soap_mode);
+ soap(soap_mode, soap_mode);
+ soap(const struct soap&);
+ virtual ~soap();
+#else
+ void (*dummy)();
+#endif
+};
+
+struct soap_code_map
+{ long code;
+ const char *string;
+};
+
+/* forwarding list */
+struct soap_flist
+{ struct soap_flist *next;
+ int type;
+ void *ptr;
+ unsigned int level;
+ size_t len;
+ void (*fcopy)(struct soap*, int, int, void*, size_t, const void*, size_t);
+};
+
+/* id-ref forwarding list */
+struct soap_ilist
+{ struct soap_ilist *next;
+ int type;
+ size_t size;
+ void *link;
+ void *copy;
+ struct soap_flist *flist;
+ void *ptr;
+ unsigned int level;
+ char id[1]; /* the actual id string value flows into the allocated region below this struct */
+};
+
+struct soap_plugin
+{ struct soap_plugin *next;
+ const char *id;
+ void *data;
+ int (*fcopy)(struct soap *soap, struct soap_plugin *dst, struct soap_plugin *src);
+ void (*fdelete)(struct soap *soap, struct soap_plugin *p); /* should delete fields of plugin only and not free(p) */
+};
+
+#ifndef WITH_NONAMESPACES
+extern SOAP_NMAC struct Namespace namespaces[];
+#endif
+
+#ifndef WITH_LEAN
+# define soap_get0(soap) (((soap)->bufidx>=(soap)->buflen && soap_recv(soap)) ? EOF : (unsigned char)(soap)->buf[(soap)->bufidx])
+# define soap_get1(soap) (((soap)->bufidx>=(soap)->buflen && soap_recv(soap)) ? EOF : (unsigned char)(soap)->buf[(soap)->bufidx++])
+#else
+soap_wchar soap_get0(struct soap*);
+soap_wchar soap_get1(struct soap*);
+#endif
+
+#define soap_revget1(soap) ((soap)->bufidx--)
+#define soap_unget(soap, c) ((soap)->ahead = c)
+#define soap_register_plugin(soap, plugin) soap_register_plugin_arg(soap, plugin, NULL)
+#define soap_imode(soap, n) ((soap)->mode = (soap)->imode = (n))
+#define soap_set_imode(soap, n) ((soap)->imode |= (n))
+#define soap_clr_imode(soap, n) ((soap)->imode &= ~(n))
+#define soap_omode(soap, n) ((soap)->mode = (soap)->omode = (n))
+#define soap_set_omode(soap, n) ((soap)->omode |= (n))
+#define soap_clr_omode(soap, n) ((soap)->omode &= ~(n))
+#define soap_set_mode(soap, n) ((soap)->imode |= (n), (soap)->omode |= (n))
+#define soap_clr_mode(soap, n) ((soap)->imode &= ~(n), (soap)->omode &= ~(n))
+#define soap_destroy(soap) soap_delete((soap), NULL)
+
+#ifdef HAVE_STRRCHR
+# define soap_strrchr(s, t) strrchr(s, t)
+#else
+ SOAP_FMAC1 char* SOAP_FMAC2 soap_strrchr(const char *s, int t);
+#endif
+
+#ifdef HAVE_STRTOL
+# define soap_strtol(s, t, b) strtol(s, t, b)
+#else
+ SOAP_FMAC1 long SOAP_FMAC2 soap_strtol(const char *s, char **t, int b);
+#endif
+
+#ifdef HAVE_STRTOUL
+# define soap_strtoul(s, t, b) strtoul(s, t, b)
+#else
+ SOAP_FMAC1 unsigned long SOAP_FMAC2 soap_strtoul(const char *s, char **t, int b);
+#endif
+
+#if defined(WITH_OPENSSL)
+# define soap_random soap_rand()
+SOAP_FMAC1 int SOAP_FMAC2 soap_rand(void);
+#elif defined(HAVE_RANDOM)
+# define soap_random (int)random()
+#else
+# define soap_random rand()
+#endif
+
+#ifdef WITH_NOIDREF
+# define soap_embedded(s, p, t) (0)
+# define soap_id_lookup(s, i, p, t, n, k) (p)
+# define soap_id_forward(s, h, p, len, st, tt, n, k, fc) (p)
+# define soap_reference(s, a, t) (1)
+# define soap_array_reference(s, p, a, n, t) (1)
+# define soap_embed(s, p, a, n, t, pp) (0)
+# define soap_embedded_id(s, i, p, t) (i)
+# define soap_is_embedded(s, p) (0)
+# define soap_is_single(s, p) (1)
+# define soap_lookup_type(s, i) (0)
+# define soap_getindependent(s) (0)
+# define soap_putindependent(s) (0)
+# define soap_getelement(s, n) (n)
+# define soap_putelement(s, p, t, i, n) (0)
+# define soap_markelement(s, p, n) (0)
+#endif
+
+SOAP_FMAC1 void SOAP_FMAC2 soap_header(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_fault(struct soap*);
+SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultcode(struct soap*);
+SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultsubcode(struct soap*);
+SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultstring(struct soap*);
+SOAP_FMAC1 const char** SOAP_FMAC2 soap_faultdetail(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_serializeheader(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putheader(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getheader(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_serializefault(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putfault(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getfault(struct soap*);
+
+SOAP_FMAC1 void SOAP_FMAC2 soap_ssl_init();
+SOAP_FMAC1 int SOAP_FMAC2 soap_poll(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_connect_command(struct soap*, int, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_connect(struct soap*, const char*, const char*);
+SOAP_FMAC1 SOAP_SOCKET SOAP_FMAC2 soap_bind(struct soap*, const char*, int, int);
+SOAP_FMAC1 SOAP_SOCKET SOAP_FMAC2 soap_accept(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_accept(struct soap*);
+SOAP_FMAC1 const char * SOAP_FMAC2 soap_ssl_error(struct soap*, int);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_server_context(struct soap*, unsigned short, const char*, const char*, const char*, const char*, const char*, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_client_context(struct soap*, unsigned short, const char*, const char*, const char*, const char*, const char*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_puthttphdr(struct soap*, int status, size_t count);
+
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_get_header_attribute(struct soap*, const char*, const char*);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_decode_key(char*, size_t, const char*);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_decode_val(char*, size_t, const char*);
+
+SOAP_FMAC1 size_t SOAP_FMAC2 soap_hash(const char*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_endpoint(struct soap*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_flush_raw(struct soap*, const char*, size_t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_flush(struct soap*);
+SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_get(struct soap*);
+SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_getchar(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_tag_cmp(const char*, const char*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_fault(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_sender_fault(struct soap*, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_sender_fault_subcode(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_receiver_fault(struct soap*, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_receiver_fault_subcode(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_set_sender_error(struct soap*, const char*, const char*, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_set_receiver_error(struct soap*, const char*, const char*, int);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_send_raw(struct soap*, const char*, size_t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_recv_raw(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_recv(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_send(struct soap*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_send2(struct soap*, const char*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_send3(struct soap*, const char*, const char*, const char*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_pututf8(struct soap*, unsigned long);
+SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_getutf8(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_putbase64(struct soap*, const unsigned char*, int);
+SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_getbase64(struct soap*, int*, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_puthex(struct soap*, const unsigned char*, int);
+SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_gethex(struct soap*, int*);
+
+#ifndef WITH_LEANER
+SOAP_FMAC1 int SOAP_FMAC2 soap_xop_forward(struct soap*, unsigned char**, int*, char**, char**, char**);
+SOAP_FMAC1 int SOAP_FMAC2 soap_dime_forward(struct soap*, unsigned char**, int*, char**, char**, char**);
+#endif
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_lookup_id(struct soap*, void *p, int t, struct soap_plist**);
+SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_lookup(struct soap*, const void *p, int t, struct soap_plist**);
+SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_enter(struct soap*, const void *p, const struct soap_array *a, int n, int t, struct soap_plist**);
+SOAP_FMAC1 int SOAP_FMAC2 soap_array_pointer_lookup(struct soap*, const void *p, const struct soap_array *a, int n, int t, struct soap_plist**);
+SOAP_FMAC1 int SOAP_FMAC2 soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type);
+SOAP_FMAC1 struct soap_ilist* SOAP_FMAC2 soap_lookup(struct soap*, const char*);
+SOAP_FMAC1 struct soap_ilist* SOAP_FMAC2 soap_enter(struct soap*, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_resolve(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_embedded(struct soap*, const void *p, int t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_reference(struct soap*, const void *p, int t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_array_reference(struct soap*, const void *p, const struct soap_array *a, int n, int t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_embedded_id(struct soap*, int id, const void *p, int t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_is_embedded(struct soap*, struct soap_plist*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_is_single(struct soap*, struct soap_plist*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_embedded(struct soap*, struct soap_plist*);
+#endif
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_begin_count(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_end_count(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_begin_send(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_end_send(struct soap*);
+
+SOAP_FMAC1 const struct soap_code_map* SOAP_FMAC2 soap_code(const struct soap_code_map*, const char*);
+SOAP_FMAC1 long SOAP_FMAC2 soap_code_int(const struct soap_code_map*, const char*, long);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_code_str(const struct soap_code_map*, long);
+SOAP_FMAC1 long SOAP_FMAC2 soap_code_bits(const struct soap_code_map*, const char*);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_code_list(struct soap*, const struct soap_code_map*, long);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_getline(struct soap*, char*, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_begin_recv(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_end_recv(struct soap*);
+
+SOAP_FMAC1 void* SOAP_FMAC2 soap_malloc(struct soap*, size_t);
+SOAP_FMAC1 void SOAP_FMAC2 soap_dealloc(struct soap*, void*);
+SOAP_FMAC1 struct soap_clist * SOAP_FMAC2 soap_link(struct soap*, void*, int, int, int (*fdelete)(struct soap_clist*));
+SOAP_FMAC1 void SOAP_FMAC2 soap_unlink(struct soap*, const void*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_free_temp(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_del(struct soap*);
+
+SOAP_FMAC1 void* SOAP_FMAC2 soap_track_malloc(struct soap*, const char*, int, size_t);
+SOAP_FMAC1 void SOAP_FMAC2 soap_track_free(struct soap*, const char*, int, void*);
+
+#ifndef WITH_NOIDREF
+SOAP_FMAC1 int SOAP_FMAC2 soap_lookup_type(struct soap*, const char *id);
+SOAP_FMAC1 void* SOAP_FMAC2 soap_id_lookup(struct soap*, const char *id, void **p, int t, size_t n, unsigned int k);
+SOAP_FMAC1 void* SOAP_FMAC2 soap_id_forward(struct soap*, const char *id, void *p, size_t len, int st, int tt, size_t n, unsigned int k, void(*fcopy)(struct soap*, int, int, void*, size_t, const void*, size_t));
+#endif
+SOAP_FMAC1 void* SOAP_FMAC2 soap_id_enter(struct soap*, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*));
+SOAP_FMAC1 void SOAP_FMAC2 soap_fcopy(struct soap *soap, int st, int tt, void *p, size_t, const void *q, size_t n);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_size(const int *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getoffsets(const char *, const int *, int *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getsize(const char *, const char *, int *);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getsizes(const char *, int *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getposition(const char *, int *);
+
+SOAP_FMAC1 char* SOAP_FMAC2 soap_putsize(struct soap*, const char *, int);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_putsizesoffsets(struct soap*, const char *, const int *, const int *, int);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_putsizes(struct soap*, const char *, const int *, int);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_putoffset(struct soap*, int);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_putoffsets(struct soap*, const int *, int);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_closesock(struct soap*);
+
+SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_new(void);
+SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_new1(soap_mode);
+SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_new2(soap_mode, soap_mode);
+SOAP_FMAC1 void SOAP_FMAC2 soap_free(struct soap*);
+SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_copy(const struct soap*);
+SOAP_FMAC1 struct soap *SOAP_FMAC2 soap_copy_context(struct soap*, const struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_copy_stream(struct soap*, struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_free_stream(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_init(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_init1(struct soap*, soap_mode);
+SOAP_FMAC1 void SOAP_FMAC2 soap_init2(struct soap*, soap_mode, soap_mode);
+SOAP_FMAC1 void SOAP_FMAC2 soap_done(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_cleanup(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_begin(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_end(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_delete(struct soap*, void*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_delegate_deletion(struct soap*, struct soap*);
+
+/* API functions available with DEBUG or SOAP_DEBUG defined: */
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_recv_logfile(struct soap*, const char*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_sent_logfile(struct soap*, const char*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_test_logfile(struct soap*, const char*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_close_logfiles(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_open_logfile(struct soap*, int);
+/* */
+
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_value(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_match_tag(struct soap*, const char*, const char *);
+SOAP_FMAC1 int SOAP_FMAC2 soap_match_array(struct soap*, const char*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_element(struct soap*, const char*, int, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_begin_out(struct soap*, const char *tag, int id, const char *type);
+SOAP_FMAC1 int SOAP_FMAC2 soap_array_begin_out(struct soap*, const char *tag, int id, const char *type, const char *offset);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_ref(struct soap*, const char *tag, int id, int href);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_href(struct soap*, const char *tag, int id, const char *ref, const char *val);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_null(struct soap*, const char *tag, int id, const char *type);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_id(struct soap*, const char *tag, int id, const void *p, const struct soap_array *a, int d, const char *type, int n);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_result(struct soap*, const char *tag);
+SOAP_FMAC1 void SOAP_FMAC2 soap_check_result(struct soap*, const char *tag);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_end_out(struct soap*, const char *tag);
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_start_end_out(struct soap*, const char *tag);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_attribute(struct soap*, const char*, const char*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_begin_in(struct soap*, const char *tag, int nillable, const char *type);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_element_end_in(struct soap*, const char *tag);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_peek_element(struct soap*);
+
+SOAP_FMAC1 void SOAP_FMAC2 soap_retry(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_revert(struct soap*);
+
+SOAP_FMAC1 char* SOAP_FMAC2 soap_strdup(struct soap*, const char*);
+SOAP_FMAC1 wchar_t* SOAP_FMAC2 soap_wstrdup(struct soap*, const wchar_t*);
+SOAP_FMAC1 const char * SOAP_FMAC2 soap_tagsearch(const char *big, const char *little);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_string_out(struct soap*, const char *s, int flag);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_string_in(struct soap*, int, long, long);
+
+#ifndef WITH_LEANER
+SOAP_FMAC1 int SOAP_FMAC2 soap_wstring_out(struct soap*, const wchar_t *s, int flag);
+SOAP_FMAC1 wchar_t* SOAP_FMAC2 soap_wstring_in(struct soap*, int, long, long);
+#endif
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_match_namespace(struct soap*, const char *, const char*, size_t n1, size_t n2);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_set_namespaces(struct soap*, const struct Namespace*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_local_namespaces(struct soap*);
+
+SOAP_FMAC1 void SOAP_FMAC2 soap_pop_namespace(struct soap*);
+SOAP_FMAC1 struct soap_nlist* SOAP_FMAC2 soap_push_namespace(struct soap*, const char *,const char *);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_current_namespace(struct soap *soap, const char *tag);
+
+SOAP_FMAC1 struct soap_nlist* SOAP_FMAC2 soap_lookup_ns(struct soap *soap, const char *tag, size_t n);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_store_lab(struct soap*, const char*, size_t);
+SOAP_FMAC1 int SOAP_FMAC2 soap_append_lab(struct soap*, const char*, size_t);
+
+SOAP_FMAC1 struct soap_blist* SOAP_FMAC2 soap_new_block(struct soap*);
+SOAP_FMAC1 void* SOAP_FMAC2 soap_push_block(struct soap*, struct soap_blist*, size_t);
+SOAP_FMAC1 void SOAP_FMAC2 soap_pop_block(struct soap*, struct soap_blist*);
+SOAP_FMAC1 size_t SOAP_FMAC2 soap_size_block(struct soap*, struct soap_blist*, size_t);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_first_block(struct soap*, struct soap_blist*);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_next_block(struct soap*, struct soap_blist*);
+SOAP_FMAC1 size_t SOAP_FMAC2 soap_block_size(struct soap*, struct soap_blist*);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_save_block(struct soap*, struct soap_blist*, char*, int);
+SOAP_FMAC1 void SOAP_FMAC2 soap_end_block(struct soap*, struct soap_blist*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_begin_out(struct soap*);
+SOAP_FMAC1 int soap_envelope_end_out(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_begin_in(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_end_in(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_body_begin_out(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_body_end_out(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_body_begin_in(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_body_end_in(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_recv_header(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_response(struct soap*, int);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_send_empty_response(struct soap*, int status);
+SOAP_FMAC1 int SOAP_FMAC2 soap_recv_empty_response(struct soap*);
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_send_fault(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_recv_fault(struct soap*, int check);
+
+#ifndef WITH_NOSTDLIB
+SOAP_FMAC1 void SOAP_FMAC2 soap_print_fault(struct soap*, FILE*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_print_fault_location(struct soap*, FILE*);
+# ifndef WITH_LEAN
+# ifdef __cplusplus
+SOAP_FMAC1 void SOAP_FMAC2 soap_stream_fault(struct soap*, std::ostream&);
+# endif
+SOAP_FMAC1 char* SOAP_FMAC2 soap_sprint_fault(struct soap*, char*, size_t);
+# endif
+#endif
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2byte(struct soap*, const char*, char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2short(struct soap*, const char*, short*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2int(struct soap*, const char*, int*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2long(struct soap*, const char*, long*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2LONG64(struct soap*, const char*, LONG64*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2float(struct soap*, const char*, float*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2double(struct soap*, const char*, double*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedByte(struct soap*, const char*, unsigned char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedShort(struct soap*, const char*, unsigned short*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedInt(struct soap*, const char*, unsigned int*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedLong(struct soap*, const char*, unsigned long*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2ULONG64(struct soap*, const char*, ULONG64*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2string(struct soap*, const char*, char**, long minlen, long maxlen);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2QName(struct soap*, const char*, char**, long minlen, long maxlen);
+
+#ifndef WITH_LEAN
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2wchar(struct soap*, const char*, wchar_t**, long minlen, long maxlen);
+SOAP_FMAC1 int SOAP_FMAC2 soap_s2dateTime(struct soap*, const char*, time_t*);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_s2base64(struct soap*, const unsigned char*, char*, int);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_s2hex(struct soap*, const unsigned char*, char*, int);
+#endif
+
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_byte2s(struct soap*, char);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_short2s(struct soap*, short);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_int2s(struct soap*, int);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_long2s(struct soap*, long);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_LONG642s(struct soap*, LONG64);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_float2s(struct soap*, float);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_double2s(struct soap*, double);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_unsignedByte2s(struct soap*, unsigned char);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_unsignedShort2s(struct soap*, unsigned short);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_unsignedInt2s(struct soap*, unsigned int);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_unsignedLong2s(struct soap*, unsigned long);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_ULONG642s(struct soap*, ULONG64);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_QName2s(struct soap*, const char*);
+
+#ifndef WITH_LEAN
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_wchar2s(struct soap*, const wchar_t*);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_dateTime2s(struct soap*, time_t);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_base642s(struct soap*, const char*, char*, size_t, int*);
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_hex2s(struct soap*, const char*, char*, size_t, int*);
+#endif
+
+
+SOAP_FMAC1 int* SOAP_FMAC2 soap_inint(struct soap*, const char *tag, int *p, const char *, int);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_inbyte(struct soap*, const char *tag, char *p, const char *, int);
+SOAP_FMAC1 long* SOAP_FMAC2 soap_inlong(struct soap*, const char *tag, long *p, const char *, int);
+SOAP_FMAC1 LONG64* SOAP_FMAC2 soap_inLONG64(struct soap*, const char *tag, LONG64 *p, const char *, int);
+SOAP_FMAC1 short* SOAP_FMAC2 soap_inshort(struct soap*, const char *tag, short *p, const char *, int);
+SOAP_FMAC1 float* SOAP_FMAC2 soap_infloat(struct soap*, const char *tag, float *p, const char *, int);
+SOAP_FMAC1 double* SOAP_FMAC2 soap_indouble(struct soap*, const char *tag, double *p, const char *, int);
+SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_inunsignedByte(struct soap*, const char *tag, unsigned char *p, const char *, int);
+SOAP_FMAC1 unsigned short* SOAP_FMAC2 soap_inunsignedShort(struct soap*, const char *tag, unsigned short *p, const char *, int);
+SOAP_FMAC1 unsigned int* SOAP_FMAC2 soap_inunsignedInt(struct soap*, const char *tag, unsigned int *p, const char *, int);
+SOAP_FMAC1 unsigned long* SOAP_FMAC2 soap_inunsignedLong(struct soap*, const char *tag, unsigned long *p, const char *, int);
+SOAP_FMAC1 ULONG64* SOAP_FMAC2 soap_inULONG64(struct soap*, const char *tag, ULONG64 *p, const char *, int);
+SOAP_FMAC1 char** SOAP_FMAC2 soap_instring(struct soap*, const char *tag, char **p, const char *, int, int, long, long);
+SOAP_FMAC1 char** SOAP_FMAC2 soap_inliteral(struct soap*, const char *tag, char **p);
+
+#ifndef WITH_LEAN
+SOAP_FMAC1 time_t* SOAP_FMAC2 soap_indateTime(struct soap*, const char *tag, time_t *p, const char *, int);
+SOAP_FMAC1 time_t SOAP_FMAC2 soap_timegm(struct tm*);
+#endif
+
+#ifndef WITH_LEANER
+SOAP_FMAC1 wchar_t** SOAP_FMAC2 soap_inwstring(struct soap*, const char *tag, wchar_t **p, const char *, int, long, long);
+SOAP_FMAC1 wchar_t** SOAP_FMAC2 soap_inwliteral(struct soap*, const char *tag, wchar_t **p);
+#endif
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_outbyte(struct soap*, const char *tag, int id, const char *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outshort(struct soap*, const char *tag, int id, const short *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outint(struct soap*, const char *tag, int id, const int *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outlong(struct soap*, const char *tag, int id, const long *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outLONG64(struct soap*, const char *tag, int id, const LONG64 *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outfloat(struct soap*, const char *tag, int id, const float *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outdouble(struct soap*, const char *tag, int id, const double *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outunsignedByte(struct soap*, const char *tag, int id, const unsigned char *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outunsignedShort(struct soap*, const char *tag, int id, const unsigned short *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outunsignedInt(struct soap*, const char *tag, int id, const unsigned int *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outunsignedLong(struct soap*, const char *tag, int id, const unsigned long *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outULONG64(struct soap*, const char *tag, int id, const ULONG64 *p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outstring(struct soap*, const char *tag, int id, char *const*p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outliteral(struct soap*, const char *tag, char *const*p, const char *type);
+
+#ifndef WITH_LEAN
+SOAP_FMAC1 int SOAP_FMAC2 soap_outdateTime(struct soap*, const char *tag, int id, const time_t *p, const char *, int);
+#endif
+
+#ifndef WITH_LEANER
+SOAP_FMAC1 int SOAP_FMAC2 soap_outwstring(struct soap*, const char *tag, int id, wchar_t *const*p, const char *, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_outwliteral(struct soap*, const char *tag, wchar_t *const*p, const char *type);
+#endif
+
+#ifndef WITH_LEANER
+SOAP_FMAC1 int SOAP_FMAC2 soap_attachment(struct soap *, const char*, int, const void*, const struct soap_array*, const char*, const char*, const char*, int, const char*, int);
+SOAP_FMAC1 int SOAP_FMAC2 soap_move(struct soap*, long);
+SOAP_FMAC1 size_t SOAP_FMAC2 soap_tell(struct soap*);
+SOAP_FMAC1 char* SOAP_FMAC2 soap_dime_option(struct soap*, unsigned short, const char*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getdimehdr(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getdime(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putdimehdr(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putdime(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getmimehdr(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_getmime(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putmimehdr(struct soap*, struct soap_multipart*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putmime(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_dime(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_set_mime(struct soap*, const char *boundary, const char *start);
+SOAP_FMAC1 void SOAP_FMAC2 soap_clr_dime(struct soap*);
+SOAP_FMAC1 void SOAP_FMAC2 soap_clr_mime(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_set_dime_attachment(struct soap*, char *ptr, size_t size, const char *type, const char *id, unsigned short optype, const char *option);
+SOAP_FMAC1 int SOAP_FMAC2 soap_set_mime_attachment(struct soap*, char *ptr, size_t size, enum soap_mime_encoding encoding, const char *type, const char *id, const char *location, const char *description);
+SOAP_FMAC1 void SOAP_FMAC2 soap_post_check_mime_attachments(struct soap *soap);
+SOAP_FMAC1 int SOAP_FMAC2 soap_check_mime_attachments(struct soap *soap);
+SOAP_FMAC1 struct soap_multipart* SOAP_FMAC2 soap_get_mime_attachment(struct soap *soap, void *handle);
+SOAP_FMAC1 int SOAP_FMAC2 soap_match_cid(struct soap*, const char*, const char*);
+#endif
+
+SOAP_FMAC1 int SOAP_FMAC2 soap_register_plugin_arg(struct soap*, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void*);
+SOAP_FMAC1 void* SOAP_FMAC2 soap_lookup_plugin(struct soap*, const char*);
+
+SOAP_FMAC1 const char* SOAP_FMAC2 soap_attr_value(struct soap *soap, const char *name, int flag);
+SOAP_FMAC1 int SOAP_FMAC2 soap_set_attr(struct soap *soap, const char *name, const char *value, int flag);
+SOAP_FMAC1 void SOAP_FMAC2 soap_clr_attr(struct soap *soap);
+
+#ifdef WITH_COOKIES
+SOAP_FMAC1 void SOAP_FMAC2 soap_getcookies(struct soap *soap, const char *val);
+SOAP_FMAC1 size_t SOAP_FMAC2 soap_encode_cookie(const char*, char*, size_t);
+SOAP_FMAC1 extern struct soap_cookie* SOAP_FMAC2 soap_set_cookie(struct soap*, const char*, const char*, const char*, const char*);
+SOAP_FMAC1 extern struct soap_cookie* SOAP_FMAC2 soap_cookie(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern char* SOAP_FMAC2 soap_cookie_value(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern char* SOAP_FMAC2 soap_env_cookie_value(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern time_t SOAP_FMAC2 soap_cookie_expire(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern int SOAP_FMAC2 soap_set_cookie_expire(struct soap*, const char*, long, const char*, const char*);
+SOAP_FMAC1 extern int SOAP_FMAC2 soap_set_cookie_session(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern int SOAP_FMAC2 soap_clr_cookie_session(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern void SOAP_FMAC2 soap_clr_cookie(struct soap*, const char*, const char*, const char*);
+SOAP_FMAC1 extern int SOAP_FMAC2 soap_getenv_cookies(struct soap*);
+SOAP_FMAC1 extern struct soap_cookie* SOAP_FMAC2 soap_copy_cookies(struct soap*, const struct soap*);
+SOAP_FMAC1 extern void SOAP_FMAC2 soap_free_cookies(struct soap*);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putsetcookies(struct soap *soap);
+SOAP_FMAC1 int SOAP_FMAC2 soap_putcookies(struct soap *soap, const char *domain, const char *path, int secure);
+#endif
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* STDSOAP_H */
diff --git a/usr/src/lib/libkmsagent/common/SYSCommon.c b/usr/src/lib/libkmsagent/common/SYSCommon.c
new file mode 100644
index 0000000000..dd418fec4b
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SYSCommon.c
@@ -0,0 +1,2307 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*---------------------------------------------------------------------------
+ * Module: SYSCommon.c
+ *-------------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include "SYSCommon.h"
+#include <time.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <signal.h>
+
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
+#ifdef WIN32
+#include <io.h>
+#include <stdlib.h> /* for malloc, calloc, and free */
+#elif defined K_LINUX_PLATFORM
+#include <unistd.h> /* it includes usleep(us) */
+#include <sys/time.h>
+#include <fts.h>
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+
+#ifdef K_SOLARIS_PLATFORM
+/* For K_AdjustLocalClock */
+#include <unistd.h>
+/* For K_SetRootPassword */
+#define __EXTENSIONS__ /* to expose flockfile and friends in stdio.h */
+#include <errno.h>
+#include <libgen.h>
+#include <malloc.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <stropts.h>
+#include <unistd.h>
+#include <termio.h>
+#include <security/pam_appl.h>
+#include <widec.h>
+#endif
+
+#ifdef K_LINUX_PLATFORM
+extern int pthread_mutexattr_settype __P ((pthread_mutexattr_t *__attr,
+ int __kind));
+#endif
+
+#ifdef K_HPUX_PLATFORM
+int64 atoll(const char *str)
+{
+ int64 tmp = 0;
+ sscanf(str, "%lld", &tmp);
+ return tmp;
+}
+
+#endif
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CreateThread
+ *
+ * Description:
+ * Thread creation function "CreateThread" takes a thread function
+ * and its parameter to create a thread. It also has a Boolean
+ * parameter to indicate if the thread is detached or joinable.
+ * A new thread's handle is returned through the output parameter.
+ *
+ * Input
+ * -----
+ * i_pFunc Function pointer of the thread function
+ * i_pvData The point of the parameter passed to the thread function
+ * i_bIsDetached The thread is detached or not
+ * (Note: It is not supported on Win32)
+ *
+ * Output
+ * ------
+ * o_pNewThread The Thread handle
+ *
+ * Return value Error code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_CreateThread(K_ThreadFunc i_pFunc,
+ void *i_pvData,
+ int i_bIsDetached,
+ K_THREAD_HANDLE *o_pNewThread)
+{
+ int iOK = K_SYS_OK;
+ int iReturn = 0;
+
+#ifdef WIN32
+
+ {
+ unsigned id;
+
+ *o_pNewThread = (HANDLE)_beginthreadex(NULL,
+ 0,
+ (int (_stdcall *) (void *vpData))i_pFunc,
+ i_pvData,
+ 0,
+ &id);
+
+
+ if(*o_pNewThread == 0)
+ {
+#ifdef SYS_DEBUG
+ printf(" (%s, %d): error creating pthread, error = %d\n",
+ __FILE__, __LINE__, iReturn);
+#endif
+ return K_SYS_ERR_CREATE_THREAD;
+ }
+
+ return K_SYS_OK;
+ }
+
+#else
+ pthread_attr_t attr;
+
+ iReturn = pthread_attr_init(&attr);
+
+ if ( iReturn == 0 )
+ {
+ iReturn = pthread_attr_setdetachstate(&attr, (i_bIsDetached) ?
+ PTHREAD_CREATE_DETACHED :
+ PTHREAD_CREATE_JOINABLE);
+ }
+
+#ifdef UNIX
+ if ( iReturn == 0 )
+ {
+ iReturn = pthread_attr_setstacksize(&attr, 1024*1024);
+ }
+#endif
+
+ if ( iReturn == 0 )
+ {
+ iReturn = pthread_create(o_pNewThread, &attr, (void *(*)(void *)) i_pFunc, i_pvData);
+ }
+
+ if ( iReturn == 0 )
+ {
+ iReturn = pthread_attr_destroy(&attr);
+ }
+
+ // TODO: Log error?
+ if ( iReturn )
+ {
+#ifdef SYS_DEBUG
+ printf(" (%s, %d): error creating pthread, error = %d\n",
+ __FILE__, __LINE__, iReturn);
+#endif
+
+ iOK = K_SYS_ERR_CREATE_THREAD;
+ }
+
+ return iOK;
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_JoinThread
+ *
+ * Description:
+ * Thread joining function is called when the current thread
+ * waits another thread to terminate.
+ *
+ * Input
+ * -----
+ * i_hThread The thread handle of the to-be-joined thread
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_JoinThread(K_THREAD_HANDLE i_hThread)
+{
+ int iOK = K_SYS_OK;
+#ifdef WIN32
+
+ WaitForSingleObject(i_hThread, INFINITE);
+
+#else
+ {
+ int iReturn;
+ iReturn = pthread_join(i_hThread, NULL);
+
+ if ( iReturn )
+ {
+
+#ifdef SYS_DEBUG
+ printf(" (%s, %d): error creating pthread, error = %d\n",
+ __FILE__, __LINE__, iReturn);
+#endif
+ iOK = K_SYS_ERR_JOIN_THREAD;
+ }
+ }
+
+#endif
+ return iOK;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetCurrentThreadId
+ *
+ * Description:
+ * Returns the thread ID of the current thread.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value The thread ID
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_GetCurrentThreadId()
+{
+#ifdef WIN32
+ return GetCurrentThreadId();
+#else
+ return pthread_self();
+#endif
+
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CreateMutex
+ *
+ * Description:
+ * The mutex creation function creates a mutex according to the given
+ * mutex type, and returns the mutex handle to the output parameter.
+ *
+ * Input
+ * -----
+ * i_bIsRecursive Indication whether the mutex can be entered recursively
+ *
+ * Output
+ * ------
+ * o_phandle the handle pointer to the mutex
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_CreateMutex( K_MUTEX_HANDLE *o_phandle )
+{
+ int iOK = K_SYS_OK;
+ BOOL bIsRecursive = 1; // this used to be an input -- but why do we want this to be optional?
+
+#ifdef WIN32
+ {
+ *o_phandle = (WIN32Mutex *)malloc(sizeof(WIN32Mutex));
+ if(*o_phandle == NULL)
+ {
+ return K_SYS_ERR_NO_MEMORY;
+ }
+ (*o_phandle)->m_bIsRecursive = bIsRecursive;
+ if(bIsRecursive)
+ {
+ InitializeCriticalSection(&((*o_phandle)->m_stCriticalSection));
+ }
+ else
+ {
+ (*o_phandle)->m_handle = CreateMutex(NULL, FALSE, NULL);
+ }
+
+ }
+#else
+ {
+ int iType;
+ pthread_mutexattr_t attr;
+
+ if ( pthread_mutexattr_init(&attr) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+ if(bIsRecursive)
+ {
+ iType =
+#ifdef K_LINUX_PLATFORM
+ PTHREAD_MUTEX_RECURSIVE_NP;
+#else
+ PTHREAD_MUTEX_RECURSIVE;
+#endif
+
+ if ( pthread_mutexattr_settype(&attr, iType) )
+ {
+ return K_SYS_ERR_COND;
+ }
+ }
+
+ *o_phandle = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
+ if(*o_phandle == NULL)
+ {
+ return K_SYS_ERR_NO_MEMORY;
+ }
+
+ if ( pthread_mutex_init(*o_phandle, &attr) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+ if ( pthread_mutexattr_destroy(&attr) )
+ {
+ return K_SYS_ERR_COND;
+ }
+ }
+#endif
+
+ return iOK;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_LockMutex
+ *
+ * Description:
+ * K_LockMutex is used to lock the mutex, and K_UnlockMutex is
+ * used to unlock it.
+ *
+ * Input
+ * -----
+ * i_handle the mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_LockMutex(K_MUTEX_HANDLE i_handle)
+{
+ int iOK = K_SYS_OK;
+#ifdef WIN32
+
+ if(i_handle->m_bIsRecursive)
+ {
+ EnterCriticalSection(&(i_handle->m_stCriticalSection));
+ }
+ else
+ {
+ WaitForSingleObject(i_handle->m_handle, INFINITE);
+ }
+
+#else
+
+ if ( pthread_mutex_lock(i_handle) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+#endif
+ return iOK; // TODO: better error handling
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_UnlockMutex
+ *
+ * Description:
+ * K_UnlockMutex is used to unlock the lock.
+ *
+ * Input
+ * -----
+ * i_handle the mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_UnlockMutex(K_MUTEX_HANDLE i_handle)
+{
+ int iOK = K_SYS_OK;
+
+#ifdef WIN32
+ if(i_handle->m_bIsRecursive)
+ {
+ LeaveCriticalSection(&(i_handle->m_stCriticalSection));
+ }
+ else
+ {
+ ReleaseMutex(i_handle->m_handle);
+ }
+
+#else
+
+ if ( pthread_mutex_unlock(i_handle) )
+ {
+ return K_SYS_ERR_COND;
+ }
+#endif
+
+ return iOK; // TODO: better error handling
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_DestroyMutex
+ *
+ * Description:
+ * When a mutex is no longer needed, K_DestroyMutex must be called
+ * to destroy it.
+ *
+ * Input
+ * -----
+ * i_handle the mutex handle
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_DestroyMutex(K_MUTEX_HANDLE i_handle)
+{
+
+ int iOK = K_SYS_OK;
+
+#ifdef WIN32
+
+ if(i_handle->m_bIsRecursive)
+ {
+ DeleteCriticalSection(&(i_handle->m_stCriticalSection));
+ }
+ else
+ {
+ CloseHandle(i_handle->m_handle);
+ }
+ free(i_handle);
+
+#else
+ pthread_mutex_destroy(i_handle);
+ free(i_handle);
+#endif
+ return iOK; // TODO: better error handling
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_InitConditionalVariable
+ *
+ * Description:
+ * This function initializes a conditional variable. Upon successful
+ * completion, the new condition variable is returned via the condition
+ * parameter, and 0 is returned. Otherwise, an error code is returned.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable which is to be
+ * initialized
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_InitConditionalVariable (K_ConditionalVariable * i_pCond)
+{
+ int iOK = K_SYS_OK;
+#ifdef WIN32
+
+ i_pCond->m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ i_pCond->m_hMutex = CreateMutex(NULL, FALSE, NULL);
+ i_pCond->m_iSignalAll = 0;
+ i_pCond->m_iNumWaiting = 0;
+
+#else
+
+ if ( pthread_cond_init(i_pCond, NULL) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+#endif
+
+ return iOK;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_DestroyConditionalVariable
+ *
+ * Description:
+ * This function destroys a conditional variable. Upon successful
+ * completion, the condition variable is destroyed, and 0 is returned.
+ * Otherwise, an error code is returned.
+ * After deletion of the condition variable, the condition parameter
+ * is not valid until it is initialized again by a call to the
+ * K_InitConditionalVariable subroutine.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable which is to be
+ * destroyed
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_DestroyConditionalVariable(K_ConditionalVariable * i_pCond)
+{
+ int iOK = K_SYS_OK;
+#ifdef WIN32
+ CloseHandle(i_pCond->m_hMutex);
+ CloseHandle(i_pCond->m_hEvent);
+#else
+
+ if ( pthread_cond_destroy(i_pCond) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+#endif
+ return iOK;
+
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_WaitConditionalVariable
+ *
+ * Description:
+ * This function is used to block on a condition variable.
+ * They are called with mutex locked by the calling thread or undefined
+ * behaviour will result.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable
+ * i_handle the companion mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_WaitConditionalVariable(K_ConditionalVariable * i_pCond,
+ K_MUTEX_HANDLE i_handle)
+{
+
+ int iOK = K_SYS_OK;
+#ifdef WIN32
+ DWORD res;
+
+ while (1)
+ {
+ iOK = WaitForSingleObject(i_pCond->m_hMutex, INFINITE);
+ if (iOK != WAIT_OBJECT_0)
+ {
+ return K_SYS_ERR_COND;
+ }
+ i_pCond->m_iNumWaiting++;
+ ReleaseMutex(i_pCond->m_hMutex);
+
+ K_UnlockMutex(i_handle);
+ res = WaitForSingleObject(i_pCond->m_hEvent, INFINITE);
+ i_pCond->m_iNumWaiting--;
+
+ if (res != WAIT_OBJECT_0)
+ {
+ ReleaseMutex(i_pCond->m_hMutex);
+ return K_SYS_ERR_COND;
+ }
+
+ if (i_pCond->m_iSignalAll)
+ {
+ if (i_pCond->m_iNumWaiting == 0)
+ {
+ ResetEvent(i_pCond->m_hEvent);
+ }
+ break;
+ }
+
+ if (i_pCond->m_iSignalled)
+ {
+ i_pCond->m_iSignalled = 0;
+ ResetEvent(i_pCond->m_hEvent);
+ break;
+ }
+ ReleaseMutex(i_pCond->m_hMutex);
+ }
+
+ K_LockMutex(i_handle);
+
+ return K_SYS_OK;
+#else
+
+ if ( pthread_cond_wait(i_pCond, i_handle) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+#endif
+ return iOK; // TODO: better error handling
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_SignalConditionalVariable
+ *
+ * Description:
+ * This function is used to restart one of the threads that are waiting on
+ * the condition variable. If no threads are waiting on it, nothing happens.
+ * If several threads are waiting on it, exactly one is restarted.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_SignalConditionalVariable(K_ConditionalVariable * i_pCond)
+{
+ int iOK = K_SYS_OK;
+#ifdef WIN32
+
+ int iReturn;
+
+ iReturn = WaitForSingleObject(i_pCond->m_hMutex, INFINITE);
+ if (iReturn != WAIT_OBJECT_0)
+ {
+ return K_SYS_ERR_COND;
+ }
+
+ i_pCond->m_iSignalled = 1;
+
+ iReturn = SetEvent(i_pCond->m_hEvent);
+ if (iReturn == 0)
+ {
+ iOK = K_SYS_ERR_COND;
+ }
+ ReleaseMutex(i_pCond->m_hMutex);
+
+ return iOK;
+#else
+
+ if ( pthread_cond_signal(i_pCond) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+#endif
+ return iOK;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_BroadcastConditionalVariable
+ *
+ * Description:
+ * This function is used to restart all threads that are waiting on
+ * the condition variable.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_BroadcastConditionalVariable(K_ConditionalVariable * i_pCond)
+{
+
+ int iOK = K_SYS_OK;
+
+#ifdef WIN32
+
+ int iReturn;
+
+ iReturn = WaitForSingleObject(i_pCond->m_hMutex, INFINITE);
+ if (iReturn != WAIT_OBJECT_0)
+ {
+ return K_SYS_ERR_COND;
+ }
+ i_pCond->m_iSignalled = 1;
+ i_pCond->m_iSignalAll = 1;
+
+ iReturn = SetEvent(i_pCond->m_hEvent);
+
+ if (iReturn == 0)
+ {
+ iOK = K_SYS_ERR_COND;
+ }
+
+ ReleaseMutex(i_pCond->m_hMutex);
+
+ return iOK;
+
+#else
+
+ if ( pthread_cond_broadcast(i_pCond) )
+ {
+ return K_SYS_ERR_COND;
+ }
+
+#endif
+ return iOK;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_Sleep
+ *
+ * Description:
+ * Sleep for a given period in given milliseconds.
+ *
+ * Input
+ * -----
+ * i_ms milliseconds
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+
+void K_Sleep(int i_ms)
+{
+#ifdef WIN32
+ Sleep(i_ms);
+#else
+ usleep(i_ms * 1000);
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetTickCount
+ *
+ * Description:
+ * The K_GetTickCount function retrieves the number of
+ * milliseconds that have elapsed since the system was started.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value the elasped milliseconds since the system was started
+ *
+ *--------------------------------------------------------------------------*/
+
+unsigned int K_GetTickCount()
+{
+#ifdef WIN32
+ return (unsigned int)GetTickCount();
+#else
+ {
+ struct timeval tv;
+ gettimeofday( &tv, NULL );
+ /* this will rollover ~ every 49.7 days
+ dont surprise when it returns negative values, since we are only interested
+ in using sth like "tickCount2 - tickCount1" to get the time interval
+ */
+ return ( tv.tv_sec * 1000 ) + ( tv.tv_usec / 1000 );
+ }
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_AdjustClock
+ *
+ * Description:
+ * The K_AdjustClock function immediately adjusts the system clock by
+ * the given number of seconds. A positive number adjusts the system
+ * clock forward; a negative number adjusts the system clock backward.
+ *
+ * Input
+ * -----
+ * i_iAdjustmentInSeconds Number of seconds by which to adjust the
+ * system clock
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 if successful, 0 on error
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_AdjustClock( long i_iAdjustmentInSeconds )
+{
+#ifndef WIN32
+ struct timeval stDateTime;
+ if ( 0 != gettimeofday(&stDateTime, NULL) )
+ {
+ return FALSE;
+ }
+
+ stDateTime.tv_sec += i_iAdjustmentInSeconds;
+
+ if ( 0 != settimeofday(&stDateTime, NULL) )
+ {
+ return FALSE;
+ }
+#else
+ // TODO: implement for Windows
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_IsLittleEndian
+ *
+ * Description:
+ * Checks to see whether this platform uses little endian integer
+ * representation.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 for little endian
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_IsLittleEndian()
+{
+ short iWord = 0x4321;
+ return ((*(unsigned char*)&iWord) == 0x21);
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_FileLength32
+ *
+ * Description:
+ * Gets the size in bytes of the file associated with the given FILE pointer.
+ *
+ * Input
+ * -----
+ * i_fpFile File handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value File size in bytes, or -1L on error
+ *
+ *--------------------------------------------------------------------------*/
+
+long K_FileLength32( FILE* i_fpFile )
+{
+#ifdef WIN32
+ int iFileDescriptor = _fileno( i_fpFile );
+ struct _stat stStat;
+
+ if ( _fstat(iFileDescriptor, &stStat) != 0)
+ {
+ // error
+ return -1L;
+ }
+
+#else
+ int iFileDescriptor = fileno( i_fpFile );
+ struct stat stStat;
+
+ if ( fstat(iFileDescriptor, &stStat) != 0)
+ {
+ // error
+ return -1L;
+ }
+
+#endif
+
+ return stStat.st_size;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_StringCompareNoCase
+ *
+ * Description:
+ * Compares the two given strings insensitive to case.
+ *
+ * Input
+ * -----
+ * i_sString1 First string
+ * i_sString2 Second string
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 if identical, -1 if first string is less than second
+ * string, or 1 if first string is greater than second
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_StringCompareNoCase( const char* i_sString1, const char* i_sString2 )
+{
+#ifdef WIN32
+ return _stricmp( i_sString1, i_sString2 );
+#else
+ return strcasecmp( i_sString1, i_sString2 );
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_StringCompareNoCaseWide
+ *
+ * Description:
+ * Compares the two given wide strings insensitive to case.
+ *
+ * Input
+ * -----
+ * i_wsString1 First wide string
+ * i_wsString2 Second wide string
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 if identical, -1 if first string is less than second
+ * string, or 1 if first string is greater than second
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_StringCompareNoCaseWide( const wchar_t* i_wsString1, const wchar_t* i_wsString2 )
+{
+#ifdef WIN32
+ return _wcsicmp( i_wsString1, i_wsString2 );
+#elif defined K_SOLARIS_PLATFORM
+ return wscasecmp( i_wsString1, i_wsString2 );
+#else
+ return wcscasecmp( i_wsString1, i_wsString2 );
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CreateDirectory
+ *
+ * Description:
+ * Creates a directory with the given path name.
+ *
+ * Input
+ * -----
+ * i_sDirectoryName Directory name
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_CreateDirectory( const char* i_sDirectoryName )
+{
+ // TODO: make this build all parent directories as well.
+
+#ifdef WIN32
+ if ( CreateDirectoryA( i_sDirectoryName, NULL ) )
+ {
+ return 0;
+ }
+ else
+ {
+ DWORD dwError = GetLastError();
+ return ( dwError == ERROR_ALREADY_EXISTS ) ? 0 : (dwError ? dwError : -1);
+ }
+#else
+ if ( mkdir( i_sDirectoryName, S_IRWXU ) == 0 )
+ {
+ return 0;
+ }
+ else
+ {
+ return ( errno == EEXIST ) ? 0 : (errno ? errno : -1);
+ }
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_DeleteFile
+ *
+ * Description:
+ * Deletes the given file.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to delete
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, errno on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_DeleteFile( const char* i_sFilename )
+{
+ int bSuccess = 0;
+
+ bSuccess =
+#ifdef WIN32
+ _unlink(
+#else
+ unlink(
+#endif
+ i_sFilename ) == 0;
+
+ return bSuccess ? 0 : errno;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ReadFile
+ *
+ * Description:
+ * Reads from the given file and passes the bytes read back to the output
+ * parameter. The caller must deallocate o_ppFileData using free().
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file from which to read
+ *
+ * Output
+ * ------
+ * o_ppFileData Pointer to bytes read
+ *
+ * Return value Number of bytes read on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_ReadFile( const char* i_sFilename, unsigned char** o_ppFileData )
+{
+ FILE* pFile = 0;
+ long iFileSize = 0;
+
+ if ( !i_sFilename || (strlen(i_sFilename) <= 0) || !o_ppFileData )
+ {
+ return -1;
+ }
+
+ *o_ppFileData = 0;
+
+ // Open the file
+
+ pFile = fopen( i_sFilename, "rb" );
+ if ( !pFile )
+ {
+ return -1;
+ }
+
+ // Determine the file size
+
+ if ( fseek( pFile, 0, SEEK_END ) )
+ {
+ (void) fclose( pFile );
+ return -1;
+ }
+
+ iFileSize = ftell( pFile );
+ if ( iFileSize < 0 )
+ {
+ (void) fclose( pFile );
+ return -1;
+ }
+ else if ( iFileSize == 0 )
+ {
+ (void) fclose( pFile );
+ return 0;
+ }
+
+ if ( fseek( pFile, 0, SEEK_SET ) )
+ {
+ (void) fclose( pFile );
+ return -1;
+ }
+
+ *o_ppFileData = (unsigned char*)malloc( iFileSize );
+ if ( !*o_ppFileData )
+ {
+ // Out of memory.
+ (void) fclose( pFile );
+ return -1;
+ }
+
+ if ( iFileSize != (long)fread( *o_ppFileData, 1, iFileSize, pFile ) )
+ {
+ free( *o_ppFileData );
+ *o_ppFileData = 0;
+ (void) fclose( pFile );
+ return -1;
+ }
+
+ (void) fclose( pFile );
+
+ return iFileSize;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ReadFileString
+ *
+ * Description:
+ * Reads from the given file and passes the bytes read back to the output
+ * parameter, appending these bytes with a null terminator. There is no
+ * guarantee that there are no non-text characters in the returned "string".
+ * The caller must deallocate o_ppFileData using free().
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file from which to read
+ *
+ * Output
+ * ------
+ * o_psFileDataString Pointer to bytes read
+ *
+ * Return value Number of bytes read (including null terminator) on
+ * success (0 if file is empty), -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_ReadFileString( const char* i_sFilename, char** o_psFileDataString )
+{
+ unsigned char* pFileData = 0;
+ int iFileSize = 0;
+
+ *o_psFileDataString = 0;
+
+ iFileSize = K_ReadFile( i_sFilename, &pFileData );
+
+ if ( iFileSize <= 0 )
+ {
+ return iFileSize;
+ }
+
+ *o_psFileDataString = (char*)malloc( iFileSize+1 );
+
+ if ( !*o_psFileDataString )
+ {
+ // Out of memory.
+ if ( pFileData )
+ {
+ free( pFileData );
+ }
+ return -1;
+ }
+
+ memcpy( *o_psFileDataString, pFileData, iFileSize );
+
+ (*o_psFileDataString)[iFileSize] = '\0';
+
+ if ( pFileData )
+ {
+ free( pFileData );
+ }
+
+ return iFileSize+1;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_WriteFile
+ *
+ * Description:
+ * Writes the given bytes to the given file.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to which to write
+ * i_pFileData Bytes to write
+ * i_iFileDataSize Number of bytes to write
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, errno or -1 (generic error) on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_WriteFile( const char* i_sFilename, const unsigned char* i_pFileData, int i_iFileDataSize )
+{
+ FILE* pFile = 0;
+
+ if ( !i_sFilename || (strlen(i_sFilename) <= 0) || (!i_pFileData && (i_iFileDataSize > 0)) || (i_iFileDataSize < 0) )
+ {
+ return -1;
+ }
+
+ pFile = fopen( i_sFilename, "wb" );
+ if ( !pFile )
+ {
+ int iError = errno;
+ return (iError != 0) ? iError : -1;
+ }
+
+ if ( i_iFileDataSize > 0 )
+ {
+ if ( i_iFileDataSize != (int)fwrite( i_pFileData, 1, i_iFileDataSize, pFile ) )
+ {
+ int iError = ferror( pFile );
+ (void) fclose( pFile );
+ return (iError != 0) ? iError : -1;
+ }
+ }
+
+ (void) fclose( pFile );
+
+ return 0;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_WriteFileString
+ *
+ * Description:
+ * Writes the given null-terminated bytes to the given file. The null
+ * terminator itself is not written to the file.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to which to write
+ * i_sFileData Bytes to write
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, errno or -1 (generic error) on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_WriteFileString( const char* i_sFilename, const char* i_sFileData )
+{
+ if ( !i_sFilename || (strlen(i_sFilename) <= 0) || !i_sFileData || (strlen(i_sFileData) <= 0) )
+ {
+ return -1;
+ }
+
+ return K_WriteFile( i_sFilename, (const unsigned char*)i_sFileData, strlen(i_sFileData) );
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_FileExists
+ *
+ * Description:
+ * Checks to see whehter the given file exists.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to check
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 if file exists, 0 if not, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_FileExists( const char* i_sFilename )
+{
+ FILE* pFile = 0;
+
+ if ( !i_sFilename || (strlen(i_sFilename) <= 0) )
+ {
+ return -1;
+ }
+
+ pFile = fopen( i_sFilename, "r+" );
+
+ if ( !pFile )
+ {
+ if ( errno == ENOENT )
+ {
+ return 0;
+ }
+
+ return -1;
+ }
+
+ (void) fclose( pFile );
+
+ return 1;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CopyFile
+ *
+ * Description:
+ * Reads from the given source file and writes these bytes to the given
+ * destination file.
+ *
+ * Input
+ * -----
+ * i_sSrcFilename Name of file from which to read
+ * i_sDestFilename Name of file to which to write
+ *
+ * Output
+ * ------
+ * o_pbFileExists Non-zero if the destination file already exists
+ *
+ * Return value 0 on success, errno or -1 (generic error) on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_CopyFile( const char* i_sSrcFilename, const char* i_sDestFilename, int* o_pbFileExists )
+{
+ unsigned char* pFileData = 0;
+ int iFileSize = 0;
+ int iError, iFileExists;
+
+ if ( !i_sSrcFilename || (strlen(i_sSrcFilename) <= 0)
+ || !i_sDestFilename || (strlen(i_sDestFilename) <= 0)
+ || !o_pbFileExists )
+ {
+ return -1;
+ }
+
+ *o_pbFileExists = 0;
+
+ iFileExists = K_FileExists( i_sDestFilename );
+
+ if ( iFileExists < 0 )
+ {
+ iError = errno;
+ return (iError == 0) ? -1 : iError;
+ }
+ else if ( iFileExists > 0 )
+ {
+ *o_pbFileExists = 1;
+ return -1;
+ }
+
+ iFileSize = K_ReadFile( i_sSrcFilename, &pFileData );
+ if ( iFileSize < 0 )
+ {
+ iError = errno;
+ return (iError == 0) ? -1 : iError;
+ }
+
+ iError = K_WriteFile( i_sDestFilename, pFileData, iFileSize );
+
+ if ( pFileData )
+ {
+ free( pFileData );
+ }
+
+ return iError;
+}
+
+
+#ifdef K_LINUX_PLATFORM
+static int fts_compare( const FTSENT** i_ppF1, const FTSENT** i_ppF2 )
+{
+ return strcmp( (*i_ppF1)->fts_name, (*i_ppF2)->fts_name );
+}
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+
+
+/*
+ * TODO: Set up functions for platform-specific find-file operations to
+ * help clean up the code below.
+ */
+
+typedef struct K_FindInfo
+{
+#ifdef WIN32
+ struct _finddata_t m_stFindData;
+ long m_hFile;
+#elif defined K_LINUX_PLATFORM
+ FTS* m_pFTS;
+ FTSENT* m_pFTSENT;
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+ int unused;
+#endif
+} K_FindInfo;
+
+// Memory for filename is held in i_pFindInfo.
+const char* K_GetFilenameFromInfo( const K_FindInfo* i_pFindInfo )
+{
+ if( !i_pFindInfo )
+ {
+ return 0;
+ }
+
+#ifdef WIN32
+ return i_pFindInfo->m_stFindData.name;
+#elif defined K_LINUX_PLATFORM
+ return i_pFindInfo->m_pFTSENT->fts_name;
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+ FATAL_ASSERT( 0 );
+ return 0;
+#endif
+}
+
+// Forward declarations
+int K_FindFileNext( K_FindInfo* io_pFindInfo );
+void K_FindFileClose( K_FindInfo* io_pFindInfo );
+
+// Returns 0 if successful, 1 if not found, -1 if error.
+// If not error, K_FindFileClose must be called.
+// o_pFindInfo must not be null.
+int K_FindFileFirst( const char* i_sDirectoryName, K_FindInfo* o_pFindInfo )
+{
+#ifdef WIN32
+ char* sSearchString = 0;
+ int iSearchStringIndex = 0;
+#endif
+
+ if ( !i_sDirectoryName || (strlen(i_sDirectoryName) <= 0) || !o_pFindInfo )
+ {
+ return -1;
+ }
+
+#ifdef WIN32
+ memset( o_pFindInfo, 0, sizeof(K_FindInfo) );
+
+ iSearchStringIndex = strlen(i_sDirectoryName);
+ if ( i_sDirectoryName[iSearchStringIndex-1] == PATH_SEPARATOR )
+ {
+ iSearchStringIndex += 2;
+ }
+ else
+ {
+ iSearchStringIndex += 3;
+ }
+
+ sSearchString = (char*)calloc( iSearchStringIndex, 1 );
+ if ( !sSearchString )
+ {
+ return -1;
+ }
+
+ strcpy( sSearchString, i_sDirectoryName );
+ iSearchStringIndex--;
+ sSearchString[iSearchStringIndex] = '\0';
+ iSearchStringIndex--;
+ sSearchString[iSearchStringIndex] = '*';
+ iSearchStringIndex--;
+ sSearchString[iSearchStringIndex] = PATH_SEPARATOR;
+
+ o_pFindInfo->m_hFile = _findfirst( sSearchString, &o_pFindInfo->m_stFindData );
+ free( sSearchString );
+ if ( o_pFindInfo->m_hFile == -1 )
+ {
+ if ( errno == ENOENT )
+ {
+ return 1;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+#elif defined K_LINUX_PLATFORM
+ memset( o_pFindInfo, 0, sizeof(K_FindInfo) );
+
+ o_pFindInfo->m_pFTS = fts_open( aPath, FTS_PHYSICAL | FTS_NOSTAT, fts_compare );
+ if ( !o_pFindInfo->m_pFTS )
+ {
+ return -1;
+ }
+
+ o_pFindInfo->m_pFTSENT = fts_read( o_pFindInfo->m_pFTS );
+ if ( !o_pFindInfo->m_pFTSENT )
+ {
+ if ( errno == 0 )
+ {
+ return 1;
+ }
+ else
+ {
+ fts_close( o_pFindInfo->m_pFTS );
+ return -1;
+ }
+ }
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+
+ // If what we found is not actually a file, get the next hit.
+#ifdef WIN32
+ if ( (o_pFindInfo->m_stFindData.attrib & _A_SUBDIR) )
+#elif defined K_LINUX_PLATFORM
+ if ( !(o_pFindInfo->m_pFTSENT->fts_info & FTS_F) )
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+ {
+ int iNextReturn = K_FindFileNext( o_pFindInfo );
+ if ( iNextReturn < 0 )
+ {
+ K_FindFileClose( o_pFindInfo );
+ return -1;
+ }
+ else
+ {
+ return iNextReturn;
+ }
+ }
+
+#if defined(WIN32) || defined(K_LINUX_PLATFORM)
+ return 0;
+#endif
+}
+
+// Returns 0 if successful, 1 if not found, -1 if error.
+int K_FindFileNext( K_FindInfo* io_pFindInfo )
+{
+ if ( !io_pFindInfo )
+ {
+ return -1;
+ }
+
+#ifdef WIN32
+ if ( _findnext( io_pFindInfo->m_hFile, &io_pFindInfo->m_stFindData ) != 0 )
+ {
+ return (errno == ENOENT) ? 1 : -1;
+ }
+#elif defined K_LINUX_PLATFORM
+ io_pFindInfo->m_pFTSENT = fts_read( io_pFindInfo->m_pFTS );
+ if ( !io_pFindInfo->m_pFTSENT )
+ {
+ return (errno == 0) ? 1 : -1;
+ }
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+
+ // If what we found is not actually a file, get the next hit.
+#ifdef WIN32
+ if ( (io_pFindInfo->m_stFindData.attrib & _A_SUBDIR) )
+#elif defined K_LINUX_PLATFORM
+ if ( !(io_pFindInfo->m_pFTSENT->fts_info & FTS_F) )
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+ {
+ return K_FindFileNext( io_pFindInfo );
+ }
+
+#if defined(WIN32) || defined(K_LINUX_PLATFORM)
+ return 0;
+#endif
+}
+
+void K_FindFileClose( K_FindInfo* io_pFindInfo )
+{
+ if ( !io_pFindInfo )
+ {
+ return;
+ }
+
+#ifdef WIN32
+ _findclose( io_pFindInfo->m_hFile );
+#elif defined K_LINUX_PLATFORM
+ fts_close( io_pFindInfo->m_pFTS );
+#else
+/*
+ * Directory traversal code is not yet available for Solaris.
+ * If such code will need to be written, then it will probably use ftw.h.
+ */
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetFilenamesInDirectoryCount
+ *
+ * Description:
+ * Reads the given directory and returns the number of files that it contains.
+ *
+ * Input
+ * -----
+ * i_sDirectoryName Name of directory
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Number of files on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_GetFilenamesInDirectoryCount( const char* i_sDirectoryName )
+{
+ K_FindInfo stFindInfo;
+ int iCurrentFile = 0;
+ int iError = 0;
+
+ if ( !i_sDirectoryName || (strlen(i_sDirectoryName) <= 0) )
+ {
+ return -1;
+ }
+
+ iError = K_FindFileFirst( i_sDirectoryName, &stFindInfo );
+ if ( iError < 0 )
+ {
+ // error
+ return -1;
+ }
+ else if ( iError > 0 )
+ {
+ // no files found
+ K_FindFileClose( &stFindInfo );
+ return 0;
+ }
+
+ while ( 1 )
+ {
+ iCurrentFile++;
+
+ iError = K_FindFileNext( &stFindInfo );
+ if ( iError < 0 )
+ {
+ // error
+ K_FindFileClose( &stFindInfo );
+ return -1;
+ }
+ else if ( iError > 0 )
+ {
+ // no more files found
+ break;
+ }
+ }
+
+ K_FindFileClose( &stFindInfo );
+
+ return iCurrentFile;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetFilenamesInDirectory
+ *
+ * Description:
+ * Reads the given directory and returns an array of names of files that it
+ * contains. A null pointer appears at the last item in the array. The
+ * caller must deallocate o_pasFilenames by using K_FreeFilenames or by
+ * calling free() for each file name and then calling free() on the array
+ * itself.
+ *
+ * Input
+ * -----
+ * i_sDirectoryName Name of directory
+ *
+ * Output
+ * ------
+ * o_pasFilenames Array of names of files found in this directory
+ *
+ * Return value Number of files on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_GetFilenamesInDirectory(
+ const char* i_sDirectoryName,
+ char*** o_pasFilenames )
+{
+ // Note that we iterate through the filenames twice -- once to get the count
+ // (K_GetFilenamesInDirectoryCount) and then once to get all the names. But
+ // it may happen that the count changes between these calls. So we'll retrieve
+ // at most the number of files that's returned in the first pass.
+
+ K_FindInfo stFindInfo;
+ int iFilenameCount = 0, iCurrentFile = 0;
+ int iError = 0;
+
+ if ( !i_sDirectoryName || (strlen(i_sDirectoryName) <= 0) || !o_pasFilenames )
+ {
+ return -1;
+ }
+
+ *o_pasFilenames = 0;
+
+ iFilenameCount = K_GetFilenamesInDirectoryCount( i_sDirectoryName );
+
+ if ( iFilenameCount < 0 )
+ {
+ return -1;
+ }
+
+ iError = K_FindFileFirst( i_sDirectoryName, &stFindInfo );
+ if ( iError < 0 )
+ {
+ // error
+ return -1;
+ }
+ else if ( iError > 0 )
+ {
+ // No files found
+ K_FindFileClose( &stFindInfo );
+ return 0;
+ }
+
+ *o_pasFilenames = (char**)calloc( (iFilenameCount+1), sizeof(char*) ); // +1 for the null last one
+ if ( !*o_pasFilenames )
+ {
+ // Out of memory
+ K_FindFileClose( &stFindInfo );
+ return -1;
+ }
+
+ while ( 1 )
+ {
+ const char* sFilename = K_GetFilenameFromInfo( &stFindInfo );
+
+ size_t iFilenameLength = sFilename ? strlen( sFilename ) : 0;
+
+ if ( iFilenameLength <= 0 )
+ {
+ K_FreeFilenames( *o_pasFilenames );
+ K_FindFileClose( &stFindInfo );
+ return -1;
+ }
+
+ (*o_pasFilenames)[iCurrentFile] = (char*)calloc( (iFilenameLength+1), sizeof(char) );
+ if ( !(*o_pasFilenames)[iCurrentFile] )
+ {
+ K_FreeFilenames( *o_pasFilenames );
+ K_FindFileClose( &stFindInfo );
+ return -1;
+ }
+
+ strncpy( (*o_pasFilenames)[iCurrentFile], sFilename, iFilenameLength );
+ (*o_pasFilenames)[iCurrentFile][iFilenameLength] = '\0';
+
+ iCurrentFile++;
+
+ if ( iCurrentFile >= iFilenameCount )
+ {
+ break;
+ }
+
+ iError = K_FindFileNext( &stFindInfo );
+ if ( iError < 0 )
+ {
+ // error
+ K_FindFileClose( &stFindInfo );
+ return -1;
+ }
+ else if ( iError > 0 )
+ {
+ // no more files found
+ break;
+ }
+ }
+
+ K_FindFileClose( &stFindInfo );
+
+ return iCurrentFile;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_FreeFilenames
+ *
+ * Description:
+ * Deallocates the memory allocated in a successful call to
+ * K_GetFilenamesInDirectory.
+ *
+ * Input
+ * -----
+ * i_asFilenames Array of names of files
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+
+void K_FreeFilenames( char** i_asFilenames )
+{
+ int i;
+
+ if ( !i_asFilenames )
+ {
+ return;
+ }
+
+ for ( i = 0; (i_asFilenames[i] != 0); i++ )
+ {
+ free( i_asFilenames[i] );
+ i_asFilenames[i] = 0;
+ }
+
+ free( i_asFilenames );
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_AdjustLocalClock
+ *
+ * Description:
+ * The K_AdjustLocalClock function gradually adjusts the system clock by
+ * the given number of seconds. A positive number adjusts the system
+ * clock forward; a negative number adjusts the system clock backward.
+ *
+ * Input
+ * -----
+ * i_iAdjustmentInSeconds Number of seconds by which to adjust the
+ * system clock
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 if successful, 0 on error
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_AdjustLocalClock( int i_iNumberOfSeconds )
+{
+ struct timeval delta, lastchange;
+
+#ifndef K_SOLARIS_PLATFORM
+ /* Only supported/tested on Solaris at the moment */
+
+ return -1;
+#else
+ /* WARNING: uses standard C time functions with Year 2038 limitations */
+ time_t now;
+
+ if ( (now = time(NULL)) == ((time_t)-1) )
+ {
+ return -1;
+ }
+
+ delta.tv_sec = i_iNumberOfSeconds;
+ delta.tv_usec = 0;
+
+ return adjtime(&delta, &lastchange);
+#endif
+}
+
+
+#ifdef K_SOLARIS_PLATFORM
+static int pam_tty_conv(
+ int num_msg,
+ struct pam_message** mess,
+ struct pam_response** resp,
+ void* my_data)
+{
+ // Following code implements a console-based PAM "conversation" function
+ // (based sample code from Solaris 10 Software Developer Collection >>
+ // Solaris Security for Developers Guide >>
+ // 3. Writing PAM Applications and Services)
+
+ struct pam_message* m = *mess;
+ struct pam_response* r;
+ int i, j;
+ const char* sPassword = (const char*)my_data;
+ int error = PAM_CONV_ERR;
+
+ if (num_msg <= 0 || num_msg >= PAM_MAX_NUM_MSG)
+ {
+ (void) fprintf(stderr, "PAM error: bad number of messages");
+ *resp = NULL;
+ return (PAM_CONV_ERR);
+ }
+
+ if ((*resp = r = calloc(num_msg, sizeof (struct pam_response))) == NULL)
+ {
+ return (PAM_BUF_ERR);
+ }
+
+ // Loop through messages
+ for (i = 0; i < num_msg; i++) {
+
+ // bad message from service module
+ if (m->msg == NULL)
+ {
+ (void) fprintf(stderr, "PAM error: bad message");
+ goto err;
+ }
+
+ // fix up final newline: removed for prompts, added back for messages
+ if (m->msg[strlen(m->msg)] == '\n')
+ {
+ m->msg[strlen(m->msg)] = '\0';
+ }
+
+ // Since the KMA has its own password prompts and enforces its own rule checks, we already have the
+ // new password in memory. So instead of displaying PAM prompts and collecting user responses, we
+ // "automate" by assuming that the prompts correspond to the standard sequence of "New password:"
+ // followed by "Confirm password:" and so in each case we immediately return the password we already
+ // have in memory. This violates the PAM "conversation" function instructions (which say, basically,
+ // not to assume any particular sequence of prompts since there could be any number of underlying
+ // password managers), but since the KMA is running on an appliance with a fixed password manager,
+ // our assumptions should hold.
+
+ r->resp = NULL;
+ r->resp_retcode = 0;
+ switch (m->msg_style)
+ {
+ case PAM_PROMPT_ECHO_OFF:
+ case PAM_PROMPT_ECHO_ON:
+ // Assume the prompt asked for New/Confirm password, so return password.
+ if ( (r->resp = strdup(sPassword)) == NULL )
+ {
+ error = PAM_BUF_ERR;
+ goto err;
+ }
+ break;
+
+ case PAM_ERROR_MSG:
+ // Assuming the system is configured properly and the KMA password prompts enforce password strength rules,
+ // there should not be errors because of weak passwords, etc. Still, print errors so users/support can
+ // diagnose problems.
+ (void) fputs(m->msg, stderr);
+ (void) fputc('\n', stderr);
+ break;
+
+ case PAM_TEXT_INFO:
+ // Supress prompts (again, making assumptions).
+ break;
+
+ default:
+ (void) fprintf(stderr, "PAM error: unknown message");
+ goto err;
+ }
+ if (errno == EINTR)
+ {
+ goto err;
+ }
+
+ // next message/response
+ m++;
+ r++;
+ }
+ return (PAM_SUCCESS);
+
+err:
+ // Service modules do not clean up responses if an error is returned.
+ // Free responses here.
+ for (j = 0; j < i; j++, r++)
+ {
+ if (r->resp)
+ {
+ // clear before freeing -- may be a password
+ bzero(r->resp, strlen(r->resp));
+ free(r->resp);
+ r->resp = NULL;
+ }
+ }
+ free(r);
+ *resp = NULL;
+ return error;
+}
+#endif
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_SetRootPassword
+ *
+ * Description:
+ * The K_SetRootPassword function sets the password for the root user via
+ * Pluggable Authentication Module (PAM). This function is interactive.
+ *
+ * Input
+ * -----
+ * i_sPassword Password to set
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 if successful, -1 on error
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_SetRootPassword( const char* i_sPassword )
+{
+ // Only supported/tested on Solaris at the moment
+#ifndef K_SOLARIS_PLATFORM
+ return -1;
+#else
+ // Based on sample code from Solaris 10 Software Developer Collection >>
+ // Solaris Security for Developers Guide >>
+ // 3. Writing PAM Applications and Services
+
+ // TODO: Return PAM error codes (to be logged) instead of emitting
+ // messages to screen?
+
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int err;
+
+ conv.conv = pam_tty_conv;
+ conv.appdata_ptr = (void*)i_sPassword;
+
+ // Initialize PAM framework
+ err = pam_start("KeyMgr", "root", &conv, &pamh);
+ if (err != PAM_SUCCESS)
+ {
+ fprintf(stderr, "PAM error: %s\n", pam_strerror(pamh, err));
+ return -1;
+ }
+
+ // Change password
+ err = pam_chauthtok(pamh, 0);
+ if (err != PAM_SUCCESS)
+ {
+ fprintf(stderr, "PAM error: %s\n", pam_strerror(pamh, err));
+ // fall through to cleanup
+ }
+
+ // Cleanup session
+ pam_end(pamh, 0);
+
+ return (err == PAM_SUCCESS) ? 0 : -1;
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_Alarm
+ *
+ * Description:
+ * Calls alarm(2) on Unix in order to cause the operating system to generate
+ * a SIGALRM signal for this process after the given number of real-time
+ * seconds. Does nothing on Windows.
+ *
+ * Input
+ * -----
+ * i_iSeconds Number of seconds after which to generate a SIGALRM
+ * signal
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value If a previous alarm request is pending, then it returns
+ * the number of seconds until this previous request would
+ * have generated a SIGALRM signal. Otherwise, returns 0.
+ *
+ *--------------------------------------------------------------------------*/
+
+unsigned int K_Alarm( unsigned int i_iSeconds )
+{
+#ifndef WIN32
+ return alarm( i_iSeconds );
+#else
+ return 0;
+#endif
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetExtendedVersionFromBase
+ *
+ * Description:
+ * This KMS-specific function prepends the timestamp value to the specified
+ * base replication schema version and returns this value as an extended
+ * replication schema version.
+ *
+ * Input
+ * -----
+ * i_iBaseSchemaVersion Base replication schema version
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Extended replication schema version
+ *
+ *--------------------------------------------------------------------------*/
+
+unsigned int K_GetExtendedVersionFromBase( unsigned int i_iBaseSchemaVersion )
+{
+ // seconds since 1970, force to 32-bit
+#ifdef WIN32
+ INT32 iTimeStamp = (INT32) time(NULL);
+#else
+ int32_t iTimeStamp = (int32_t) time(NULL);
+#endif
+ // minutes since 1970
+ iTimeStamp = iTimeStamp / 60;
+ // minutes since 2000 (approximately)
+ iTimeStamp -= (30*365*24*60);
+ // shift 8 bits to clear out room for schema version #
+ iTimeStamp = iTimeStamp << 8;
+ // add schema version # to lower end
+ iTimeStamp |= i_iBaseSchemaVersion;
+
+ return (unsigned int) iTimeStamp;
+
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ParseTimestampFromExtendedVersion
+ *
+ * Description:
+ * This KMS-specific function parses the timestamp value from the given
+ * extended replication schema version and returns this timestamp value.
+ *
+ * Input
+ * -----
+ * i_iExtendedSchemaVersion Extended replication schema version
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Timestamp value
+ *
+ *--------------------------------------------------------------------------*/
+
+unsigned int K_ParseTimestampFromExtendedVersion(
+ unsigned int i_iExtendedSchemaVersion )
+{
+ unsigned int iTimeStamp = i_iExtendedSchemaVersion >> 8;
+
+ return iTimeStamp;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ParseBaseFromExtendedVersion
+ *
+ * Description:
+ * This KMS-specific function parses the base replication schema value from
+ * the given extended replication schema version and returns this base value.
+ *
+ * Input
+ * -----
+ * i_iExtendedSchemaVersion Extended replication schema version
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Base replication schema value
+ *
+ *--------------------------------------------------------------------------*/
+
+unsigned int K_ParseBaseFromExtendedVersion(
+ unsigned int i_iExtendedSchemaVersion )
+{
+ unsigned int iBaseSchemaVersion = i_iExtendedSchemaVersion & 0x000000FF;
+
+ return iBaseSchemaVersion;
+}
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_System
+ *
+ * Description:
+ * This function is a thread-safe replacement for the unsafe system(3C) call.
+ * See the popen(3C) man page for more information.
+ *
+ * Input
+ * -----
+ * i_sCmd Command to execute
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Termination status of the command language interpreter
+ * if successful, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_System( const char *i_sCmd )
+{
+#ifndef WIN32
+ FILE *p;
+ int rc;
+ struct sigaction sOldAction;
+
+ // Save signal handler
+ sigaction( SIGCHLD, NULL, &sOldAction );
+
+ // Use default child signal handler
+ sigset( SIGCHLD, SIG_DFL );
+
+ p = popen( i_sCmd, "w" );
+ if ( p == NULL )
+ {
+ rc = -1;
+ }
+ else
+ {
+ rc = pclose( p );
+ }
+
+ // Reset signal handler
+ sigset( SIGCHLD, sOldAction.sa_handler );
+
+ return rc;
+#else
+ return system( i_sCmd );
+#endif
+}
+
diff --git a/usr/src/lib/libkmsagent/common/SYSCommon.h b/usr/src/lib/libkmsagent/common/SYSCommon.h
new file mode 100644
index 0000000000..2fd114c4c1
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/SYSCommon.h
@@ -0,0 +1,1168 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*---------------------------------------------------------------------------
+ * Module: System Abstraction Layer
+ *
+ * Description:
+ * The system layer provides an abstract layer for the most commonly
+ * used system calls for multi-platforms including Windows and most
+ * Unix variants.
+ *
+ * All the functions defined in this layer fall into 4 categories:
+ * Threading related functions
+ * Mutexes
+ * Conditional variables
+ * Other Utilities
+ *--------------------------------------------------------------------------*/
+
+#ifndef SYS_COMMON_H
+#define SYS_COMMON_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------------------
+ * ERROR code
+ *--------------------------------------------------------------------------*/
+
+#define K_SYS_OK 0
+#define K_SYS_ERR_NO_MEMORY 1
+#define K_SYS_ERR_CREATE_THREAD 2
+#define K_SYS_ERR_JOIN_THREAD 3
+#define K_SYS_ERR_COND 4
+
+/*---------------------------------------------------------------------------
+ * Header files
+ *--------------------------------------------------------------------------*/
+
+#ifdef WIN32
+ #include <windows.h>
+ #include <process.h>
+#else
+ #include <pthread.h>
+
+ /* UNIX : added by STG */
+ #include <stdlib.h>
+ #include <string.h>
+#ifndef METAWARE
+ #include <wchar.h>
+#endif
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdarg.h>
+
+ /*
+ * These functions are not needed, since the Agent API hides them
+ * enum KeystoneAgent_SortOrder {};
+ * enum KeystoneAgent_FilterOperator {};
+ */
+
+#endif
+
+/*---------------------------------------------------------------------------
+ * MACRO definitions
+ *--------------------------------------------------------------------------*/
+
+#ifdef WIN32
+#define PATH_SEPARATOR '\\'
+#define PATH_SEPARATOR_WSTR L"\\"
+#ifndef PATH_MAX
+#define PATH_MAX MAX_PATH
+#endif
+#else
+#define PATH_SEPARATOR '/'
+#define PATH_SEPARATOR_WSTR L"/"
+#endif
+
+#ifndef BOOL
+#define BOOL int
+#endif
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+#ifdef K_LINUX_PLATFORM
+ #ifndef UNIX
+ #define UNIX
+ #endif
+#endif
+
+#ifdef K_AIX_PLATFORM
+ #ifndef UNIX
+ #define UNIX
+ #endif
+#endif
+
+#ifdef K_SOLARIS_PLATFORM
+ #ifndef UNIX
+ #define UNIX
+ #endif
+#endif
+
+#ifdef K_HPUX_PLATFORM
+ #ifndef UNIX
+ #define UNIX
+ #endif
+#endif
+
+/*---------------------------------------------------------------------------
+ * Fatal error definitions
+ *--------------------------------------------------------------------------*/
+
+#ifndef __FUNCTION__
+#define __FUNCTION__ "(Unknown)"
+#endif
+
+#ifndef FATAL_APPLICATION_STATE
+
+#ifdef DEBUG
+
+#ifdef WIN32
+#include "crtdbg.h"
+#define DEBUG_BREAK() { _CrtDbgBreak(); }
+#else /* WIN32 */
+#ifdef METAWARE
+#define DEBUG_BREAK() (void *) 0x00000000; /* dummy operation */
+#else
+#if !defined(__i386)
+#define DEBUG_BREAK()
+#else
+#ifdef __GNUC__
+#define DEBUG_BREAK() { __asm__ ( "int3" ); } /* NOTE: This only works for x86 platforms */
+#else
+#define DEBUG_BREAK()
+#endif
+#endif /* __i386 */
+#endif /* METAWARE */
+#endif /* WIN32 */
+
+#define FATAL_APPLICATION_STATE() \
+do { \
+ DEBUG_BREAK(); \
+ process_fatal_application_state(__FILE__,__FUNCTION__,__LINE__,0); \
+} while(0)
+
+#define FATAL_APPLICATION_STATE1(additional_text) \
+do { \
+ DEBUG_BREAK(); \
+ process_fatal_application_state(__FILE__,__FUNCTION__,__LINE__,additional_text); \
+} while(0)
+
+#else //DEBUG
+
+#define DEBUG_BREAK()
+
+#define FATAL_APPLICATION_STATE() \
+do { \
+ process_fatal_application_state(__FILE__,__FUNCTION__,__LINE__,0); \
+} while(0)
+
+#define FATAL_APPLICATION_STATE1(additional_text) \
+do { \
+ process_fatal_application_state(__FILE__,__FUNCTION__,__LINE__,additional_text); \
+} while(0)
+
+#endif //DEBUG
+
+#define FATAL_ASSERT(expression) do { if(!(expression)) {FATAL_APPLICATION_STATE();} } while(0)
+#define FATAL_ASSERT1(expression,additional_text) do { if(!(expression)) {FATAL_APPLICATION_STATE1(additional_text);} } while(0)
+
+/* MS Visual Studio compiler does not support __attribute__() */
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
+void process_fatal_application_state(const char* sFile, const char* sFunction, int iLine, const char* sAdditionalText) __attribute__((noreturn));
+
+void generate_stack_trace(const char* i_sFile, const wchar_t* i_wsErrMsg);
+
+#endif /* FATAL_APPLICATION_STATE */
+
+/*---------------------------------------------------------------------------
+ * Primitive type definitions
+ *--------------------------------------------------------------------------*/
+
+#ifdef WIN32
+typedef __int64 int64;
+#else
+#ifndef K_AIX_PLATFORM
+typedef signed long long int64;
+#endif
+#endif
+
+
+#ifdef K_HPUX_PLATFORM
+wchar_t* wcsstr (const wchar_t* haystack, const wchar_t* needle);
+int wprintf (const wchar_t* format, ...);
+int swprintf (wchar_t* s, size_t maxlen, const wchar_t* format, ...);
+int vswprintf (wchar_t* s, size_t maxlen, const wchar_t* format, va_list args);
+int swscanf(const wchar_t *s, const wchar_t *format, ...);
+int64 atoll(const char *str);
+#endif
+
+/*---------------------------------------------------------------------------
+ * Thread type definitions
+ *--------------------------------------------------------------------------*/
+
+#ifdef WIN32
+typedef HANDLE K_THREAD_HANDLE;
+#else
+typedef pthread_t K_THREAD_HANDLE;
+#endif
+
+/*---------------------------------------------------------------------------
+ * Mutex type definitions
+ *--------------------------------------------------------------------------*/
+
+#ifdef WIN32
+
+typedef struct {
+ HANDLE m_handle; /* mutex handle */
+
+ CRITICAL_SECTION m_stCriticalSection; /* criticalSection */
+
+ int m_bIsRecursive;
+} WIN32Mutex;
+
+typedef WIN32Mutex* K_MUTEX_HANDLE;
+
+#else
+typedef pthread_mutex_t* K_MUTEX_HANDLE;
+#endif
+
+/*---------------------------------------------------------------------------
+ * Conditional variable type definitions
+ *--------------------------------------------------------------------------*/
+
+#ifdef WIN32
+ struct K_CondStruct
+ {
+ HANDLE m_hEvent;
+ HANDLE m_hMutex;
+ int m_iSignalAll;
+ int m_iNumWaiting;
+ int m_iSignalled;
+ };
+ typedef struct K_CondStruct K_ConditionalVariable;
+
+#else
+ typedef pthread_cond_t K_ConditionalVariable;
+#endif
+
+/*---------------------------------------------------------------------------
+ * Thread function type definitions
+ *--------------------------------------------------------------------------*/
+
+ /*
+ * Having the function return int breaks compatibility between Windows
+ * and Unix; the function has to return void
+ */
+/*#ifdef WIN32
+ * typedef int (_stdcall *K_ThreadFunc) (void *vpData);
+ *#else
+ */
+ typedef void (*K_ThreadFunc) (void *vpData);
+/*
+ *#endif
+ */
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CreateThread
+ *
+ * Description:
+ * This thread creation function takes a thread function
+ * and its parameter to create a thread. It also has a Boolean
+ * parameter to indicate if the thread is detached or joinable.
+ * A new thread's handle is returned through the output parameter.
+ *
+ * Input
+ * -----
+ * i_pFunc Function pointer of the thread function
+ * i_pvData The point of the parameter passed to the thread function
+ * i_bIsDetached The thread is detached or not. If detached, then it is
+ * not joinable. (Note: It is not supported on Win32)
+ *
+ * Output
+ * ------
+ * o_pNewThread The Thread handle
+ *
+ * Return value Error code
+ *
+ *--------------------------------------------------------------------------*/
+int K_CreateThread(K_ThreadFunc i_pFunc,
+ void *i_pvData,
+ int i_bIsDetached,
+ K_THREAD_HANDLE *o_pNewThread);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_JoinThread
+ *
+ * Description:
+ * This thread joining function is called when the current thread
+ * waits another thread to terminate.
+ *
+ * Input
+ * -----
+ * i_hThread The thread handle of the to-be-joined thread
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error code
+ *
+ *--------------------------------------------------------------------------*/
+int K_JoinThread(K_THREAD_HANDLE i_hThread);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetCurrentThreadId
+ *
+ * Description:
+ * Returns the thread ID of the current thread.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value The thread ID
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_GetCurrentThreadId();
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CreateMutex
+ *
+ * Description:
+ * The mutex creation function creates a mutex according to the given
+ * mutex type, and returns the mutex handle to the output parameter.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * o_phandle the handle pointer to the mutex
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_CreateMutex( K_MUTEX_HANDLE *o_phandle );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_LockMutex
+ *
+ * Description:
+ * K_LockMutex is used to lock the mutex, and K_UnlockMutex is
+ * used to unlock it.
+ *
+ * Input
+ * -----
+ * i_handle the mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+int K_LockMutex(K_MUTEX_HANDLE i_handle);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_UnlockMutex
+ *
+ * Description:
+ * K_UnlockMutex is used to unlock the lock.
+ *
+ * Input
+ * -----
+ * i_handle the mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+int K_UnlockMutex(K_MUTEX_HANDLE i_handle);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_DestroyMutex
+ *
+ * Description:
+ * When a mutex is no longer needed, K_DestroyMutex must be called
+ * to destroy it.
+ *
+ * Input
+ * -----
+ * i_handle the mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_DestroyMutex(K_MUTEX_HANDLE i_handle);
+
+
+/*---------------------------------------------------------------------------
+ *
+ * The following section defines Conditional Variable
+ *
+ * Conditional Variable implements similar functionalities defined
+ * in POSIX thread library. But it only supports conditional variables
+ * inside one process and doesn't support pthread_cond_timedwait().
+*--------------------------------------------------------------------------*/
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_InitConditionalVariable
+ *
+ * Description:
+ * This function initializes a conditional variable; Upon successful
+ * completion, the new condition variable is returned via the condition
+ * parameter, and 0 is returned. Otherwise, an error code is returned.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable which is to be
+ * initialized
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+int K_InitConditionalVariable (K_ConditionalVariable * i_pCond);
+
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_DestroyConditionalVariable
+ *
+ * Description:
+ * This function destroys a conditional variable. Upon successful
+ * completion, the condition variable is destroyed, and 0 is returned.
+ * Otherwise, an error code is returned.
+ * After deletion of the condition variable, the condition parameter
+ * is not valid until it is initialized again by a call to the
+ * K_InitConditionalVariable subroutine.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable which is to be
+ * destroyed
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_DestroyConditionalVariable(K_ConditionalVariable * i_pCond);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_WaitConditionalVariable
+ *
+ * Description:
+ * This function is used to block on a condition variable.
+ * They are called with mutex locked by the calling thread or undefined
+ * behaviour will result.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable
+ * i_handle the companion mutex handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+int K_WaitConditionalVariable(K_ConditionalVariable * i_pCond,
+ K_MUTEX_HANDLE i_handle);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_SignalConditionalVariable
+ *
+ * Description:
+ * This function is used to restart one of the threads that are waiting on
+ * the condition variable. If no threads are waiting on it, nothing happens.
+ * If several threads are waiting on it, exactly one is restarted.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+int K_SignalConditionalVariable(K_ConditionalVariable * i_pCond);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_BroadcastConditionalVariable
+ *
+ * Description:
+ * This function is used to restart all threads that are waiting on
+ * the condition variable.
+ *
+ * Input
+ * -----
+ * i_pCond the pointer to the conditional variable
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Error Code
+ *
+ *--------------------------------------------------------------------------*/
+int K_BroadcastConditionalVariable(K_ConditionalVariable * i_pCond);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_Sleep
+ *
+ * Description:
+ * Sleep for a given period in the given milliseconds.
+ *
+ * Input
+ * -----
+ * i_ms milliseconds
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+void K_Sleep(int i_ms);
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetTickCount
+ *
+ * Description:
+ * The K_GetTickCount function retrieves the number of
+ * milliseconds that have elapsed since the system was started.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value the elasped milliseconds since the system was started
+ *
+ *--------------------------------------------------------------------------*/
+unsigned int K_GetTickCount();
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_AdjustClock
+ *
+ * Description:
+ * The K_AdjustClock function immediately adjusts the system clock by
+ * the given number of seconds. A positive number adjusts the system
+ * clock forward; a negative number adjusts the system clock backward.
+ *
+ * Input
+ * -----
+ * i_iAdjustmentInSeconds Number of seconds by which to adjust the
+ * system clock
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 if successful, 0 on error
+ *
+ *--------------------------------------------------------------------------*/
+int K_AdjustClock( long i_iAdjustmentInSeconds );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_IsLittleEndian
+ *
+ * Description:
+ * Checks to see whether this platform uses little endian integer
+ * representation.
+ *
+ * Input
+ * -----
+ * (none)
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 for little endian
+ *
+ *--------------------------------------------------------------------------*/
+int K_IsLittleEndian();
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_FileLength32
+ *
+ * Description:
+ * Gets the size in bytes of the file associated with the given FILE pointer.
+ *
+ * Input
+ * -----
+ * i_fpFile File handle
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value File size in bytes, or -1L on error
+ *
+ *--------------------------------------------------------------------------*/
+long K_FileLength32( FILE* i_fpFile );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_StringCompareNoCase
+ *
+ * Description:
+ * Compares the two given strings insensitive to case.
+ *
+ * Input
+ * -----
+ * i_sString1 First string
+ * i_sString2 Second string
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 if identical, -1 if first string is less than second
+ * string, or 1 if first string is greater than second
+ *
+ *--------------------------------------------------------------------------*/
+int K_StringCompareNoCase( const char* i_sString1, const char* i_sString2 );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_StringCompareNoCaseWide
+ *
+ * Description:
+ * Compares the two given wide strings insensitive to case.
+ *
+ * Input
+ * -----
+ * i_wsString1 First wide string
+ * i_wsString2 Second wide string
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 if identical, -1 if first string is less than second
+ * string, or 1 if first string is greater than second
+ *
+ *--------------------------------------------------------------------------*/
+int K_StringCompareNoCaseWide( const wchar_t* i_wsString1, const wchar_t* i_wsString2 );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_snprintf
+ *
+ * Description:
+ * See the snprintf(3C) man page.
+ *
+ *--------------------------------------------------------------------------*/
+#ifdef WIN32
+#define K_snprintf _snprintf
+#else
+#define K_snprintf snprintf
+#endif
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_snwprintf
+ *
+ * Description:
+ * See the swprintf(3C) man page.
+ *
+ *--------------------------------------------------------------------------*/
+#ifdef WIN32
+#define K_snwprintf _snwprintf
+#else
+#define K_snwprintf swprintf
+#endif
+
+#ifdef WIN32
+#define K_fseek fseek
+#define K_ftell ftell
+#else
+#define K_fseek fseeko
+#define K_ftell ftello
+#endif
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CreateDirectory
+ *
+ * Description:
+ * Creates a directory with the given path name.
+ *
+ * Input
+ * -----
+ * i_sDirectoryName Directory name
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_CreateDirectory( const char* i_sDirectoryName );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_DeleteFile
+ *
+ * Description:
+ * Deletes the given file.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to delete
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, errno on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_DeleteFile( const char* i_sFilename );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ReadFile
+ *
+ * Description:
+ * Reads from the given file and passes the bytes read back to the output
+ * parameter. The caller must deallocate o_ppFileData using free().
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file from which to read
+ *
+ * Output
+ * ------
+ * o_ppFileData Pointer to bytes read
+ *
+ * Return value Number of bytes read on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_ReadFile( const char* i_sFilename, unsigned char** o_ppFileData );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ReadFileString
+ *
+ * Description:
+ * Reads from the given file and passes the bytes read back to the output
+ * parameter, appending these bytes with a null terminator. There is no
+ * guarantee that there are no non-text characters in the returned "string".
+ * The caller must deallocate o_ppFileData using free().
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file from which to read
+ *
+ * Output
+ * ------
+ * o_psFileDataString Pointer to bytes read
+ *
+ * Return value Number of bytes read (including null terminator) on
+ * success (0 if file is empty), -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_ReadFileString( const char* i_sFilename, char** o_psFileDataString );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_WriteFile
+ *
+ * Description:
+ * Writes the given bytes to the given file.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to which to write
+ * i_pFileData Bytes to write
+ * i_iFileDataSize Number of bytes to write
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, errno or -1 (generic error) on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_WriteFile( const char* i_sFilename, const unsigned char* i_pFileData, int i_iFileDataSize );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_WriteFileString
+ *
+ * Description:
+ * Writes the given null-terminated bytes to the given file. The null
+ * terminator itself is not written to the file.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to which to write
+ * i_sFileData Bytes to write
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 on success, errno or -1 (generic error) on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_WriteFileString( const char* i_sFilename, const char* i_sFileData );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_FileExists
+ *
+ * Description:
+ * Checks to see whehter the given file exists.
+ *
+ * Input
+ * -----
+ * i_sFilename Name of file to check
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 if file exists, 0 if not, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_FileExists( const char* i_sFilename );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_CopyFile
+ *
+ * Description:
+ * Reads from the given source file and writes these bytes to the given
+ * destination file.
+ *
+ * Input
+ * -----
+ * i_sSrcFilename Name of file from which to read
+ * i_sDestFilename Name of file to which to write
+ *
+ * Output
+ * ------
+ * o_pbFileExists Non-zero if the destination file already exists
+ *
+ * Return value 0 on success, errno or -1 (generic error) on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_CopyFile(
+ const char* i_sSrcFilename,
+ const char* i_sDestFilename,
+ int* o_pbFileExists );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetFilenamesInDirectoryCount
+ *
+ * Description:
+ * Reads the given directory and returns the number of files that it contains.
+ *
+ * Input
+ * -----
+ * i_sDirectoryName Name of directory
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Number of files on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_GetFilenamesInDirectoryCount( const char* i_sDirectoryName );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetFilenamesInDirectory
+ *
+ * Description:
+ * Reads the given directory and returns an array of names of files that it
+ * contains. A null pointer appears at the last item in the array. The
+ * caller must deallocate o_pasFilenames by using K_FreeFilenames or by
+ * calling free() for each file name and then calling free() on the array
+ * itself.
+ *
+ * Input
+ * -----
+ * i_sDirectoryName Name of directory
+ *
+ * Output
+ * ------
+ * o_pasFilenames Array of names of files found in this directory
+ *
+ * Return value Number of files on success, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+int K_GetFilenamesInDirectory(
+ const char* i_sDirectoryName,
+ char*** o_pasFilenames );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_FreeFilenames
+ *
+ * Description:
+ * Deallocates the memory allocated in a successful call to
+ * K_GetFilenamesInDirectory.
+ *
+ * Input
+ * -----
+ * i_asFilenames Array of names of files
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value (none)
+ *
+ *--------------------------------------------------------------------------*/
+void K_FreeFilenames( char** i_asFilenames );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_AdjustLocalClock
+ *
+ * Description:
+ * The K_AdjustLocalClock function gradually adjusts the system clock by
+ * the given number of seconds. A positive number adjusts the system
+ * clock forward; a negative number adjusts the system clock backward.
+ *
+ * Input
+ * -----
+ * i_iAdjustmentInSeconds Number of seconds by which to adjust the
+ * system clock
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 1 if successful, 0 on error
+ *
+ *--------------------------------------------------------------------------*/
+int K_AdjustLocalClock( int i_iNumberOfSeconds );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_SetRootPassword
+ *
+ * Description:
+ * The K_SetRootPassword function sets the password for the root user via
+ * Pluggable Authentication Module (PAM). This function is interactive.
+ *
+ * Input
+ * -----
+ * i_sPassword Password to set
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value 0 if successful, -1 on error
+ *
+ *--------------------------------------------------------------------------*/
+int K_SetRootPassword( const char* i_sPassword );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_Alarm
+ *
+ * Description:
+ * Calls alarm(2) on Unix in order to cause the operating system to generate
+ * a SIGALRM signal for this process after the given number of real-time
+ * seconds. Does nothing on Windows.
+ *
+ * Input
+ * -----
+ * i_iSeconds Number of seconds after which to generate a SIGALRM
+ * signal
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value If a previous alarm request is pending, then it returns
+ * the number of seconds until this previous request would
+ * have generated a SIGALRM signal. Otherwise, returns 0.
+ *
+ *--------------------------------------------------------------------------*/
+unsigned int K_Alarm( unsigned int i_iSeconds );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_GetExtendedVersionFromBase
+ *
+ * Description:
+ * This KMS-specific function prepends the timestamp value to the specified
+ * base replication schema version and returns this value as an extended
+ * replication schema version.
+ *
+ * Input
+ * -----
+ * i_iBaseSchemaVersion Base replication schema version
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Extended replication schema version
+ *
+ *--------------------------------------------------------------------------*/
+unsigned int K_GetExtendedVersionFromBase( unsigned int i_iBaseSchemaVersion );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ParseTimestampFromExtendedVersion
+ *
+ * Description:
+ * This KMS-specific function parses the timestamp value from the given
+ * extended replication schema version and returns this timestamp value.
+ *
+ * Input
+ * -----
+ * i_iExtendedSchemaVersion Extended replication schema version
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Timestamp value
+ *
+ *--------------------------------------------------------------------------*/
+unsigned int K_ParseTimestampFromExtendedVersion(
+ unsigned int i_iExtendedSchemaVersion );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_ParseBaseFromExtendedVersion
+ *
+ * Description:
+ * This KMS-specific function parses the base replication schema value from
+ * the given extended replication schema version and returns this base value.
+ *
+ * Input
+ * -----
+ * i_iExtendedSchemaVersion Extended replication schema version
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Base replication schema value
+ *
+ *--------------------------------------------------------------------------*/
+
+unsigned int K_ParseBaseFromExtendedVersion(
+ unsigned int i_iExtendedSchemaVersion );
+
+
+/*---------------------------------------------------------------------------
+ * Function: K_System
+ *
+ * Description:
+ * This function is a thread-safe replacement for the unsafe system(3C) call.
+ * See the popen(3C) man page for more information.
+ *
+ * Input
+ * -----
+ * i_sCmd Command to execute
+ *
+ * Output
+ * ------
+ * (none)
+ *
+ * Return value Termination status of the command language interpreter
+ * if successful, -1 on failure
+ *
+ *--------------------------------------------------------------------------*/
+
+int K_System( const char *i_sCmd );
+
+#define K_system K_System
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/usr/src/lib/libkmsagent/common/debug.h b/usr/src/lib/libkmsagent/common/debug.h
new file mode 100644
index 0000000000..c611bceff8
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/debug.h
@@ -0,0 +1,161 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#ifndef DEBUG_H
+#define DEBUG_H
+
+/************************** START OF MODULE PROLOGUE ***************************
+*
+* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+*
+*-------------------------------------------------------------------------------
+*
+* FUNCTION NAME: di_debug
+*
+* FUNCTION TITLE: Display debug information
+*
+* TASK/PROCESS NAME: Encryption
+*
+* MODULE DESCRIPTION: Define globals and prototypes for displaying debug
+* information.
+*
+* HISTORY:
+* -------
+* 05/13/10 JHD xxxxxxx Added Prologue and prototype for log_cond_printf().
+*
+***************************** END OF MODULE PROLOGUE **************************/
+
+#ifdef DEBUG
+#warn "DEBUG is on"
+#endif
+
+#ifdef DEBUG
+#define START_STACK_CHECK \
+ volatile unsigned long check1 = 0xDEADBABE; \
+ volatile unsigned long check2 = 0xFEEDF00D;
+
+#define END_STACK_CHECK \
+{ \
+ if (check1 != 0xDEADBABE) \
+ log_printf("stack check 1 failed at %s %c\n", __FILE__, __LINE__); \
+ if (check2 != 0xFEEDF00D) \
+ log_printf("stack check 2 failed at %s %c\n", __FILE__, __LINE__); \
+}
+#else
+#define START_STACK_CHECK
+#define END_STACK_CHECK
+#endif
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define OUTMSG_SIZE 256
+
+
+/*-------------------------------------------------------------------
+ * Use the following to define whether memory is actually
+ * going to be allocated for these definitions.
+ *------------------------------------------------------------------*/
+#undef EXTERNAL
+
+#ifdef ALLOCATE_ECPT_TRACE /* This set means we are allocating */
+ #define EXTERNAL
+#else
+ #define EXTERNAL extern
+#endif
+
+#define ECPT_MAX_TRACE 2048
+#define ECPT_TRACE_CHAR 111
+
+typedef struct
+{
+ int task; /* which thread */
+ int tod; /* Time of Day Stamp */
+ int function; /* Function name */
+ int len; /* num chars in buffer */
+ char buf[ ECPT_TRACE_CHAR + 1 ]; /* trace message buffer */
+
+} ECPT_TRACE_ENTRY;
+
+
+typedef struct
+{
+ int index; /* Index to next entry */
+
+ int tx_wait;
+ int tx_ds_main;
+ int tx_rsv1; /* unused */
+ int tx_rsv2; /* unused */
+ int tx_rsv3; /* unused */
+ int tx_rsv4; /* unused */
+ int tx_rsv5; /* unused */
+
+ ECPT_TRACE_ENTRY entry[ ECPT_MAX_TRACE ]; /* Telnet trace entries */
+
+} ECPT_TRACE_STRUCT;
+
+
+EXTERNAL ECPT_TRACE_STRUCT Ecpt_trace_table;
+
+/*--------------------------------------------------------------------------
+ * Define ECPT KMS Agent communications to include in log to telnet clients.
+ *-------------------------------------------------------------------------*/
+EXTERNAL int Ecpt_log_to_telnet;
+
+#define ECPT_LOG_SSL_CB 0x0001
+#define ECPT_LOG_TCP_CONNECT 0x0002
+#define ECPT_LOG_TCP_DISCONNECT 0x0004
+#define ECPT_LOG_TCP_SHUTDOWN 0x0008
+#define ECPT_LOG_TCP_SEND 0x0010
+#define ECPT_LOG_TCP_FRECV 0x0020
+#define ECPT_LOG_TCP_CLOSE 0x0040
+#define ECPT_LOG_SSL_CLIENT 0x0080
+#define ECPT_LOG_AGENT 0x0100
+
+
+extern char outmsg[OUTMSG_SIZE];
+
+void serial_debug_msg(char*, int);
+int log_fprintf(FILE *, const char *, ...);
+int log_sprintf(char*, const char *, ...);
+int log_printf(const char *, ...);
+int log_error_printf(const char *, ...);
+void log_cond_printf(int, const char *, ...);
+
+ECPT_TRACE_ENTRY *ecpt_trace( int function,
+ char *func );
+
+#define ECPT_TRACE( trace, func ) trace = ecpt_trace( (int)func, #func );
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/usr/src/lib/libkmsagent/common/ieee80211_crypto.c b/usr/src/lib/libkmsagent/common/ieee80211_crypto.c
new file mode 100644
index 0000000000..367e8ac932
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/ieee80211_crypto.c
@@ -0,0 +1,201 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+#include "rijndael.h"
+#else
+#include <stdlib.h>
+#include <aes_impl.h>
+#endif
+
+#ifdef METAWARE
+#include "sizet.h"
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#include <string.h>
+#else
+#ifndef WIN32
+#include <strings.h>
+#endif
+#endif
+
+#include "KMSAgentAESKeyWrap.h"
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifdef WIN32
+#define ovbcopy(x, y, z) memmove(y, x, z);
+#else
+#define ovbcopy(x, y, z) bcopy(x, y, z);
+#endif
+
+#ifndef K_SOLARIS_PLATFORM
+/* similar to iovec except that it accepts const pointers */
+struct vector {
+ const void *base;
+ size_t len;
+};
+
+#ifdef METAWARE
+#define bcopy(s1, s2, n) memcpy(s2, s1, n)
+#endif
+
+/*
+ * AES Key Wrap (see RFC 3394).
+ */
+#endif /* K_SOLARIS_PLATFORM */
+
+static const uint8_t aes_key_wrap_iv[8] =
+ { 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6 };
+
+void aes_key_wrap (const uint8_t *kek,
+ size_t kek_len,
+ const uint8_t *pt,
+ size_t len,
+ uint8_t *ct)
+{
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+ rijndael_ctx ctx;
+#else
+ void *ks;
+ size_t ks_size;
+#endif
+ uint8_t *a, *r, ar[16], t, b[16];
+ size_t i;
+ int j;
+
+ /*
+ * Only allow lengths for 't' values that fit within a byte. This
+ * covers all reasonable uses of AES Key Wrap
+ */
+ if (len > (255 / 6)) {
+ return;
+ }
+
+ /* allow ciphertext and plaintext to overlap (ct == pt) */
+ ovbcopy(pt, ct + 8, len * 8);
+
+ a = ct;
+ memcpy(a, aes_key_wrap_iv, 8); /* default IV */
+
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+ rijndael_set_key_enc_only(&ctx, (uint8_t *)kek, kek_len * 8);
+#else
+ ks = aes_alloc_keysched(&ks_size, 0);
+ if (ks == NULL)
+ return;
+ aes_init_keysched(kek, kek_len * 8, ks);
+#endif
+
+ for (j = 0, t = 1; j < 6; j++) {
+ r = ct + 8;
+ for (i = 0; i < len; i++, t++) {
+ memcpy(ar, a, 8);
+ memcpy(ar + 8, r, 8);
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+ rijndael_encrypt(&ctx, ar, b);
+#else
+ (void) aes_encrypt_block(ks, ar, b);
+#endif
+
+ b[7] ^= t;
+ memcpy(a, &b[0], 8);
+ memcpy(r, &b[8], 8);
+
+ r += 8;
+ }
+ }
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+ free(ks);
+#endif
+}
+
+int aes_key_unwrap (const uint8_t *kek,
+ size_t kek_len,
+ const uint8_t *ct,
+ uint8_t *pt,
+ size_t len)
+{
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+ rijndael_ctx ctx;
+#else
+ void *ks;
+ size_t ks_size;
+#endif
+ uint8_t a[8], *r, b[16], t, ar[16];
+ size_t i;
+ int j;
+
+ /*
+ * Only allow lengths for 't' values that fit within a byte. This
+ * covers all reasonable uses of AES Key Wrap
+ */
+ if (len > (255 / 6)) {
+ return (-1);
+ }
+
+ memcpy(a, ct, 8);
+ /* allow ciphertext and plaintext to overlap (ct == pt) */
+ ovbcopy(ct + 8, pt, len * 8);
+
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+ rijndael_set_key(&ctx, (uint8_t *)kek, kek_len * 8);
+#else
+ ks = aes_alloc_keysched(&ks_size, 0);
+ if (ks == NULL)
+ return (-1);
+ aes_init_keysched(kek, kek_len * 8, ks);
+#endif
+
+ for (j = 0, t = 6 * len; j < 6; j++) {
+ r = pt + (len - 1) * 8;
+ for (i = 0; i < len; i++, t--) {
+ memcpy(&ar[0], a, 8);
+ ar[7] ^= t;
+ memcpy(&ar[8], r, 8);
+#if !defined(K_SOLARIS_PLATFORM) || defined(SOLARIS10)
+ rijndael_decrypt(&ctx, ar, b);
+#else
+ (void) aes_decrypt_block(ks, ar, b);
+#endif
+ memcpy(a, b, 8);
+ memcpy(r, b + 8, 8);
+ r -= 8;
+ }
+ }
+#if defined(K_SOLARIS_PLATFORM) && !defined(SOLARIS10)
+ free(ks);
+#endif
+
+ return memcmp(a, aes_key_wrap_iv, 8) != 0;
+}
diff --git a/usr/src/lib/libkmsagent/common/k_setupssl.c b/usr/src/lib/libkmsagent/common/k_setupssl.c
new file mode 100644
index 0000000000..de24e499f0
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/k_setupssl.c
@@ -0,0 +1,223 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*---------------------------------------------------------------------------
+ * Module: k_setupssl.c
+ * Operating System: Linux, Win32
+ *
+ * Description:
+ * This is the C Implementation file for setting up OpenSSL muti-threading environment
+ *
+ *-------------------------------------------------------------------------*/
+
+#ifndef WIN32
+#include <signal.h>
+#include <openssl/evp.h> /* UNIX */
+#include <openssl/engine.h>
+#endif
+
+#include "k_setupssl.h"
+#include "stdsoap2.h"
+#include <openssl/crypto.h>
+
+#if defined(WIN32)
+
+#include <windows.h>
+#define MUTEX_TYPE HANDLE
+#define MUTEX_SETUP(x) (x) = CreateMutex(NULL, FALSE, NULL)
+#define MUTEX_CLEANUP(x) CloseHandle(x)
+#define MUTEX_LOCK(x) WaitForSingleObject((x), INFINITE)
+#define MUTEX_UNLOCK(x) ReleaseMutex(x)
+#define THREAD_ID GetCurrentThreadId()
+
+#else
+
+#include <pthread.h>
+
+# define MUTEX_TYPE pthread_mutex_t
+# define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
+# define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
+# define MUTEX_LOCK(x) pthread_mutex_lock(&(x))
+# define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
+# define THREAD_ID pthread_self()
+
+#ifdef K_SOLARIS_PLATFORM
+MUTEX_TYPE init_ssl_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int ssl_initialized = 0;
+#endif
+#endif
+
+struct CRYPTO_dynlock_value
+{ MUTEX_TYPE mutex;
+};
+
+void sigpipe_handle(int x)
+{
+}
+
+static MUTEX_TYPE *mutex_buf;
+
+static struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line)
+{ struct CRYPTO_dynlock_value *value;
+ value = (struct CRYPTO_dynlock_value*)malloc(sizeof(struct CRYPTO_dynlock_value));
+ if (value)
+ MUTEX_SETUP(value->mutex);
+ return value;
+}
+
+static void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)
+{ if (mode & CRYPTO_LOCK)
+ MUTEX_LOCK(l->mutex);
+ else
+ MUTEX_UNLOCK(l->mutex);
+}
+
+static void dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line)
+{ MUTEX_CLEANUP(l->mutex);
+ free(l);
+}
+
+void kms_locking_function(int mode, int n, const char *file, int line)
+{ if (mode & CRYPTO_LOCK)
+ MUTEX_LOCK(mutex_buf[n]);
+ else
+ MUTEX_UNLOCK(mutex_buf[n]);
+}
+
+
+unsigned long id_function(void )
+{ return (unsigned long)THREAD_ID;
+}
+
+#ifdef WIN32
+void OpenSSL_add_all_ciphers(void); // UNIX
+void OpenSSL_add_all_digests(void);
+#endif
+
+#ifdef K_HPUX_PLATFORM
+extern void allow_unaligned_data_access();
+#endif
+
+// gSOAP 2.7e:
+// The function ssl_init is defined in stdsoap2.cpp and is not exported by
+// default by gSOAP.
+// gSOAP 2.7.12:
+// The function soap_ssl_init is defined in stdsoap2.cpp. It replaces
+// ssl_init and is exported by gSOAP. gSOAP 2.7.13 also supports a new
+// SOAP_SSL_SKIP_HOST_CHECK flag.
+#ifndef SOAP_SSL_SKIP_HOST_CHECK
+extern int ssl_init();
+#endif
+
+int K_SetupSSL()
+{ int i;
+#ifdef K_SOLARIS_PLATFORM
+ if (ssl_initialized)
+ return 1;
+ MUTEX_LOCK(init_ssl_mutex);
+#endif
+ mutex_buf = (MUTEX_TYPE*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(MUTEX_TYPE));
+ if (!mutex_buf) {
+#ifdef K_SOLARIS_PLATFORM
+ MUTEX_UNLOCK(init_ssl_mutex);
+#endif
+ return 0;
+ }
+ for (i = 0; i < CRYPTO_num_locks(); i++)
+ MUTEX_SETUP(mutex_buf[i]);
+ if (CRYPTO_get_id_callback() == NULL)
+ CRYPTO_set_id_callback(id_function);
+ if (CRYPTO_get_locking_callback() == NULL)
+ CRYPTO_set_locking_callback(kms_locking_function);
+
+ CRYPTO_set_dynlock_create_callback(dyn_create_function);
+ CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
+ CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);
+
+#ifndef WIN32
+ /* Need SIGPIPE handler on Unix/Linux systems to catch broken pipes: */
+ signal(SIGPIPE, sigpipe_handle);
+#endif
+#ifdef K_HPUX_PLATFORM
+// signal(SIGBUS, sigpipe_handle);
+ allow_unaligned_data_access();
+#endif
+ OpenSSL_add_all_ciphers();
+ OpenSSL_add_all_digests();
+
+ // call gSOAP's OpenSSL initialization, which initializes SSL algorithms and seeds RAND
+
+ // gSOAP 2.7e:
+ // The function ssl_init is defined in stdsoap2.cpp and is not exported by
+ // default by gSOAP.
+ // gSOAP 2.7.13:
+ // The function soap_ssl_init is defined in stdsoap2.cpp. It replaces
+ // ssl_init and is exported by gSOAP. gSOAP 2.7.13 also supports a new
+ // SOAP_SSL_SKIP_HOST_CHECK flag.
+#ifdef SOAP_SSL_SKIP_HOST_CHECK
+ soap_ssl_init();
+#else
+ ssl_init();
+#endif
+
+#ifdef K_SOLARIS_PLATFORM
+ ssl_initialized = 1;
+ MUTEX_UNLOCK(init_ssl_mutex);
+#endif
+
+ return 1;
+}
+
+void K_CleanupSSL()
+{ int i;
+ if (!mutex_buf)
+ return;
+#ifdef K_SOLARIS_PLATFORM
+ {
+ unsigned long (*id_func)();
+
+ if ((id_func = CRYPTO_get_id_callback()) == id_function) {
+ ENGINE_cleanup();
+ /* EVP_cleanup(); */
+ ERR_free_strings();
+ CRYPTO_set_id_callback(NULL);
+ CRYPTO_set_locking_callback(NULL);
+ }
+ }
+#endif
+ CRYPTO_set_dynlock_create_callback(NULL);
+ CRYPTO_set_dynlock_lock_callback(NULL);
+ CRYPTO_set_dynlock_destroy_callback(NULL);
+ for (i = 0; i < CRYPTO_num_locks(); i++)
+ MUTEX_CLEANUP(mutex_buf[i]);
+ OPENSSL_free(mutex_buf);
+ mutex_buf = NULL;
+}
+
+// TODO: what should 'struct soap' really be?
+int K_SetupCallbacks( struct soap *i_pSoap )
+{
+ return 1;
+}
diff --git a/usr/src/lib/libkmsagent/common/k_setupssl.h b/usr/src/lib/libkmsagent/common/k_setupssl.h
new file mode 100644
index 0000000000..31a956e1d7
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/k_setupssl.h
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+/*---------------------------------------------------------------------------
+ * Module: k_setupssl.h
+ * Operating System: Linux, Win32
+ *
+ * Description:
+ * This is the header file of setting up OpenSSL
+ */
+
+#ifndef _K_SETUP_SSL_H
+#define _K_SETUP_SSL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef METAWARE
+#include "stdsoap2.h"
+/**
+ * set up gSoap I/O callback functions for environments that need to customize
+ * the I/O functions, e.g. embedded agents.
+ */
+int K_SetupCallbacks( struct soap *i_pSoap );
+
+int K_ssl_client_context(struct soap *i_pSoap,
+ int flags,
+ const char *keyfile, /* NULL - SERVER */
+ const char *password, /* NULL - SERVER */
+ const char *cafile,
+ const char *capath, /* ALWAYS NULL */
+ const char *randfile);
+#endif
+
+
+int K_SetupSSL();
+void K_CleanupSSL();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/usr/src/lib/libkmsagent/common/mapfile-vers b/usr/src/lib/libkmsagent/common/mapfile-vers
new file mode 100644
index 0000000000..a35bc1fe2b
--- /dev/null
+++ b/usr/src/lib/libkmsagent/common/mapfile-vers
@@ -0,0 +1,43 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION SUNWprivate {
+ global:
+ KMSAgent_CreateDataUnit;
+ KMSAgent_CreateKey;
+ KMSAgent_DisassociateDataUnitKeys;
+ KMSAgent_FinalizeLibrary;
+ KMSAgent_FreeArrayOfKeys;
+ KMSAgent_InitializeLibrary;
+ KMSAgent_LoadProfile;
+ KMSAgent_RetrieveDataUnit;
+ KMSAgent_RetrieveDataUnitByExternalUniqueID;
+ KMSAgent_RetrieveDataUnitKeys;
+ KMSAgent_UnloadProfile;
+ KMSAgent_ChangeLocalPWD;
+ KMSAgent_GetProfileStatus;
+ local:
+ *;
+};
diff --git a/usr/src/lib/libkmsagent/i386/Makefile b/usr/src/lib/libkmsagent/i386/Makefile
new file mode 100644
index 0000000000..5b0478c540
--- /dev/null
+++ b/usr/src/lib/libkmsagent/i386/Makefile
@@ -0,0 +1,29 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/libkmsagent/sparc/Makefile b/usr/src/lib/libkmsagent/sparc/Makefile
new file mode 100644
index 0000000000..80771356ad
--- /dev/null
+++ b/usr/src/lib/libkmsagent/sparc/Makefile
@@ -0,0 +1,31 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+
+include ../Makefile.com
+sparc_C_PICFLAGS = -KPIC
+sparc_CC_PICFLAGS = -KPIC
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/libkmsagent/sparcv9/Makefile b/usr/src/lib/libkmsagent/sparcv9/Makefile
new file mode 100644
index 0000000000..939e8c7e73
--- /dev/null
+++ b/usr/src/lib/libkmsagent/sparcv9/Makefile
@@ -0,0 +1,28 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/pkcs11/Makefile b/usr/src/lib/pkcs11/Makefile
index 7d14efdd5c..61351cd3c0 100644
--- a/usr/src/lib/pkcs11/Makefile
+++ b/usr/src/lib/pkcs11/Makefile
@@ -18,9 +18,7 @@
#
# CDDL HEADER END
#
-#
-# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
#
# lib/pkcs11/Makefile
@@ -38,6 +36,7 @@ SUBDIRS = \
libsoftcrypto \
libkcfd \
pkcs11_kernel \
+ pkcs11_kms \
pkcs11_softtoken \
pkcs11_tpm
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/Makefile b/usr/src/lib/pkcs11/pkcs11_kms/Makefile
new file mode 100644
index 0000000000..f82f4a6763
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/Makefile
@@ -0,0 +1,43 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include $(SRC)/lib/Makefile.lib
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+check := TARGET= check
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+
+.KEEP_STATE:
+
+all clean clobber install lint: $(SUBDIRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/Makefile.com b/usr/src/lib/pkcs11/pkcs11_kms/Makefile.com
new file mode 100644
index 0000000000..d9f7e19b22
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/Makefile.com
@@ -0,0 +1,99 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+LIBRARY= pkcs11_kms.a
+VERS= .1
+
+CORE_OBJECTS= \
+ kmsAESCrypt.o \
+ kmsAttributeUtil.o \
+ kmsDecrypt.o \
+ kmsDigest.o \
+ kmsDualCrypt.o \
+ kmsEncrypt.o \
+ kmsGeneral.o \
+ kmsKeys.o \
+ kmsKeystoreUtil.o \
+ kmsObject.o \
+ kmsObjectUtil.o \
+ kmsRand.o \
+ kmsSession.o \
+ kmsSessionUtil.o \
+ kmsSign.o \
+ kmsSlottable.o \
+ kmsSlotToken.o \
+ kmsVerify.o
+
+OBJECTS= $(CORE_OBJECTS)
+
+AESDIR= $(SRC)/common/crypto/aes
+KMSAGENTDIR= $(SRC)/lib/libkmsagent/common
+
+include $(SRC)/lib/Makefile.lib
+
+# set signing mode
+POST_PROCESS_SO += ; $(ELFSIGN_CRYPTO)
+
+SRCDIR= ../common
+CORESRCS = $(CORE_OBJECTS:%.o=$(SRCDIR)/%.c)
+
+LIBS = $(DYNLIB)
+LDLIBS += -lc -lcryptoutil -lsoftcrypto -lmd -lavl -lkmsagent
+
+CFLAGS += $(CCVERBOSE)
+
+CPPFLAGS += -DUSESOLARIS_AES -DKMSUSERPKCS12
+
+ROOTLIBDIR= $(ROOT)/usr/lib/security
+ROOTLIBDIR64= $(ROOT)/usr/lib/security/$(MACH64)
+
+lint \
+pics/kmsAESCrypt.o \
+pics/kmsEncrypt.o \
+pics/kmsDecrypt.o \
+pics/kmsSlotToken.o \
+pics/kmsKeystoreUtil.o \
+pics/kmsAttributeUtil.o := CPPFLAGS += -I$(AESDIR) -I$(SRC)/common/crypto
+
+CPPFLAGS += -I$(KMSAGENTDIR)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+#
+# -lkmsagent is not here because it is C++ and we don't lint C++ code.
+#
+LINTLDLIBS = -lc -lcryptoutil -lavl -lmd -lsoftcrypto
+
+LINTFLAGS64 += -errchk=longptr64 -errtags=yes
+
+lintcheck := SRCS = $(CORESRCS)
+lintcheck := LDLIBS = -L$(ROOT)/lib -L$(ROOT)/usr/lib $(LINTLDLIBS)
+
+lintother: $$(OSRCS)
+ $(LINT.c) $(LINTCHECKFLAGS) $(OSRCS) $(LINTLDLIBS)
+
+lint: lintcheck
+
+include $(SRC)/lib/Makefile.targ
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/amd64/Makefile b/usr/src/lib/pkcs11/pkcs11_kms/amd64/Makefile
new file mode 100644
index 0000000000..99c7ac2351
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/amd64/Makefile
@@ -0,0 +1,36 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+
+include ../Makefile.com
+include ../../../Makefile.lib.64
+
+LINTCHECKFLAGS += -erroff=E_INCONS_ARG_DECL2 \
+ -erroff=E_INCONS_ARG_USED2 \
+ -erroff=E_INCONS_VAL_TYPE_DECL2 \
+ -erroff=E_INCONS_VAL_TYPE_USED2 \
+ -erroff=E_FUNC_DECL_VAR_ARG2
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsAESCrypt.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsAESCrypt.c
new file mode 100644
index 0000000000..0e384e0043
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsAESCrypt.c
@@ -0,0 +1,1046 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <security/cryptoki.h>
+#include <aes_impl.h>
+
+#include "kmsSession.h"
+#include "kmsObject.h"
+#include "kmsCrypt.h"
+
+/*
+ * Add padding bytes with the value of length of padding.
+ */
+static void
+kms_add_pkcs7_padding(CK_BYTE *buf, int block_size, CK_ULONG data_len)
+{
+
+ ulong_t i, pad_len;
+ CK_BYTE pad_value;
+
+ pad_len = block_size - (data_len % block_size);
+ pad_value = (CK_BYTE)pad_len;
+
+ for (i = 0; i < pad_len; i++)
+ buf[i] = pad_value;
+}
+
+/*
+ * Remove padding bytes.
+ */
+static CK_RV
+kms_remove_pkcs7_padding(CK_BYTE *pData, CK_ULONG padded_len,
+ CK_ULONG *pulDataLen, int block_size)
+{
+
+ CK_BYTE pad_value;
+ ulong_t i;
+
+ pad_value = pData[padded_len - 1];
+
+
+ /* Make sure there is a valid padding value. */
+ if ((pad_value == 0) || (pad_value > block_size))
+ return (CKR_ENCRYPTED_DATA_INVALID);
+
+ for (i = padded_len - pad_value; i < padded_len; i++)
+ if (pad_value != pData[i])
+ return (CKR_ENCRYPTED_DATA_INVALID);
+
+ *pulDataLen = padded_len - pad_value;
+ return (CKR_OK);
+}
+
+/*
+ * Allocate context for the active encryption or decryption operation, and
+ * generate AES key schedule to speed up the operation.
+ */
+CK_RV
+kms_aes_crypt_init_common(kms_session_t *session_p,
+ CK_MECHANISM_PTR pMechanism, kms_object_t *key_p,
+ boolean_t encrypt)
+{
+ size_t size;
+ kms_aes_ctx_t *kms_aes_ctx;
+
+ kms_aes_ctx = calloc(1, sizeof (kms_aes_ctx_t));
+ if (kms_aes_ctx == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+
+ kms_aes_ctx->key_sched = aes_alloc_keysched(&size, 0);
+
+ if (kms_aes_ctx->key_sched == NULL) {
+ free(kms_aes_ctx);
+ return (CKR_HOST_MEMORY);
+ }
+
+ kms_aes_ctx->keysched_len = size;
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ if (encrypt) {
+ /* Called by C_EncryptInit. */
+ session_p->encrypt.context = kms_aes_ctx;
+ session_p->encrypt.mech.mechanism = pMechanism->mechanism;
+ } else {
+ /* Called by C_DecryptInit. */
+ session_p->decrypt.context = kms_aes_ctx;
+ session_p->decrypt.mech.mechanism = pMechanism->mechanism;
+ }
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ /*
+ * If this is a non-sensitive key and it does NOT have
+ * a key schedule yet, then allocate one and expand it.
+ * Otherwise, if it's a non-sensitive key, and it DOES have
+ * a key schedule already attached to it, just copy the
+ * pre-expanded schedule to the context and avoid the
+ * extra key schedule expansion operation.
+ */
+ if (!(key_p->bool_attr_mask & SENSITIVE_BOOL_ON)) {
+ if (OBJ_KEY_SCHED(key_p) == NULL) {
+ void *ks;
+
+ (void) pthread_mutex_lock(&key_p->object_mutex);
+ if (OBJ_KEY_SCHED(key_p) == NULL) {
+ ks = aes_alloc_keysched(&size, 0);
+ if (ks == NULL) {
+ (void) pthread_mutex_unlock(
+ &key_p->object_mutex);
+ free(kms_aes_ctx);
+ return (CKR_HOST_MEMORY);
+ }
+#ifdef __sparcv9
+ /* LINTED */
+ aes_init_keysched(OBJ_SEC_VALUE(key_p), (uint_t)
+ (OBJ_SEC_VALUE_LEN(key_p) * 8), ks);
+#else /* !__sparcv9 */
+ aes_init_keysched(OBJ_SEC_VALUE(key_p),
+ (OBJ_SEC_VALUE_LEN(key_p) * 8), ks);
+#endif /* __sparcv9 */
+ OBJ_KEY_SCHED_LEN(key_p) = size;
+ OBJ_KEY_SCHED(key_p) = ks;
+ }
+ (void) pthread_mutex_unlock(&key_p->object_mutex);
+ }
+ (void) memcpy(kms_aes_ctx->key_sched, OBJ_KEY_SCHED(key_p),
+ OBJ_KEY_SCHED_LEN(key_p));
+ kms_aes_ctx->keysched_len = OBJ_KEY_SCHED_LEN(key_p);
+ } else {
+ /*
+ * Initialize key schedule for AES. aes_init_keysched()
+ * requires key length in bits.
+ */
+#ifdef __sparcv9
+ /* LINTED */
+ aes_init_keysched(OBJ_SEC_VALUE(key_p), (uint_t)
+ (OBJ_SEC_VALUE_LEN(key_p) * 8), kms_aes_ctx->key_sched);
+#else /* !__sparcv9 */
+ aes_init_keysched(OBJ_SEC_VALUE(key_p),
+ (OBJ_SEC_VALUE_LEN(key_p) * 8), kms_aes_ctx->key_sched);
+#endif /* __sparcv9 */
+ }
+ return (CKR_OK);
+}
+
+/*
+ * kms_aes_encrypt_common()
+ *
+ * Arguments:
+ * session_p: pointer to kms_session_t struct
+ * pData: pointer to the input data to be encrypted
+ * ulDataLen: length of the input data
+ * pEncrypted: pointer to the output data after encryption
+ * pulEncryptedLen: pointer to the length of the output data
+ * update: boolean flag indicates caller is kms_encrypt
+ * or kms_encrypt_update
+ *
+ * Description:
+ * This function calls the corresponding encrypt routine based
+ * on the mechanism.
+ *
+ * Returns:
+ * CKR_OK: success
+ * CKR_BUFFER_TOO_SMALL: the output buffer provided by application
+ * is too small
+ * CKR_FUNCTION_FAILED: encrypt function failed
+ * CKR_DATA_LEN_RANGE: the input data is not a multiple of blocksize
+ */
+CK_RV
+kms_aes_encrypt_common(kms_session_t *session_p, CK_BYTE_PTR pData,
+ CK_ULONG ulDataLen, CK_BYTE_PTR pEncrypted,
+ CK_ULONG_PTR pulEncryptedLen, boolean_t update)
+{
+
+ int rc = 0;
+ CK_RV rv = CKR_OK;
+ kms_aes_ctx_t *kms_aes_ctx =
+ (kms_aes_ctx_t *)session_p->encrypt.context;
+ aes_ctx_t *aes_ctx;
+ CK_MECHANISM_TYPE mechanism = session_p->encrypt.mech.mechanism;
+ CK_BYTE *in_buf = NULL;
+ CK_BYTE *out_buf = NULL;
+ CK_ULONG out_len;
+ CK_ULONG total_len;
+ CK_ULONG remain;
+
+ if (mechanism == CKM_AES_CTR)
+ goto do_encryption;
+
+ /*
+ * AES only takes input length that is a multiple of blocksize
+ * for C_Encrypt function with the mechanism CKM_AES_ECB or
+ * CKM_AES_CBC.
+ *
+ * AES allows any input length for C_Encrypt function with the
+ * mechanism CKM_AES_CBC_PAD and for C_EncryptUpdate function.
+ */
+ if ((!update) && (mechanism != CKM_AES_CBC_PAD)) {
+ if ((ulDataLen % AES_BLOCK_LEN) != 0) {
+ rv = CKR_DATA_LEN_RANGE;
+ goto cleanup;
+ }
+ }
+
+ if (!update) {
+ /*
+ * Called by C_Encrypt
+ */
+ if (mechanism == CKM_AES_CBC_PAD) {
+ /*
+ * For CKM_AES_CBC_PAD, compute output length to
+ * count for the padding. If the length of input
+ * data is a multiple of blocksize, then make output
+ * length to be the sum of the input length and
+ * one blocksize. Otherwise, output length will
+ * be rounded up to the next multiple of blocksize.
+ */
+ out_len = AES_BLOCK_LEN *
+ (ulDataLen / AES_BLOCK_LEN + 1);
+ } else {
+ /*
+ * For non-padding mode, the output length will
+ * be same as the input length.
+ */
+ out_len = ulDataLen;
+ }
+
+ /*
+ * If application asks for the length of the output buffer
+ * to hold the ciphertext?
+ */
+ if (pEncrypted == NULL) {
+ *pulEncryptedLen = out_len;
+ return (CKR_OK);
+ }
+
+ /* Is the application-supplied buffer large enough? */
+ if (*pulEncryptedLen < out_len) {
+ *pulEncryptedLen = out_len;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+
+ /* Encrypt pad bytes in a separate operation */
+ if (mechanism == CKM_AES_CBC_PAD) {
+ out_len -= AES_BLOCK_LEN;
+ }
+
+ in_buf = pData;
+ out_buf = pEncrypted;
+ } else {
+ /*
+ * Called by C_EncryptUpdate
+ *
+ * Add the lengths of last remaining data and current
+ * plaintext together to get the total input length.
+ */
+ total_len = kms_aes_ctx->remain_len + ulDataLen;
+
+ /*
+ * If the total input length is less than one blocksize,
+ * or if the total input length is just one blocksize and
+ * the mechanism is CKM_AES_CBC_PAD, we will need to delay
+ * encryption until when more data comes in next
+ * C_EncryptUpdate or when C_EncryptFinal is called.
+ */
+ if ((total_len < AES_BLOCK_LEN) ||
+ ((mechanism == CKM_AES_CBC_PAD) &&
+ (total_len == AES_BLOCK_LEN))) {
+ if (pEncrypted != NULL) {
+ /*
+ * Save input data and its length in
+ * the remaining buffer of AES context.
+ */
+ (void) memcpy(kms_aes_ctx->data +
+ kms_aes_ctx->remain_len, pData, ulDataLen);
+ kms_aes_ctx->remain_len += ulDataLen;
+ }
+
+ /* Set encrypted data length to 0. */
+ *pulEncryptedLen = 0;
+ return (CKR_OK);
+ }
+
+ /* Compute the length of remaing data. */
+ remain = total_len % AES_BLOCK_LEN;
+
+ /*
+ * Make sure that the output length is a multiple of
+ * blocksize.
+ */
+ out_len = total_len - remain;
+
+ /*
+ * If application asks for the length of the output buffer
+ * to hold the ciphertext?
+ */
+ if (pEncrypted == NULL) {
+ *pulEncryptedLen = out_len;
+ return (CKR_OK);
+ }
+
+ /* Is the application-supplied buffer large enough? */
+ if (*pulEncryptedLen < out_len) {
+ *pulEncryptedLen = out_len;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+
+ if (kms_aes_ctx->remain_len != 0) {
+ /*
+ * Copy last remaining data and current input data
+ * to the output buffer.
+ */
+ (void) memmove(pEncrypted + kms_aes_ctx->remain_len,
+ pData, out_len - kms_aes_ctx->remain_len);
+ (void) memcpy(pEncrypted, kms_aes_ctx->data,
+ kms_aes_ctx->remain_len);
+ bzero(kms_aes_ctx->data, kms_aes_ctx->remain_len);
+
+ in_buf = pEncrypted;
+ } else {
+ in_buf = pData;
+ }
+ out_buf = pEncrypted;
+ }
+
+do_encryption:
+ /*
+ * Begin Encryption now.
+ */
+ switch (mechanism) {
+
+ case CKM_AES_CBC:
+ case CKM_AES_CBC_PAD:
+ {
+ crypto_data_t out;
+
+ out.cd_format = CRYPTO_DATA_RAW;
+ out.cd_offset = 0;
+ out.cd_length = out_len;
+ out.cd_raw.iov_base = (char *)out_buf;
+ out.cd_raw.iov_len = out_len;
+
+ /* Encrypt multiple blocks of data. */
+ rc = aes_encrypt_contiguous_blocks(
+ (aes_ctx_t *)kms_aes_ctx->aes_cbc,
+ (char *)in_buf, out_len, &out);
+
+ if (rc != 0)
+ goto encrypt_failed;
+
+ if (update) {
+ /*
+ * For encrypt update, if there is remaining data,
+ * save it and its length in the context.
+ */
+ if (remain != 0)
+ (void) memcpy(kms_aes_ctx->data, pData +
+ (ulDataLen - remain), remain);
+ kms_aes_ctx->remain_len = remain;
+ } else if (mechanism == CKM_AES_CBC_PAD) {
+ /*
+ * Save the remainder of the input
+ * block in a temporary block because
+ * we dont want to overrun the buffer
+ * by tacking on pad bytes.
+ */
+ CK_BYTE tmpblock[AES_BLOCK_LEN];
+ (void) memcpy(tmpblock, in_buf + out_len,
+ ulDataLen - out_len);
+ kms_add_pkcs7_padding(tmpblock +
+ (ulDataLen - out_len),
+ AES_BLOCK_LEN, ulDataLen - out_len);
+
+ out.cd_offset = out_len;
+ out.cd_length = AES_BLOCK_LEN;
+ out.cd_raw.iov_base = (char *)out_buf;
+ out.cd_raw.iov_len = out_len + AES_BLOCK_LEN;
+
+ /* Encrypt last block containing pad bytes. */
+ rc = aes_encrypt_contiguous_blocks(
+ (aes_ctx_t *)kms_aes_ctx->aes_cbc,
+ (char *)tmpblock, AES_BLOCK_LEN, &out);
+
+ out_len += AES_BLOCK_LEN;
+ }
+
+ if (rc == 0) {
+ *pulEncryptedLen = out_len;
+ break;
+ }
+encrypt_failed:
+ *pulEncryptedLen = 0;
+ rv = CKR_FUNCTION_FAILED;
+ goto cleanup;
+ }
+ default:
+ rv = CKR_MECHANISM_INVALID;
+ goto cleanup;
+ } /* end switch */
+
+ if (update)
+ return (CKR_OK);
+
+ /*
+ * The following code will be executed if the caller is
+ * kms_encrypt() or an error occurred. The encryption
+ * operation will be terminated so we need to do some cleanup.
+ */
+cleanup:
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ aes_ctx = (aes_ctx_t *)kms_aes_ctx->aes_cbc;
+ if (aes_ctx != NULL) {
+ bzero(aes_ctx->ac_keysched, aes_ctx->ac_keysched_len);
+ free(kms_aes_ctx->aes_cbc);
+ }
+
+ bzero(kms_aes_ctx->key_sched, kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+ free(session_p->encrypt.context);
+ session_p->encrypt.context = NULL;
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ return (rv);
+}
+
+
+/*
+ * kms_aes_decrypt_common()
+ *
+ * Arguments:
+ * session_p: pointer to kms_session_t struct
+ * pEncrypted: pointer to the input data to be decrypted
+ * ulEncryptedLen: length of the input data
+ * pData: pointer to the output data
+ * pulDataLen: pointer to the length of the output data
+ * Update: boolean flag indicates caller is kms_decrypt
+ * or kms_decrypt_update
+ *
+ * Description:
+ * This function calls the corresponding decrypt routine based
+ * on the mechanism.
+ *
+ * Returns:
+ * CKR_OK: success
+ * CKR_BUFFER_TOO_SMALL: the output buffer provided by application
+ * is too small
+ * CKR_ENCRYPTED_DATA_LEN_RANGE: the input data is not a multiple
+ * of blocksize
+ * CKR_FUNCTION_FAILED: decrypt function failed
+ */
+CK_RV
+kms_aes_decrypt_common(kms_session_t *session_p, CK_BYTE_PTR pEncrypted,
+ CK_ULONG ulEncryptedLen, CK_BYTE_PTR pData,
+ CK_ULONG_PTR pulDataLen, boolean_t update)
+{
+
+ int rc = 0;
+ CK_RV rv = CKR_OK;
+ kms_aes_ctx_t *kms_aes_ctx =
+ (kms_aes_ctx_t *)session_p->decrypt.context;
+ aes_ctx_t *aes_ctx;
+ CK_MECHANISM_TYPE mechanism = session_p->decrypt.mech.mechanism;
+ CK_BYTE *in_buf = NULL;
+ CK_BYTE *out_buf = NULL;
+ CK_ULONG out_len;
+ CK_ULONG total_len;
+ CK_ULONG remain;
+
+ if (mechanism == CKM_AES_CTR)
+ goto do_decryption;
+
+ /*
+ * AES only takes input length that is a multiple of 16 bytes
+ * for C_Decrypt function with the mechanism CKM_AES_ECB,
+ * CKM_AES_CBC or CKM_AES_CBC_PAD.
+ *
+ * AES allows any input length for C_DecryptUpdate function.
+ */
+ if (!update) {
+ /*
+ * Called by C_Decrypt
+ */
+ if ((ulEncryptedLen % AES_BLOCK_LEN) != 0) {
+ rv = CKR_ENCRYPTED_DATA_LEN_RANGE;
+ goto cleanup;
+ }
+
+ /*
+ * If application asks for the length of the output buffer
+ * to hold the plaintext?
+ */
+ if (pData == NULL) {
+ *pulDataLen = ulEncryptedLen;
+ return (CKR_OK);
+ }
+
+ /* Is the application-supplied buffer large enough? */
+ if (mechanism != CKM_AES_CBC_PAD) {
+ if (*pulDataLen < ulEncryptedLen) {
+ *pulDataLen = ulEncryptedLen;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+ out_len = ulEncryptedLen;
+ } else {
+ /*
+ * For CKM_AES_CBC_PAD, we don't know how
+ * many bytes for padding at this time, so
+ * we'd assume one block was padded.
+ */
+ if (*pulDataLen < (ulEncryptedLen - AES_BLOCK_LEN)) {
+ *pulDataLen = ulEncryptedLen - AES_BLOCK_LEN;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+ out_len = ulEncryptedLen - AES_BLOCK_LEN;
+ }
+ in_buf = pEncrypted;
+ out_buf = pData;
+ } else {
+ /*
+ * Called by C_DecryptUpdate
+ *
+ * Add the lengths of last remaining data and current
+ * input data together to get the total input length.
+ */
+ total_len = kms_aes_ctx->remain_len + ulEncryptedLen;
+
+ /*
+ * If the total input length is less than one blocksize,
+ * or if the total input length is just one blocksize and
+ * the mechanism is CKM_AES_CBC_PAD, we will need to delay
+ * decryption until when more data comes in next
+ * C_DecryptUpdate or when C_DecryptFinal is called.
+ */
+ if ((total_len < AES_BLOCK_LEN) ||
+ ((mechanism == CKM_AES_CBC_PAD) &&
+ (total_len == AES_BLOCK_LEN))) {
+ if (pData != NULL) {
+ /*
+ * Save input data and its length in
+ * the remaining buffer of AES context.
+ */
+ (void) memcpy(kms_aes_ctx->data +
+ kms_aes_ctx->remain_len,
+ pEncrypted, ulEncryptedLen);
+ kms_aes_ctx->remain_len += ulEncryptedLen;
+ }
+
+ /* Set output data length to 0. */
+ *pulDataLen = 0;
+ return (CKR_OK);
+ }
+
+ /* Compute the length of remaing data. */
+ remain = total_len % AES_BLOCK_LEN;
+
+ /*
+ * Make sure that the output length is a multiple of
+ * blocksize.
+ */
+ out_len = total_len - remain;
+
+ if (mechanism == CKM_AES_CBC_PAD) {
+ /*
+ * If the input data length is a multiple of
+ * blocksize, then save the last block of input
+ * data in the remaining buffer. C_DecryptFinal
+ * will handle this last block of data.
+ */
+ if (remain == 0) {
+ remain = AES_BLOCK_LEN;
+ out_len -= AES_BLOCK_LEN;
+ }
+ }
+
+ /*
+ * If application asks for the length of the output buffer
+ * to hold the plaintext?
+ */
+ if (pData == NULL) {
+ *pulDataLen = out_len;
+ return (CKR_OK);
+ }
+
+ /*
+ * Is the application-supplied buffer large enough?
+ */
+ if (*pulDataLen < out_len) {
+ *pulDataLen = out_len;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+
+ if (kms_aes_ctx->remain_len != 0) {
+ /*
+ * Copy last remaining data and current input data
+ * to the output buffer.
+ */
+ (void) memmove(pData + kms_aes_ctx->remain_len,
+ pEncrypted, out_len - kms_aes_ctx->remain_len);
+ (void) memcpy(pData, kms_aes_ctx->data,
+ kms_aes_ctx->remain_len);
+ bzero(kms_aes_ctx->data, kms_aes_ctx->remain_len);
+
+ in_buf = pData;
+ } else {
+ in_buf = pEncrypted;
+ }
+ out_buf = pData;
+ }
+
+do_decryption:
+ /*
+ * Begin Decryption.
+ */
+ switch (mechanism) {
+ case CKM_AES_CBC:
+ case CKM_AES_CBC_PAD:
+ {
+ crypto_data_t out;
+ CK_ULONG rem_len;
+ uint8_t last_block[AES_BLOCK_LEN];
+
+ out.cd_format = CRYPTO_DATA_RAW;
+ out.cd_offset = 0;
+ out.cd_length = out_len;
+ out.cd_raw.iov_base = (char *)out_buf;
+ out.cd_raw.iov_len = out_len;
+
+ /* Decrypt multiple blocks of data. */
+ rc = aes_decrypt_contiguous_blocks(
+ (aes_ctx_t *)kms_aes_ctx->aes_cbc,
+ (char *)in_buf, out_len, &out);
+
+ if (rc != 0)
+ goto decrypt_failed;
+
+ if ((mechanism == CKM_AES_CBC_PAD) && (!update)) {
+ /* Decrypt last block containing pad bytes. */
+ out.cd_offset = 0;
+ out.cd_length = AES_BLOCK_LEN;
+ out.cd_raw.iov_base = (char *)last_block;
+ out.cd_raw.iov_len = AES_BLOCK_LEN;
+
+ /* Decrypt last block containing pad bytes. */
+ rc = aes_decrypt_contiguous_blocks(
+ (aes_ctx_t *)kms_aes_ctx->aes_cbc,
+ (char *)in_buf + out_len, AES_BLOCK_LEN, &out);
+
+ if (rc != 0)
+ goto decrypt_failed;
+
+ /*
+ * Remove padding bytes after decryption of
+ * ciphertext block to produce the original
+ * plaintext.
+ */
+ rv = kms_remove_pkcs7_padding(last_block,
+ AES_BLOCK_LEN, &rem_len, AES_BLOCK_LEN);
+ if (rv == CKR_OK) {
+ if (rem_len != 0)
+ (void) memcpy(out_buf + out_len,
+ last_block, rem_len);
+ *pulDataLen = out_len + rem_len;
+ } else {
+ *pulDataLen = 0;
+ goto cleanup;
+ }
+ } else {
+ *pulDataLen = out_len;
+ }
+
+ if (update) {
+ /*
+ * For decrypt update, if there is remaining data,
+ * save it and its length in the context.
+ */
+ if (remain != 0)
+ (void) memcpy(kms_aes_ctx->data, pEncrypted +
+ (ulEncryptedLen - remain), remain);
+ kms_aes_ctx->remain_len = remain;
+ }
+
+ if (rc == 0)
+ break;
+decrypt_failed:
+ *pulDataLen = 0;
+ rv = CKR_FUNCTION_FAILED;
+ goto cleanup;
+ }
+ default:
+ rv = CKR_MECHANISM_INVALID;
+ goto cleanup;
+ } /* end switch */
+
+ if (update)
+ return (CKR_OK);
+
+ /*
+ * The following code will be executed if the caller is
+ * kms_decrypt() or an error occurred. The decryption
+ * operation will be terminated so we need to do some cleanup.
+ */
+cleanup:
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ aes_ctx = (aes_ctx_t *)kms_aes_ctx->aes_cbc;
+ if (aes_ctx != NULL) {
+ bzero(aes_ctx->ac_keysched, aes_ctx->ac_keysched_len);
+ free(kms_aes_ctx->aes_cbc);
+ }
+
+ bzero(kms_aes_ctx->key_sched, kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+ free(session_p->decrypt.context);
+ session_p->decrypt.context = NULL;
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ return (rv);
+}
+
+
+/*
+ * Allocate and initialize a context for AES CBC mode of operation.
+ */
+void *
+aes_cbc_ctx_init(void *key_sched, size_t size, uint8_t *ivec)
+{
+ aes_ctx_t *aes_ctx;
+
+ if ((aes_ctx = calloc(1, sizeof (aes_ctx_t))) == NULL)
+ return (NULL);
+
+ aes_ctx->ac_keysched = key_sched;
+
+ (void) memcpy(&aes_ctx->ac_iv[0], ivec, AES_BLOCK_LEN);
+
+ aes_ctx->ac_lastp = (uint8_t *)aes_ctx->ac_iv;
+ aes_ctx->ac_keysched_len = size;
+ aes_ctx->ac_flags |= CBC_MODE;
+
+ return ((void *)aes_ctx);
+}
+
+/*
+ * kms_encrypt_final()
+ *
+ * Arguments:
+ * session_p: pointer to kms_session_t struct
+ * pLastEncryptedPart: pointer to the last encrypted data part
+ * pulLastEncryptedPartLen: pointer to the length of the last
+ * encrypted data part
+ *
+ * Description:
+ * called by C_EncryptFinal().
+ *
+ * Returns:
+ * CKR_OK: success
+ * CKR_FUNCTION_FAILED: encrypt final function failed
+ * CKR_DATA_LEN_RANGE: remaining buffer contains bad length
+ */
+CK_RV
+kms_aes_encrypt_final(kms_session_t *session_p, CK_BYTE_PTR pLastEncryptedPart,
+ CK_ULONG_PTR pulLastEncryptedPartLen)
+{
+
+ CK_MECHANISM_TYPE mechanism = session_p->encrypt.mech.mechanism;
+ CK_ULONG out_len;
+ CK_RV rv = CKR_OK;
+ int rc;
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+
+ if (session_p->encrypt.context == NULL) {
+ rv = CKR_OPERATION_NOT_INITIALIZED;
+ *pulLastEncryptedPartLen = 0;
+
+ }
+ if (mechanism == CKM_AES_CBC_PAD) {
+ kms_aes_ctx_t *aes_ctx;
+
+ aes_ctx = (kms_aes_ctx_t *)session_p->encrypt.context;
+ /*
+ * For CKM_AES_CBC_PAD, compute output length with
+ * padding. If the remaining buffer has one block
+ * of data, then output length will be two blocksize of
+ * ciphertext. If the remaining buffer has less than
+ * one block of data, then output length will be
+ * one blocksize.
+ */
+ if (aes_ctx->remain_len == AES_BLOCK_LEN)
+ out_len = 2 * AES_BLOCK_LEN;
+ else
+ out_len = AES_BLOCK_LEN;
+
+ if (pLastEncryptedPart == NULL) {
+ /*
+ * Application asks for the length of the output
+ * buffer to hold the ciphertext.
+ */
+ *pulLastEncryptedPartLen = out_len;
+ goto clean1;
+ } else {
+ crypto_data_t out;
+
+ /* Copy remaining data to the output buffer. */
+ (void) memcpy(pLastEncryptedPart, aes_ctx->data,
+ aes_ctx->remain_len);
+
+ /*
+ * Add padding bytes prior to encrypt final.
+ */
+ kms_add_pkcs7_padding(pLastEncryptedPart +
+ aes_ctx->remain_len, AES_BLOCK_LEN,
+ aes_ctx->remain_len);
+
+ out.cd_format = CRYPTO_DATA_RAW;
+ out.cd_offset = 0;
+ out.cd_length = out_len;
+ out.cd_raw.iov_base = (char *)pLastEncryptedPart;
+ out.cd_raw.iov_len = out_len;
+
+ /* Encrypt multiple blocks of data. */
+ rc = aes_encrypt_contiguous_blocks(
+ (aes_ctx_t *)aes_ctx->aes_cbc,
+ (char *)pLastEncryptedPart, out_len, &out);
+
+ if (rc == 0) {
+ *pulLastEncryptedPartLen = out_len;
+ } else {
+ *pulLastEncryptedPartLen = 0;
+ rv = CKR_FUNCTION_FAILED;
+ }
+
+ /* Cleanup memory space. */
+ free(aes_ctx->aes_cbc);
+ bzero(aes_ctx->key_sched,
+ aes_ctx->keysched_len);
+ free(aes_ctx->key_sched);
+ }
+ } else if (mechanism == CKM_AES_CBC) {
+ kms_aes_ctx_t *aes_ctx;
+
+ aes_ctx = (kms_aes_ctx_t *)session_p->encrypt.context;
+ /*
+ * CKM_AES_CBC and CKM_AES_ECB does not do any padding,
+ * so when the final is called, the remaining buffer
+ * should not contain any more data.
+ */
+ *pulLastEncryptedPartLen = 0;
+ if (aes_ctx->remain_len != 0) {
+ rv = CKR_DATA_LEN_RANGE;
+ } else {
+ if (pLastEncryptedPart == NULL)
+ goto clean1;
+ }
+
+ /* Cleanup memory space. */
+ free(aes_ctx->aes_cbc);
+ bzero(aes_ctx->key_sched, aes_ctx->keysched_len);
+ free(aes_ctx->key_sched);
+ } else {
+ rv = CKR_MECHANISM_INVALID;
+ }
+
+ free(session_p->encrypt.context);
+ session_p->encrypt.context = NULL;
+clean1:
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ return (rv);
+}
+
+/*
+ * kms_decrypt_final()
+ *
+ * Arguments:
+ * session_p: pointer to kms_session_t struct
+ * pLastPart: pointer to the last recovered data part
+ * pulLastPartLen: pointer to the length of the last recovered data part
+ *
+ * Description:
+ * called by C_DecryptFinal().
+ *
+ * Returns:
+ * CKR_OK: success
+ * CKR_FUNCTION_FAILED: decrypt final function failed
+ * CKR_ENCRYPTED_DATA_LEN_RANGE: remaining buffer contains bad length
+ */
+CK_RV
+kms_aes_decrypt_final(kms_session_t *session_p, CK_BYTE_PTR pLastPart,
+ CK_ULONG_PTR pulLastPartLen)
+{
+
+ CK_MECHANISM_TYPE mechanism = session_p->decrypt.mech.mechanism;
+ CK_ULONG out_len;
+ CK_RV rv = CKR_OK;
+ int rc;
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+
+ if (session_p->decrypt.context == NULL) {
+ rv = CKR_OPERATION_NOT_INITIALIZED;
+ *pulLastPartLen = 0;
+ goto clean2;
+ }
+ switch (mechanism) {
+
+ case CKM_AES_CBC_PAD:
+ {
+ kms_aes_ctx_t *kms_aes_ctx;
+ kms_aes_ctx = (kms_aes_ctx_t *)session_p->decrypt.context;
+
+ /*
+ * We should have only one block of data left in the
+ * remaining buffer.
+ */
+ if (kms_aes_ctx->remain_len != AES_BLOCK_LEN) {
+ *pulLastPartLen = 0;
+ rv = CKR_ENCRYPTED_DATA_LEN_RANGE;
+ /* Cleanup memory space. */
+ free(kms_aes_ctx->aes_cbc);
+ bzero(kms_aes_ctx->key_sched,
+ kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+
+ goto clean1;
+ }
+
+ out_len = AES_BLOCK_LEN;
+
+ /*
+ * If application asks for the length of the output buffer
+ * to hold the plaintext?
+ */
+ if (pLastPart == NULL) {
+ *pulLastPartLen = out_len;
+ rv = CKR_OK;
+ goto clean2;
+ } else {
+ crypto_data_t out;
+
+ /* Copy remaining data to the output buffer. */
+ (void) memcpy(pLastPart, kms_aes_ctx->data,
+ AES_BLOCK_LEN);
+
+ out.cd_format = CRYPTO_DATA_RAW;
+ out.cd_offset = 0;
+ out.cd_length = AES_BLOCK_LEN;
+ out.cd_raw.iov_base = (char *)pLastPart;
+ out.cd_raw.iov_len = AES_BLOCK_LEN;
+
+ /* Decrypt final block of data. */
+ rc = aes_decrypt_contiguous_blocks(
+ (aes_ctx_t *)kms_aes_ctx->aes_cbc,
+ (char *)pLastPart, AES_BLOCK_LEN, &out);
+
+ if (rc == 0) {
+ /*
+ * Remove padding bytes after decryption of
+ * ciphertext block to produce the original
+ * plaintext.
+ */
+ rv = kms_remove_pkcs7_padding(pLastPart,
+ AES_BLOCK_LEN, &out_len, AES_BLOCK_LEN);
+ if (rv != CKR_OK)
+ *pulLastPartLen = 0;
+ else
+ *pulLastPartLen = out_len;
+ } else {
+ *pulLastPartLen = 0;
+ rv = CKR_FUNCTION_FAILED;
+ }
+
+ /* Cleanup memory space. */
+ free(kms_aes_ctx->aes_cbc);
+ bzero(kms_aes_ctx->key_sched,
+ kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+
+ }
+
+ break;
+ }
+
+ case CKM_AES_CBC:
+ {
+ kms_aes_ctx_t *kms_aes_ctx;
+
+ kms_aes_ctx = (kms_aes_ctx_t *)session_p->decrypt.context;
+ /*
+ * CKM_AES_CBC and CKM_AES_ECB does not do any padding,
+ * so when the final is called, the remaining buffer
+ * should not contain any more data.
+ */
+ *pulLastPartLen = 0;
+ if (kms_aes_ctx->remain_len != 0) {
+ rv = CKR_ENCRYPTED_DATA_LEN_RANGE;
+ } else {
+ if (pLastPart == NULL)
+ goto clean2;
+ }
+
+ /* Cleanup memory space. */
+ free(kms_aes_ctx->aes_cbc);
+ bzero(kms_aes_ctx->key_sched, kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+
+ break;
+ }
+ default:
+ /* PKCS11: The mechanism only supports single-part operation. */
+ rv = CKR_MECHANISM_INVALID;
+ break;
+ }
+
+clean1:
+ free(session_p->decrypt.context);
+ session_p->decrypt.context = NULL;
+
+clean2:
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ return (rv);
+
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsAttributeUtil.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsAttributeUtil.c
new file mode 100644
index 0000000000..69d62bec2b
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsAttributeUtil.c
@@ -0,0 +1,1726 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <security/cryptoki.h>
+#include <sys/crypto/common.h>
+#include <aes_impl.h>
+#include "kmsGlobal.h"
+#include "kmsObject.h"
+#include "kmsSession.h"
+#include "kmsSlot.h"
+
+/*
+ * This attribute table is used by the kms_lookup_attr()
+ * to validate the attributes.
+ */
+CK_ATTRIBUTE_TYPE attr_map[] = {
+ CKA_PRIVATE,
+ CKA_LABEL,
+ CKA_APPLICATION,
+ CKA_OBJECT_ID,
+ CKA_CERTIFICATE_TYPE,
+ CKA_ISSUER,
+ CKA_SERIAL_NUMBER,
+ CKA_AC_ISSUER,
+ CKA_OWNER,
+ CKA_ATTR_TYPES,
+ CKA_SUBJECT,
+ CKA_ID,
+ CKA_SENSITIVE,
+ CKA_START_DATE,
+ CKA_END_DATE,
+ CKA_MODULUS,
+ CKA_MODULUS_BITS,
+ CKA_PUBLIC_EXPONENT,
+ CKA_PRIVATE_EXPONENT,
+ CKA_PRIME_1,
+ CKA_PRIME_2,
+ CKA_EXPONENT_1,
+ CKA_EXPONENT_2,
+ CKA_COEFFICIENT,
+ CKA_PRIME,
+ CKA_SUBPRIME,
+ CKA_BASE,
+ CKA_EXTRACTABLE,
+ CKA_LOCAL,
+ CKA_NEVER_EXTRACTABLE,
+ CKA_ALWAYS_SENSITIVE,
+ CKA_MODIFIABLE,
+ CKA_ECDSA_PARAMS,
+ CKA_EC_POINT,
+ CKA_SECONDARY_AUTH,
+ CKA_AUTH_PIN_FLAGS,
+ CKA_HW_FEATURE_TYPE,
+ CKA_RESET_ON_INIT,
+ CKA_HAS_RESET
+};
+
+/*
+ * attributes that exists only in secret key objects
+ * Note: some attributes may also exist in one or two
+ * other object classes, but they are also listed
+ * because not all object have them.
+ */
+CK_ATTRIBUTE_TYPE SECRET_KEY_ATTRS[] =
+{
+ CKA_VALUE_LEN,
+ CKA_ENCRYPT,
+ CKA_DECRYPT,
+ CKA_WRAP,
+ CKA_UNWRAP,
+ CKA_SIGN,
+ CKA_VERIFY,
+ CKA_SENSITIVE,
+ CKA_EXTRACTABLE,
+ CKA_NEVER_EXTRACTABLE,
+ CKA_ALWAYS_SENSITIVE
+};
+
+/*
+ * Validate the attribute by using binary search algorithm.
+ */
+CK_RV
+kms_lookup_attr(CK_ATTRIBUTE_TYPE type)
+{
+ size_t lower, middle, upper;
+
+ lower = 0;
+ upper = (sizeof (attr_map) / sizeof (CK_ATTRIBUTE_TYPE)) - 1;
+
+ while (lower <= upper) {
+ /* Always starts from middle. */
+ middle = (lower + upper) / 2;
+
+ if (type > attr_map[middle]) {
+ /* Adjust the lower bound to upper half. */
+ lower = middle + 1;
+ continue;
+ }
+
+ if (type == attr_map[middle]) {
+ /* Found it. */
+ return (CKR_OK);
+ }
+
+ if (type < attr_map[middle]) {
+ /* Adjust the upper bound to lower half. */
+ upper = middle - 1;
+ continue;
+ }
+ }
+
+ /* Failed to find the matching attribute from the attribute table. */
+ return (CKR_ATTRIBUTE_TYPE_INVALID);
+}
+
+
+/*
+ * Validate the attribute by using the following search algorithm:
+ *
+ * 1) Search for the most frequently used attributes first.
+ * 2) If not found, search for the usage-purpose attributes - these
+ * attributes have dense set of values, therefore compiler will
+ * optimize it with a branch table and branch to the appropriate
+ * case.
+ * 3) If still not found, use binary search for the rest of the
+ * attributes in the attr_map[] table.
+ */
+CK_RV
+kms_validate_attr(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum,
+ CK_OBJECT_CLASS *class)
+{
+
+ CK_ULONG i;
+ CK_RV rv = CKR_OK;
+
+ for (i = 0; i < ulAttrNum; i++) {
+ /* First tier search */
+ switch (template[i].type) {
+ case CKA_CLASS:
+ *class = *((CK_OBJECT_CLASS*)template[i].pValue);
+ break;
+ case CKA_TOKEN:
+ break;
+ case CKA_KEY_TYPE:
+ break;
+ case CKA_VALUE:
+ break;
+ case CKA_VALUE_LEN:
+ break;
+ case CKA_VALUE_BITS:
+ break;
+ default:
+ /* Second tier search */
+ switch (template[i].type) {
+ case CKA_ENCRYPT:
+ break;
+ case CKA_DECRYPT:
+ break;
+ case CKA_WRAP:
+ break;
+ case CKA_UNWRAP:
+ break;
+ case CKA_SIGN:
+ break;
+ case CKA_SIGN_RECOVER:
+ break;
+ case CKA_VERIFY:
+ break;
+ case CKA_VERIFY_RECOVER:
+ break;
+ case CKA_DERIVE:
+ break;
+ default:
+ /* Third tier search */
+ rv = kms_lookup_attr(template[i].type);
+ if (rv != CKR_OK)
+ return (rv);
+ break;
+ }
+ break;
+ }
+ }
+ return (rv);
+}
+
+
+/*
+ * Clean up and release all the storage in the extra attribute list
+ * of an object.
+ */
+void
+kms_cleanup_extra_attr(kms_object_t *object_p)
+{
+
+ CK_ATTRIBUTE_INFO_PTR extra_attr;
+ CK_ATTRIBUTE_INFO_PTR tmp;
+
+ if (object_p == NULL)
+ return;
+
+ extra_attr = object_p->extra_attrlistp;
+ while (extra_attr) {
+ tmp = extra_attr->next;
+ if (extra_attr->attr.pValue)
+ /*
+ * All extra attributes in the extra attribute
+ * list have pValue points to the value of the
+ * attribute (with simple byte array type).
+ * Free the storage for the value of the attribute.
+ */
+ free(extra_attr->attr.pValue);
+
+ /* Free the storage for the attribute_info struct. */
+ free(extra_attr);
+ extra_attr = tmp;
+ }
+
+ object_p->extra_attrlistp = NULL;
+}
+
+/*
+ * Create the attribute_info struct to hold the object's attribute,
+ * and add it to the extra attribute list of an object.
+ */
+CK_RV
+kms_add_extra_attr(CK_ATTRIBUTE_PTR template, kms_object_t *object_p)
+{
+
+ CK_ATTRIBUTE_INFO_PTR attrp;
+
+ /* Allocate the storage for the attribute_info struct. */
+ attrp = calloc(1, sizeof (attribute_info_t));
+ if (attrp == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+
+ /* Set up attribute_info struct. */
+ attrp->attr.type = template->type;
+ attrp->attr.ulValueLen = template->ulValueLen;
+
+ if ((template->pValue != NULL) &&
+ (template->ulValueLen > 0)) {
+ /* Allocate storage for the value of the attribute. */
+ attrp->attr.pValue = malloc(template->ulValueLen);
+ if (attrp->attr.pValue == NULL) {
+ free(attrp);
+ return (CKR_HOST_MEMORY);
+ }
+
+ (void) memcpy(attrp->attr.pValue, template->pValue,
+ template->ulValueLen);
+ } else {
+ attrp->attr.pValue = NULL;
+ }
+
+ /* Insert the new attribute in front of extra attribute list. */
+ if (object_p->extra_attrlistp == NULL) {
+ object_p->extra_attrlistp = attrp;
+ attrp->next = NULL;
+ } else {
+ attrp->next = object_p->extra_attrlistp;
+ object_p->extra_attrlistp = attrp;
+ }
+
+ return (CKR_OK);
+}
+
+/*
+ * Copy the attribute_info struct from the old object to a new attribute_info
+ * struct, and add that new struct to the extra attribute list of the new
+ * object.
+ */
+CK_RV
+kms_copy_extra_attr(CK_ATTRIBUTE_INFO_PTR old_attrp,
+ kms_object_t *object_p)
+{
+ CK_ATTRIBUTE_INFO_PTR attrp;
+
+ /* Allocate attribute_info struct. */
+ attrp = calloc(1, sizeof (attribute_info_t));
+ if (attrp == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+
+ attrp->attr.type = old_attrp->attr.type;
+ attrp->attr.ulValueLen = old_attrp->attr.ulValueLen;
+
+ if ((old_attrp->attr.pValue != NULL) &&
+ (old_attrp->attr.ulValueLen > 0)) {
+ attrp->attr.pValue = malloc(old_attrp->attr.ulValueLen);
+ if (attrp->attr.pValue == NULL) {
+ free(attrp);
+ return (CKR_HOST_MEMORY);
+ }
+
+ (void) memcpy(attrp->attr.pValue, old_attrp->attr.pValue,
+ old_attrp->attr.ulValueLen);
+ } else {
+ attrp->attr.pValue = NULL;
+ }
+
+ /* Insert the new attribute in front of extra attribute list */
+ if (object_p->extra_attrlistp == NULL) {
+ object_p->extra_attrlistp = attrp;
+ attrp->next = NULL;
+ } else {
+ attrp->next = object_p->extra_attrlistp;
+ object_p->extra_attrlistp = attrp;
+ }
+
+ return (CKR_OK);
+}
+
+/*
+ * Get the attribute triple from the extra attribute list in the object
+ * (if the specified attribute type is found), and copy it to a template.
+ * Note the type of the attribute to be copied is specified by the template,
+ * and the storage is pre-allocated for the atrribute value in the template
+ * for doing the copy.
+ */
+CK_RV
+get_extra_attr_from_object(kms_object_t *object_p, CK_ATTRIBUTE_PTR template)
+{
+ CK_ATTRIBUTE_INFO_PTR extra_attr;
+ CK_ATTRIBUTE_TYPE type = template->type;
+
+ extra_attr = object_p->extra_attrlistp;
+
+ while (extra_attr) {
+ if (type == extra_attr->attr.type) {
+ /* Found it. */
+ break;
+ } else {
+ /* Does not match, try next one. */
+ extra_attr = extra_attr->next;
+ }
+ }
+
+ if (extra_attr == NULL) {
+ /* A valid but un-initialized attribute. */
+ template->ulValueLen = 0;
+ return (CKR_OK);
+ }
+
+ /*
+ * We found the attribute in the extra attribute list.
+ */
+ if (template->pValue == NULL) {
+ template->ulValueLen = extra_attr->attr.ulValueLen;
+ return (CKR_OK);
+ }
+
+ if (template->ulValueLen >= extra_attr->attr.ulValueLen) {
+ /*
+ * The buffer provided by the application is large
+ * enough to hold the value of the attribute.
+ */
+ (void) memcpy(template->pValue, extra_attr->attr.pValue,
+ extra_attr->attr.ulValueLen);
+ template->ulValueLen = extra_attr->attr.ulValueLen;
+ return (CKR_OK);
+ } else {
+ /*
+ * The buffer provided by the application does
+ * not have enough space to hold the value.
+ */
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+}
+
+/*
+ * Modify the attribute triple in the extra attribute list of the object
+ * if the specified attribute type is found. Otherwise, just add it to
+ * list.
+ */
+CK_RV
+set_extra_attr_to_object(kms_object_t *object_p, CK_ATTRIBUTE_TYPE type,
+ CK_ATTRIBUTE_PTR template)
+{
+ CK_ATTRIBUTE_INFO_PTR extra_attr;
+
+ extra_attr = object_p->extra_attrlistp;
+
+ while (extra_attr) {
+ if (type == extra_attr->attr.type) {
+ /* Found it. */
+ break;
+ } else {
+ /* Does not match, try next one. */
+ extra_attr = extra_attr->next;
+ }
+ }
+
+ if (extra_attr == NULL) {
+ /*
+ * This attribute is a new one, go ahead adding it to
+ * the extra attribute list.
+ */
+ return (kms_add_extra_attr(template, object_p));
+ }
+
+ /* We found the attribute in the extra attribute list. */
+ if ((template->pValue != NULL) &&
+ (template->ulValueLen > 0)) {
+ if (template->ulValueLen > extra_attr->attr.ulValueLen) {
+ /* The old buffer is too small to hold the new value. */
+ if (extra_attr->attr.pValue != NULL)
+ /* Free storage for the old attribute value. */
+ free(extra_attr->attr.pValue);
+
+ /* Allocate storage for the new attribute value. */
+ extra_attr->attr.pValue = malloc(template->ulValueLen);
+ if (extra_attr->attr.pValue == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+ }
+
+ /* Replace the attribute with new value. */
+ extra_attr->attr.ulValueLen = template->ulValueLen;
+ (void) memcpy(extra_attr->attr.pValue, template->pValue,
+ template->ulValueLen);
+ } else {
+ extra_attr->attr.pValue = NULL;
+ }
+
+ return (CKR_OK);
+}
+
+/*
+ * Copy the boolean data type attribute value from an object for the
+ * specified attribute to the template.
+ */
+CK_RV
+get_bool_attr_from_object(kms_object_t *object_p, CK_ULONG bool_flag,
+ CK_ATTRIBUTE_PTR template)
+{
+
+ if (template->pValue == NULL) {
+ template->ulValueLen = sizeof (CK_BBOOL);
+ return (CKR_OK);
+ }
+
+ if (template->ulValueLen >= sizeof (CK_BBOOL)) {
+ /*
+ * The buffer provided by the application is large
+ * enough to hold the value of the attribute.
+ */
+ if (object_p->bool_attr_mask & bool_flag) {
+ *((CK_BBOOL *)template->pValue) = B_TRUE;
+ } else {
+ *((CK_BBOOL *)template->pValue) = B_FALSE;
+ }
+
+ template->ulValueLen = sizeof (CK_BBOOL);
+ return (CKR_OK);
+ } else {
+ /*
+ * The buffer provided by the application does
+ * not have enough space to hold the value.
+ */
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+}
+
+/*
+ * Set the boolean data type attribute value in the object.
+ */
+CK_RV
+set_bool_attr_to_object(kms_object_t *object_p, CK_ULONG bool_flag,
+ CK_ATTRIBUTE_PTR template)
+{
+
+ if (*(CK_BBOOL *)template->pValue)
+ object_p->bool_attr_mask |= bool_flag;
+ else
+ object_p->bool_attr_mask &= ~bool_flag;
+
+ return (CKR_OK);
+}
+
+
+/*
+ * Copy the CK_ULONG data type attribute value from an object to the
+ * template.
+ */
+CK_RV
+get_ulong_attr_from_object(CK_ULONG value, CK_ATTRIBUTE_PTR template)
+{
+
+ if (template->pValue == NULL) {
+ template->ulValueLen = sizeof (CK_ULONG);
+ return (CKR_OK);
+ }
+
+ if (template->ulValueLen >= sizeof (CK_ULONG)) {
+ /*
+ * The buffer provided by the application is large
+ * enough to hold the value of the attribute.
+ */
+ *(CK_ULONG_PTR)template->pValue = value;
+ template->ulValueLen = sizeof (CK_ULONG);
+ return (CKR_OK);
+ } else {
+ /*
+ * The buffer provided by the application does
+ * not have enough space to hold the value.
+ */
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+}
+
+CK_RV
+get_string_from_template(CK_ATTRIBUTE_PTR dest, CK_ATTRIBUTE_PTR src)
+{
+ if ((src->pValue != NULL) &&
+ (src->ulValueLen > 0)) {
+ /* Allocate storage for the value of the attribute. */
+ dest->pValue = malloc(src->ulValueLen);
+ if (dest->pValue == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+
+ (void) memcpy(dest->pValue, src->pValue,
+ src->ulValueLen);
+ dest->ulValueLen = src->ulValueLen;
+ dest->type = src->type;
+ } else {
+ dest->pValue = NULL;
+ dest->ulValueLen = 0;
+ dest->type = src->type;
+ }
+
+ return (CKR_OK);
+
+}
+
+void
+string_attr_cleanup(CK_ATTRIBUTE_PTR template)
+{
+
+ if (template->pValue) {
+ free(template->pValue);
+ template->pValue = NULL;
+ template->ulValueLen = 0;
+ }
+}
+
+/*
+ * Parse the common attributes. Return to caller with appropriate return
+ * value to indicate if the supplied template specifies a valid attribute
+ * with a valid value.
+ */
+static CK_RV
+kms_parse_common_attrs(CK_ATTRIBUTE_PTR template, uint64_t *attr_mask_p)
+{
+ CK_RV rv = CKR_OK;
+ kms_slot_t *pslot = get_slotinfo();
+
+ switch (template->type) {
+ case CKA_CLASS:
+ break;
+ case CKA_TOKEN:
+ if ((*(CK_BBOOL *)template->pValue) == TRUE)
+ *attr_mask_p |= TOKEN_BOOL_ON;
+ break;
+
+ case CKA_PRIVATE:
+ if ((*(CK_BBOOL *)template->pValue) == TRUE) {
+ /*
+ * Cannot create a private object if the token
+ * has a keystore and the user isn't logged in.
+ */
+ if (pslot->sl_state != CKU_USER) {
+ rv = CKR_ATTRIBUTE_VALUE_INVALID;
+ } else {
+ *attr_mask_p |= PRIVATE_BOOL_ON;
+ }
+ }
+ break;
+
+ case CKA_MODIFIABLE:
+ if ((*(CK_BBOOL *)template->pValue) == FALSE) {
+ *attr_mask_p &= ~MODIFIABLE_BOOL_ON;
+ }
+ break;
+
+ case CKA_LABEL:
+ break;
+
+ default:
+ rv = CKR_TEMPLATE_INCONSISTENT;
+ }
+
+ return (rv);
+}
+
+/*
+ * Build a Secret Key Object.
+ *
+ * - Parse the object's template, and when an error is detected such as
+ * invalid attribute type, invalid attribute value, etc., return
+ * with appropriate return value.
+ * - Set up attribute mask field in the object for the supplied common
+ * attributes that have boolean type.
+ * - Build the attribute_info struct to hold the value of each supplied
+ * attribute that has byte array type. Link attribute_info structs
+ * together to form the extra attribute list of the object.
+ * - Allocate storage for the Secret Key object.
+ * - Build the Secret Key object. Allocate storage to hold the big integer
+ * value for the attribute CKA_VALUE that is required for all the key
+ * types supported by secret key object.
+ *
+ */
+CK_RV
+kms_build_secret_key_object(CK_ATTRIBUTE_PTR template,
+ CK_ULONG ulAttrNum, kms_object_t *new_object)
+{
+ int i;
+ CK_KEY_TYPE keytype = (CK_KEY_TYPE)~0UL;
+ uint64_t attr_mask;
+ CK_RV rv = CKR_OK;
+ int isLabel = 0;
+ /* Must not set flags */
+ int isValueLen = 0;
+ CK_ATTRIBUTE string_tmp;
+ secret_key_obj_t *sck;
+
+ string_tmp.pValue = NULL;
+
+ /*
+ * If the object was pulled from the KMS, the
+ * attributes are encoded in the object record
+ * before this function is called, we don't
+ * want to overwrite them unless the attribute
+ * template says differently.
+ */
+ if (new_object->bool_attr_mask != 0)
+ attr_mask = new_object->bool_attr_mask;
+ else
+ attr_mask = SECRET_KEY_DEFAULT;
+
+ /* Allocate storage for Secret Key Object. */
+ sck = calloc(1, sizeof (secret_key_obj_t));
+ if (sck == NULL) {
+ rv = CKR_HOST_MEMORY;
+ goto fail_cleanup;
+ }
+
+ new_object->object_class_u.secret_key = sck;
+ new_object->class = CKO_SECRET_KEY;
+
+ for (i = 0; i < ulAttrNum; i++) {
+
+ /* Secret Key Object Attributes */
+ switch (template[i].type) {
+
+ /* common key attributes */
+ case CKA_KEY_TYPE:
+ keytype = *((CK_KEY_TYPE*)template[i].pValue);
+ break;
+
+ case CKA_ID:
+ case CKA_START_DATE:
+ case CKA_END_DATE:
+ /*
+ * Allocate storage to hold the attribute
+ * value with byte array type, and add it to
+ * the extra attribute list of the object.
+ */
+ rv = kms_add_extra_attr(&template[i],
+ new_object);
+ if (rv != CKR_OK) {
+ goto fail_cleanup;
+ }
+ break;
+
+ /*
+ * The following key related attribute types must
+ * not be specified by C_CreateObject.
+ */
+ case CKA_LOCAL:
+ case CKA_KEY_GEN_MECHANISM:
+ case CKA_ALWAYS_SENSITIVE:
+ case CKA_NEVER_EXTRACTABLE:
+ rv = CKR_TEMPLATE_INCONSISTENT;
+ goto fail_cleanup;
+
+ /* Key related boolean attributes */
+ case CKA_DERIVE:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= DERIVE_BOOL_ON;
+ break;
+
+ case CKA_SENSITIVE:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= SENSITIVE_BOOL_ON;
+ break;
+
+ case CKA_ENCRYPT:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= ENCRYPT_BOOL_ON;
+ else
+ attr_mask &= ~ENCRYPT_BOOL_ON;
+ break;
+
+ case CKA_DECRYPT:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= DECRYPT_BOOL_ON;
+ else
+ attr_mask &= ~DECRYPT_BOOL_ON;
+ break;
+
+ case CKA_SIGN:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= SIGN_BOOL_ON;
+ else
+ attr_mask &= ~SIGN_BOOL_ON;
+ break;
+
+ case CKA_VERIFY:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= VERIFY_BOOL_ON;
+ else
+ attr_mask &= ~VERIFY_BOOL_ON;
+ break;
+
+ case CKA_WRAP:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= WRAP_BOOL_ON;
+ break;
+
+ case CKA_UNWRAP:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= UNWRAP_BOOL_ON;
+ break;
+
+ case CKA_EXTRACTABLE:
+ if (*(CK_BBOOL *)template[i].pValue)
+ attr_mask |= EXTRACTABLE_BOOL_ON;
+ else
+ attr_mask &= ~EXTRACTABLE_BOOL_ON;
+ break;
+
+ case CKA_VALUE:
+ if ((template[i].ulValueLen == 0) ||
+ (template[i].pValue == NULL)) {
+ rv = CKR_ATTRIBUTE_VALUE_INVALID;
+ goto fail_cleanup;
+ }
+ /*
+ * Copyin attribute from template
+ * to a local variable.
+ */
+ sck->sk_value = malloc(template[i].ulValueLen);
+ if (sck->sk_value == NULL) {
+ rv = CKR_HOST_MEMORY;
+ goto fail_cleanup;
+ }
+ (void) memcpy(sck->sk_value, template[i].pValue,
+ template[i].ulValueLen);
+ sck->sk_value_len = template[i].ulValueLen;
+ break;
+
+ case CKA_VALUE_LEN:
+ isValueLen = 1;
+ if (template[i].pValue != NULL)
+ sck->sk_value_len =
+ *(CK_ULONG_PTR)template[i].pValue;
+ else
+ sck->sk_value_len = 0;
+ break;
+
+ case CKA_LABEL:
+ isLabel = 1;
+ rv = get_string_from_template(&string_tmp,
+ &template[i]);
+ if (rv != CKR_OK)
+ goto fail_cleanup;
+ break;
+
+ default:
+ rv = kms_parse_common_attrs(&template[i], &attr_mask);
+ if (rv != CKR_OK)
+ goto fail_cleanup;
+ break;
+
+ }
+ } /* For */
+
+ if (keytype == (CK_KEY_TYPE)~0UL) {
+ rv = CKR_TEMPLATE_INCOMPLETE;
+ goto fail_cleanup;
+ }
+
+ new_object->key_type = keytype;
+
+ /* Supported key types of the Secret Key Object */
+ switch (keytype) {
+
+ case CKK_AES:
+ if (!isValueLen) {
+ rv = CKR_TEMPLATE_INCOMPLETE;
+ goto fail_cleanup;
+ }
+ if (sck->sk_value_len != AES_MIN_KEY_BYTES &&
+ sck->sk_value_len != AES_192_KEY_BYTES &&
+ sck->sk_value_len != AES_MAX_KEY_BYTES) {
+ rv = CKR_ATTRIBUTE_VALUE_INVALID;
+ goto fail_cleanup;
+ }
+ break;
+
+ case CKK_RC4:
+ case CKK_GENERIC_SECRET:
+ case CKK_BLOWFISH:
+ case CKK_DES:
+ case CKK_DES2:
+ case CKK_DES3:
+ default:
+ rv = CKR_TEMPLATE_INCONSISTENT;
+ goto fail_cleanup;
+ }
+
+ /* Set up object. */
+ new_object->bool_attr_mask = attr_mask;
+ if (isLabel) {
+ rv = kms_add_extra_attr(&string_tmp, new_object);
+ if (rv != CKR_OK)
+ goto fail_cleanup;
+ string_attr_cleanup(&string_tmp);
+ }
+
+ return (rv);
+
+fail_cleanup:
+ /*
+ * cleanup the storage allocated to the local variables.
+ */
+ string_attr_cleanup(&string_tmp);
+
+ /*
+ * cleanup the storage allocated inside the object itself.
+ */
+ kms_cleanup_object(new_object);
+
+ return (rv);
+}
+
+/*
+ * Validate the attribute types in the object's template. Then,
+ * call the appropriate build function according to the class of
+ * the object specified in the template.
+ *
+ * Note: The following classes of objects are supported:
+ * - CKO_SECRET_KEY
+ */
+CK_RV
+kms_build_object(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum,
+ kms_object_t *new_object)
+{
+ CK_OBJECT_CLASS class = (CK_OBJECT_CLASS)~0UL;
+ CK_RV rv = CKR_OK;
+
+ if (template == NULL) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /* Validate the attribute type in the template. */
+ rv = kms_validate_attr(template, ulAttrNum, &class);
+ if (rv != CKR_OK)
+ return (rv);
+
+ if (class == (CK_OBJECT_CLASS)~0UL)
+ return (CKR_TEMPLATE_INCOMPLETE);
+
+ /*
+ * Call the appropriate function based on the supported class
+ * of the object.
+ */
+ switch (class) {
+
+ case CKO_SECRET_KEY:
+ rv = kms_build_secret_key_object(template, ulAttrNum,
+ new_object);
+ break;
+
+ case CKO_DOMAIN_PARAMETERS:
+ case CKO_DATA:
+ case CKO_CERTIFICATE:
+ case CKO_HW_FEATURE:
+ case CKO_VENDOR_DEFINED:
+ case CKO_PUBLIC_KEY:
+ case CKO_PRIVATE_KEY:
+ default:
+ return (CKR_ATTRIBUTE_VALUE_INVALID);
+ }
+
+ return (rv);
+}
+
+
+/*
+ * Get the value of a requested attribute that is common to all supported
+ * classes (i.e. public key, private key, secret key classes).
+ */
+CK_RV
+kms_get_common_attrs(kms_object_t *object_p, CK_ATTRIBUTE_PTR template)
+{
+
+ CK_RV rv = CKR_OK;
+
+ switch (template->type) {
+
+ case CKA_CLASS:
+ return (get_ulong_attr_from_object(object_p->class,
+ template));
+
+ /* default boolean attributes */
+ case CKA_TOKEN:
+ template->ulValueLen = sizeof (CK_BBOOL);
+ if (template->pValue == NULL) {
+ return (CKR_OK);
+ }
+
+ *((CK_BBOOL *)template->pValue) = B_FALSE;
+ break;
+
+ case CKA_PRIVATE:
+
+ template->ulValueLen = sizeof (CK_BBOOL);
+ if (template->pValue == NULL) {
+ return (CKR_OK);
+ }
+ if (object_p->bool_attr_mask & PRIVATE_BOOL_ON) {
+ *((CK_BBOOL *)template->pValue) = B_TRUE;
+ } else {
+ *((CK_BBOOL *)template->pValue) = B_FALSE;
+ }
+ break;
+
+ case CKA_MODIFIABLE:
+ template->ulValueLen = sizeof (CK_BBOOL);
+ if (template->pValue == NULL) {
+ return (CKR_OK);
+ }
+ if ((object_p->bool_attr_mask) & MODIFIABLE_BOOL_ON)
+ *((CK_BBOOL *)template->pValue) = B_TRUE;
+ else
+ *((CK_BBOOL *)template->pValue) = B_FALSE;
+ break;
+
+ case CKA_LABEL:
+ return (get_extra_attr_from_object(object_p,
+ template));
+ break;
+
+ default:
+ /*
+ * The specified attribute for the object is invalid.
+ * (the object does not possess such an attribute.)
+ */
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_ATTRIBUTE_TYPE_INVALID);
+ }
+
+ return (rv);
+}
+
+/*
+ * Get the value of a requested attribute that is common to all key objects
+ * (i.e. public key, private key and secret key).
+ */
+CK_RV
+kms_get_common_key_attrs(kms_object_t *object_p,
+ CK_ATTRIBUTE_PTR template)
+{
+
+ switch (template->type) {
+
+ case CKA_KEY_TYPE:
+ return (get_ulong_attr_from_object(object_p->key_type,
+ template));
+
+ case CKA_ID:
+ case CKA_START_DATE:
+ case CKA_END_DATE:
+ /*
+ * The above extra attributes have byte array type.
+ */
+ return (get_extra_attr_from_object(object_p,
+ template));
+
+ /* Key related boolean attributes */
+ case CKA_LOCAL:
+ return (get_bool_attr_from_object(object_p,
+ LOCAL_BOOL_ON, template));
+
+ case CKA_DERIVE:
+ return (get_bool_attr_from_object(object_p,
+ DERIVE_BOOL_ON, template));
+
+ case CKA_KEY_GEN_MECHANISM:
+ return (get_ulong_attr_from_object(object_p->mechanism,
+ template));
+
+ default:
+ return (CKR_ATTRIBUTE_TYPE_INVALID);
+ }
+}
+
+/*
+ * Get the value of a requested attribute of a Secret Key Object.
+ *
+ * Rule: All the attributes in the secret key object can be revealed
+ * except those marked with footnote number "7" when the object
+ * has its CKA_SENSITIVE attribute set to TRUE or its
+ * CKA_EXTRACTABLE attribute set to FALSE.
+ */
+CK_RV
+kms_get_secret_key_attribute(kms_object_t *object_p,
+ CK_ATTRIBUTE_PTR template)
+{
+
+ CK_RV rv = CKR_OK;
+ CK_KEY_TYPE keytype = object_p->key_type;
+
+ switch (template->type) {
+
+ /* Key related boolean attributes */
+ case CKA_SENSITIVE:
+ return (get_bool_attr_from_object(object_p,
+ SENSITIVE_BOOL_ON, template));
+
+ case CKA_ENCRYPT:
+ return (get_bool_attr_from_object(object_p,
+ ENCRYPT_BOOL_ON, template));
+
+ case CKA_DECRYPT:
+ return (get_bool_attr_from_object(object_p,
+ DECRYPT_BOOL_ON, template));
+
+ case CKA_SIGN:
+ return (get_bool_attr_from_object(object_p,
+ SIGN_BOOL_ON, template));
+
+ case CKA_VERIFY:
+ return (get_bool_attr_from_object(object_p,
+ VERIFY_BOOL_ON, template));
+
+ case CKA_WRAP:
+ return (get_bool_attr_from_object(object_p,
+ WRAP_BOOL_ON, template));
+
+ case CKA_UNWRAP:
+ return (get_bool_attr_from_object(object_p,
+ UNWRAP_BOOL_ON, template));
+
+ case CKA_EXTRACTABLE:
+ return (get_bool_attr_from_object(object_p,
+ EXTRACTABLE_BOOL_ON, template));
+
+ case CKA_ALWAYS_SENSITIVE:
+ return (get_bool_attr_from_object(object_p,
+ ALWAYS_SENSITIVE_BOOL_ON, template));
+
+ case CKA_NEVER_EXTRACTABLE:
+ return (get_bool_attr_from_object(object_p,
+ NEVER_EXTRACTABLE_BOOL_ON, template));
+
+ case CKA_VALUE:
+ /*
+ * If the specified attribute for the secret key object
+ * cannot be revealed because the object is sensitive
+ * or unextractable, then the ulValueLen is set to -1.
+ */
+ if ((object_p->bool_attr_mask & SENSITIVE_BOOL_ON) ||
+ !(object_p->bool_attr_mask & EXTRACTABLE_BOOL_ON)) {
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_ATTRIBUTE_SENSITIVE);
+ }
+
+ switch (keytype) {
+ case CKK_AES:
+ /*
+ * Copy secret key object attributes to template.
+ */
+ if (template->pValue == NULL) {
+ template->ulValueLen =
+ OBJ_SEC_VALUE_LEN(object_p);
+ return (CKR_OK);
+ }
+
+ if (OBJ_SEC_VALUE(object_p) == NULL) {
+ template->ulValueLen = 0;
+ return (CKR_OK);
+ }
+
+ if (template->ulValueLen >=
+ OBJ_SEC_VALUE_LEN(object_p)) {
+ (void) memcpy(template->pValue,
+ OBJ_SEC_VALUE(object_p),
+ OBJ_SEC_VALUE_LEN(object_p));
+ template->ulValueLen =
+ OBJ_SEC_VALUE_LEN(object_p);
+ return (CKR_OK);
+ } else {
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+
+ case CKK_RC4:
+ case CKK_GENERIC_SECRET:
+ case CKK_RC5:
+ case CKK_DES:
+ case CKK_DES2:
+ case CKK_DES3:
+ case CKK_CDMF:
+ case CKK_BLOWFISH:
+ default:
+ template->ulValueLen = (CK_ULONG)-1;
+ rv = CKR_ATTRIBUTE_TYPE_INVALID;
+ break;
+ }
+ break;
+
+ case CKA_VALUE_LEN:
+ return (get_ulong_attr_from_object(OBJ_SEC_VALUE_LEN(object_p),
+ template));
+
+ default:
+ /*
+ * First, get the value of the request attribute defined
+ * in the list of common key attributes. If the request
+ * attribute is not found in that list, then get the
+ * attribute from the list of common attributes.
+ */
+ rv = kms_get_common_key_attrs(object_p, template);
+ if (rv == CKR_ATTRIBUTE_TYPE_INVALID) {
+ rv = kms_get_common_attrs(object_p, template);
+ }
+ break;
+ }
+
+ return (rv);
+
+}
+
+/*
+ * Call the appropriate get attribute function according to the class
+ * of object.
+ *
+ * The caller of this function holds the lock on the object.
+ */
+CK_RV
+kms_get_attribute(kms_object_t *object_p, CK_ATTRIBUTE_PTR template)
+{
+
+ CK_RV rv = CKR_OK;
+ CK_OBJECT_CLASS class = object_p->class;
+
+ switch (class) {
+ case CKO_SECRET_KEY:
+ rv = kms_get_secret_key_attribute(object_p, template);
+ break;
+
+ case CKO_PRIVATE_KEY:
+ case CKO_PUBLIC_KEY:
+ default:
+ /*
+ * If the specified attribute for the object is invalid
+ * (the object does not possess such as attribute), then
+ * the ulValueLen is modified to hold the value -1.
+ */
+ template->ulValueLen = (CK_ULONG)-1;
+ return (CKR_ATTRIBUTE_TYPE_INVALID);
+ }
+
+ return (rv);
+
+}
+
+/*
+ * Set the value of an attribute that is common to all key objects
+ * (i.e. public key, private key and secret key).
+ */
+static CK_RV
+kms_set_common_key_attribute(kms_object_t *object_p,
+ CK_ATTRIBUTE_PTR template, boolean_t copy)
+{
+
+ kms_slot_t *pslot = get_slotinfo();
+ CK_RV rv = CKR_OK;
+
+ switch (template->type) {
+
+ case CKA_LABEL:
+ /*
+ * Only the LABEL can be modified in the common storage
+ * object attributes after the object is created.
+ */
+ return (set_extra_attr_to_object(object_p,
+ CKA_LABEL, template));
+
+ case CKA_ID:
+ return (set_extra_attr_to_object(object_p,
+ CKA_ID, template));
+
+ case CKA_START_DATE:
+ return (set_extra_attr_to_object(object_p,
+ CKA_START_DATE, template));
+
+ case CKA_END_DATE:
+ return (set_extra_attr_to_object(object_p,
+ CKA_END_DATE, template));
+
+ case CKA_DERIVE:
+ return (set_bool_attr_to_object(object_p,
+ DERIVE_BOOL_ON, template));
+
+ case CKA_CLASS:
+ case CKA_KEY_TYPE:
+ case CKA_LOCAL:
+ return (CKR_ATTRIBUTE_READ_ONLY);
+
+ case CKA_PRIVATE:
+ if (!copy) {
+ /* called from C_SetAttributeValue() */
+ return (CKR_ATTRIBUTE_READ_ONLY);
+ }
+
+ /* called from C_CopyObject() */
+ if ((*(CK_BBOOL *)template->pValue) != B_TRUE) {
+ return (CKR_OK);
+ }
+
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ /*
+ * Cannot create a private object if the token
+ * has a keystore and the user isn't logged in.
+ */
+ if (pslot->sl_state != CKU_USER) {
+ rv = CKR_USER_NOT_LOGGED_IN;
+ } else {
+ rv = set_bool_attr_to_object(object_p,
+ PRIVATE_BOOL_ON, template);
+ }
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (rv);
+
+ case CKA_MODIFIABLE:
+ if (copy) {
+ rv = set_bool_attr_to_object(object_p,
+ MODIFIABLE_BOOL_ON, template);
+ } else {
+ rv = CKR_ATTRIBUTE_READ_ONLY;
+ }
+ return (rv);
+
+ default:
+ return (CKR_TEMPLATE_INCONSISTENT);
+ }
+
+}
+
+/*
+ * Set the value of an attribute of a Secret Key Object.
+ *
+ * Rule: The attributes marked with footnote number "8" in the PKCS11
+ * spec may be modified (p.88 in PKCS11 spec.).
+ */
+static CK_RV
+kms_set_secret_key_attribute(kms_object_t *object_p,
+ CK_ATTRIBUTE_PTR template, boolean_t copy)
+{
+ CK_KEY_TYPE keytype = object_p->key_type;
+
+ switch (template->type) {
+
+ case CKA_SENSITIVE:
+ /*
+ * Cannot set SENSITIVE to FALSE if it is already ON.
+ */
+ if (((*(CK_BBOOL *)template->pValue) == B_FALSE) &&
+ (object_p->bool_attr_mask & SENSITIVE_BOOL_ON)) {
+ return (CKR_ATTRIBUTE_READ_ONLY);
+ }
+
+ if (*(CK_BBOOL *)template->pValue)
+ object_p->bool_attr_mask |= SENSITIVE_BOOL_ON;
+ return (CKR_OK);
+
+ case CKA_ENCRYPT:
+ return (set_bool_attr_to_object(object_p,
+ ENCRYPT_BOOL_ON, template));
+
+ case CKA_DECRYPT:
+ return (set_bool_attr_to_object(object_p,
+ DECRYPT_BOOL_ON, template));
+
+ case CKA_SIGN:
+ return (set_bool_attr_to_object(object_p,
+ SIGN_BOOL_ON, template));
+
+ case CKA_VERIFY:
+ return (set_bool_attr_to_object(object_p,
+ VERIFY_BOOL_ON, template));
+
+ case CKA_WRAP:
+ return (set_bool_attr_to_object(object_p,
+ WRAP_BOOL_ON, template));
+
+ case CKA_UNWRAP:
+ return (set_bool_attr_to_object(object_p,
+ UNWRAP_BOOL_ON, template));
+
+ case CKA_EXTRACTABLE:
+ /*
+ * Cannot set EXTRACTABLE to TRUE if it is already OFF.
+ */
+ if ((*(CK_BBOOL *)template->pValue) &&
+ !(object_p->bool_attr_mask & EXTRACTABLE_BOOL_ON)) {
+ return (CKR_ATTRIBUTE_READ_ONLY);
+ }
+
+ if ((*(CK_BBOOL *)template->pValue) == B_FALSE)
+ object_p->bool_attr_mask &= ~EXTRACTABLE_BOOL_ON;
+ return (CKR_OK);
+
+ case CKA_VALUE:
+ return (CKR_ATTRIBUTE_READ_ONLY);
+
+ case CKA_VALUE_LEN:
+ if ((keytype == CKK_RC4) ||
+ (keytype == CKK_GENERIC_SECRET) ||
+ (keytype == CKK_AES) ||
+ (keytype == CKK_BLOWFISH))
+ return (CKR_ATTRIBUTE_READ_ONLY);
+ break;
+
+ default:
+ /*
+ * Set the value of a common key attribute.
+ */
+ return (kms_set_common_key_attribute(object_p,
+ template, copy));
+ }
+
+ /*
+ * If we got this far, then the combination of key type
+ * and requested attribute is invalid.
+ */
+ return (CKR_ATTRIBUTE_TYPE_INVALID);
+}
+
+/*
+ * Call the appropriate set attribute function according to the class
+ * of object.
+ *
+ * The caller of this function does not hold the lock on the original
+ * object, since this function is setting the attribute on the new object
+ * that is being modified.
+ *
+ */
+CK_RV
+kms_set_attribute(kms_object_t *object_p, CK_ATTRIBUTE_PTR template,
+ boolean_t copy)
+{
+
+ CK_RV rv = CKR_OK;
+ CK_OBJECT_CLASS class = object_p->class;
+
+ switch (class) {
+
+ case CKO_SECRET_KEY:
+ rv = kms_set_secret_key_attribute(object_p, template,
+ copy);
+ break;
+
+ case CKO_PUBLIC_KEY:
+ case CKO_PRIVATE_KEY:
+ default:
+ /*
+ * If the template specifies a value of an attribute
+ * which is incompatible with other existing attributes
+ * of the object, then fails with return code
+ * CKR_TEMPLATE_INCONSISTENT.
+ */
+ rv = CKR_TEMPLATE_INCONSISTENT;
+ break;
+ }
+
+ return (rv);
+}
+
+CK_RV
+kms_copy_secret_key_attr(secret_key_obj_t *old_secret_key_obj_p,
+ secret_key_obj_t **new_secret_key_obj_p)
+{
+ secret_key_obj_t *sk;
+
+ sk = malloc(sizeof (secret_key_obj_t));
+ if (sk == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+ (void) memcpy(sk, old_secret_key_obj_p, sizeof (secret_key_obj_t));
+
+ /* copy the secret key value */
+ sk->sk_value = malloc((sizeof (CK_BYTE) * sk->sk_value_len));
+ if (sk->sk_value == NULL) {
+ free(sk);
+ return (CKR_HOST_MEMORY);
+ }
+ (void) memcpy(sk->sk_value, old_secret_key_obj_p->sk_value,
+ (sizeof (CK_BYTE) * sk->sk_value_len));
+
+ *new_secret_key_obj_p = sk;
+
+ return (CKR_OK);
+}
+
+
+
+/*
+ * If CKA_CLASS not given, guess CKA_CLASS using
+ * attributes on template.
+ *
+ * Some attributes are specific to an object class. If one or more
+ * of these attributes are in the template, make a list of classes
+ * that can have these attributes. This would speed up the search later,
+ * because we can immediately skip an object if the class of that
+ * object can not possibly contain one of the attributes.
+ *
+ */
+void
+kms_process_find_attr(CK_OBJECT_CLASS *pclasses,
+ CK_ULONG *num_result_pclasses, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulCount)
+{
+ ulong_t i;
+ int j;
+ boolean_t secret_found = B_FALSE;
+ int num_secret_key_attrs;
+ int num_pclasses = 0;
+
+ for (i = 0; i < ulCount; i++) {
+ if (pTemplate[i].type == CKA_CLASS) {
+ /*
+ * don't need to guess the class, it is specified.
+ * Just record the class, and return.
+ */
+ pclasses[0] =
+ (*((CK_OBJECT_CLASS *)pTemplate[i].pValue));
+ *num_result_pclasses = 1;
+ return;
+ }
+ }
+
+ num_secret_key_attrs =
+ sizeof (SECRET_KEY_ATTRS) / sizeof (CK_ATTRIBUTE_TYPE);
+
+ /*
+ * Get the list of objects class that might contain
+ * some attributes.
+ */
+ for (i = 0; i < ulCount; i++) {
+ if (!secret_found) {
+ for (j = 0; j < num_secret_key_attrs; j++) {
+ if (pTemplate[i].type == SECRET_KEY_ATTRS[j]) {
+ secret_found = B_TRUE;
+ pclasses[num_pclasses++] =
+ CKO_SECRET_KEY;
+ break;
+ }
+ }
+ }
+ }
+ *num_result_pclasses = num_pclasses;
+}
+
+
+boolean_t
+kms_find_match_attrs(kms_object_t *obj, CK_OBJECT_CLASS *pclasses,
+ CK_ULONG num_pclasses, CK_ATTRIBUTE *template, CK_ULONG num_attr)
+{
+ ulong_t i;
+ CK_ATTRIBUTE *tmpl_attr, *obj_attr;
+ uint64_t attr_mask;
+ boolean_t compare_attr, compare_boolean;
+
+ /*
+ * Check if the class of this object match with any
+ * of object classes that can possibly contain the
+ * requested attributes.
+ */
+ if (num_pclasses > 0) {
+ for (i = 0; i < num_pclasses; i++) {
+ if (obj->class == pclasses[i]) {
+ break;
+ }
+ }
+ if (i == num_pclasses) {
+ /*
+ * this object can't possibly contain one or
+ * more attributes, don't need to check this object
+ */
+ return (B_FALSE);
+ }
+ }
+
+ /* need to examine everything */
+ for (i = 0; i < num_attr; i++) {
+ tmpl_attr = &(template[i]);
+ compare_attr = B_FALSE;
+ compare_boolean = B_FALSE;
+ switch (tmpl_attr->type) {
+ /* First, check the most common attributes */
+ case CKA_CLASS:
+ if (*((CK_OBJECT_CLASS *)tmpl_attr->pValue) !=
+ obj->class) {
+ return (B_FALSE);
+ }
+ break;
+ case CKA_KEY_TYPE:
+ if (*((CK_KEY_TYPE *)tmpl_attr->pValue) !=
+ obj->key_type) {
+ return (B_FALSE);
+ }
+ break;
+ case CKA_ENCRYPT:
+ attr_mask = (obj->bool_attr_mask) & ENCRYPT_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_DECRYPT:
+ attr_mask = (obj->bool_attr_mask) & DECRYPT_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_WRAP:
+ attr_mask = (obj->bool_attr_mask) & WRAP_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_UNWRAP:
+ attr_mask = (obj->bool_attr_mask) & UNWRAP_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_SIGN:
+ attr_mask = (obj->bool_attr_mask) & SIGN_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_SIGN_RECOVER:
+ attr_mask = (obj->bool_attr_mask) &
+ SIGN_RECOVER_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_VERIFY:
+ attr_mask = (obj->bool_attr_mask) & VERIFY_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_VERIFY_RECOVER:
+ attr_mask = (obj->bool_attr_mask) &
+ VERIFY_RECOVER_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_DERIVE:
+ attr_mask = (obj->bool_attr_mask) & DERIVE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_LOCAL:
+ attr_mask = (obj->bool_attr_mask) & LOCAL_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_SENSITIVE:
+ attr_mask = (obj->bool_attr_mask) & SENSITIVE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_SECONDARY_AUTH:
+ attr_mask = (obj->bool_attr_mask) &
+ SECONDARY_AUTH_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_TRUSTED:
+ attr_mask = (obj->bool_attr_mask) & TRUSTED_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_EXTRACTABLE:
+ attr_mask = (obj->bool_attr_mask) &
+ EXTRACTABLE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_ALWAYS_SENSITIVE:
+ attr_mask = (obj->bool_attr_mask) &
+ ALWAYS_SENSITIVE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_NEVER_EXTRACTABLE:
+ attr_mask = (obj->bool_attr_mask) &
+ NEVER_EXTRACTABLE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_TOKEN:
+ attr_mask = (obj->bool_attr_mask) & TOKEN_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_PRIVATE:
+ attr_mask = (obj->bool_attr_mask) & PRIVATE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_MODIFIABLE:
+ attr_mask = (obj->bool_attr_mask) & MODIFIABLE_BOOL_ON;
+ compare_boolean = B_TRUE;
+ break;
+ case CKA_SUBJECT:
+ case CKA_ID:
+ case CKA_START_DATE:
+ case CKA_END_DATE:
+ case CKA_KEY_GEN_MECHANISM:
+ case CKA_LABEL:
+ /* find these attributes from extra_attrlistp */
+ obj_attr = get_extra_attr(tmpl_attr->type, obj);
+ compare_attr = B_TRUE;
+ break;
+ case CKA_VALUE_LEN:
+ /* only secret key has this attribute */
+ if (obj->class == CKO_SECRET_KEY) {
+ if (*((CK_ULONG *)tmpl_attr->pValue) !=
+ OBJ_SEC_VALUE_LEN(obj)) {
+ return (B_FALSE);
+ }
+ } else {
+ return (B_FALSE);
+ }
+ break;
+ case CKA_VALUE:
+ switch (obj->class) {
+ case CKO_SECRET_KEY:
+ break;
+ default:
+ return (B_FALSE);
+ }
+ break;
+ case CKA_VALUE_BITS:
+ case CKA_PRIME_BITS:
+ case CKA_SUBPRIME_BITS:
+ default:
+ /*
+ * any other attributes are currently not supported.
+ * so, it's not possible for them to be in the
+ * object
+ */
+ return (B_FALSE);
+ }
+ if (compare_boolean) {
+ CK_BBOOL bval;
+
+ if (attr_mask) {
+ bval = TRUE;
+ } else {
+ bval = FALSE;
+ }
+ if (bval != *((CK_BBOOL *)tmpl_attr->pValue)) {
+ return (B_FALSE);
+ }
+ } else if (compare_attr) {
+ if (obj_attr == NULL) {
+ /*
+ * The attribute type is valid, and its value
+ * has not been initialized in the object. In
+ * this case, it only matches the template's
+ * attribute if the template's value length
+ * is 0.
+ */
+ if (tmpl_attr->ulValueLen != 0)
+ return (B_FALSE);
+ } else {
+ if (tmpl_attr->ulValueLen !=
+ obj_attr->ulValueLen) {
+ return (B_FALSE);
+ }
+ if (memcmp(tmpl_attr->pValue, obj_attr->pValue,
+ tmpl_attr->ulValueLen) != 0) {
+ return (B_FALSE);
+ }
+ }
+ }
+ }
+ return (B_TRUE);
+}
+
+CK_ATTRIBUTE_PTR
+get_extra_attr(CK_ATTRIBUTE_TYPE type, kms_object_t *obj)
+{
+ CK_ATTRIBUTE_INFO_PTR tmp;
+
+ tmp = obj->extra_attrlistp;
+ while (tmp != NULL) {
+ if (tmp->attr.type == type) {
+ return (&(tmp->attr));
+ }
+ tmp = tmp->next;
+ }
+ /* if get there, the specified attribute is not found */
+ return (NULL);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsCrypt.h b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsCrypt.h
new file mode 100644
index 0000000000..ade758af93
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsCrypt.h
@@ -0,0 +1,75 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _KMSCRYPT_H
+#define _KMSCRYPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include <security/pkcs11t.h>
+#ifdef USESOLARIS_AES
+#include <modes/modes.h>
+#else
+#include <aes_cbc_crypt.h>
+#define CBC_MODE AES_CBC_MODE
+#endif
+#include <aes_impl.h>
+#include "kmsObject.h"
+#include "kmsSession.h"
+
+typedef struct kms_aes_ctx {
+ void *key_sched; /* pointer to key schedule */
+ size_t keysched_len; /* Length of the key schedule */
+ uint8_t ivec[AES_BLOCK_LEN]; /* initialization vector */
+ uint8_t data[AES_BLOCK_LEN]; /* for use by update */
+ size_t remain_len; /* for use by update */
+ void *aes_cbc; /* to be used by CBC mode */
+} kms_aes_ctx_t;
+
+/*
+ * Function Prototypes.
+ */
+void *aes_cbc_ctx_init(void *, size_t, uint8_t *);
+
+CK_RV kms_aes_crypt_init_common(kms_session_t *, CK_MECHANISM_PTR,
+ kms_object_t *, boolean_t);
+
+CK_RV kms_aes_encrypt_common(kms_session_t *, CK_BYTE_PTR, CK_ULONG,
+ CK_BYTE_PTR, CK_ULONG_PTR, boolean_t);
+
+CK_RV kms_aes_decrypt_common(kms_session_t *, CK_BYTE_PTR, CK_ULONG,
+ CK_BYTE_PTR, CK_ULONG_PTR, boolean_t);
+
+CK_RV kms_aes_encrypt_final(kms_session_t *, CK_BYTE_PTR, CK_ULONG_PTR);
+CK_RV kms_aes_decrypt_final(kms_session_t *, CK_BYTE_PTR, CK_ULONG_PTR);
+
+void kms_crypt_cleanup(kms_session_t *, boolean_t, boolean_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _KMSCRYPT_H */
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDecrypt.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDecrypt.c
new file mode 100644
index 0000000000..96d4bdcb30
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDecrypt.c
@@ -0,0 +1,405 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <string.h>
+#include <strings.h>
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+#include "kmsCrypt.h"
+
+
+/*
+ * kms_decrypt_init()
+ *
+ * Arguments:
+ * session_p: pointer to kms_session_t struct
+ * pMechanism: pointer to CK_MECHANISM struct provided by application
+ * key_p: pointer to key kms_object_t struct
+ *
+ * Description:
+ * called by C_DecryptInit(). This function calls the corresponding
+ * decrypt init routine based on the mechanism.
+ *
+ * Returns:
+ * CKR_OK: success
+ * CKR_HOST_MEMORY: run out of system memory
+ * CKR_MECHANISM_PARAM_INVALID: invalid parameters in mechanism
+ * CKR_MECHANISM_INVALID: invalid mechanism type
+ * CKR_KEY_TYPE_INCONSISTENT: incorrect type of key to use
+ * with the specified mechanism
+ */
+CK_RV
+kms_decrypt_init(kms_session_t *session_p, CK_MECHANISM_PTR pMechanism,
+ kms_object_t *key_p)
+{
+
+ CK_RV rv;
+
+ switch (pMechanism->mechanism) {
+ case CKM_AES_CBC:
+ case CKM_AES_CBC_PAD:
+ {
+ kms_aes_ctx_t *kms_aes_ctx;
+
+ if (key_p->key_type != CKK_AES) {
+ return (CKR_KEY_TYPE_INCONSISTENT);
+ }
+
+ if ((pMechanism->pParameter == NULL) ||
+ (pMechanism->ulParameterLen != AES_BLOCK_LEN)) {
+ return (CKR_MECHANISM_PARAM_INVALID);
+ }
+
+ rv = kms_aes_crypt_init_common(session_p, pMechanism,
+ key_p, B_FALSE);
+
+ if (rv != CKR_OK)
+ return (rv);
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+
+ kms_aes_ctx = (kms_aes_ctx_t *)session_p->decrypt.context;
+
+ /* Save Initialization Vector (IV) in the context. */
+ (void) memcpy(kms_aes_ctx->ivec, pMechanism->pParameter,
+ AES_BLOCK_LEN);
+
+ /* Allocate a context for AES cipher-block chaining. */
+ kms_aes_ctx->aes_cbc = (void *)aes_cbc_ctx_init(
+ kms_aes_ctx->key_sched, kms_aes_ctx->keysched_len,
+ kms_aes_ctx->ivec);
+
+ if (kms_aes_ctx->aes_cbc == NULL) {
+ bzero(kms_aes_ctx->key_sched,
+ kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+ free(session_p->decrypt.context);
+ session_p->decrypt.context = NULL;
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ return (CKR_HOST_MEMORY);
+ }
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ return (rv);
+ }
+ default:
+ return (CKR_MECHANISM_INVALID);
+ }
+}
+
+CK_RV
+C_DecryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hKey)
+{
+ CK_RV rv;
+ kms_session_t *session_p;
+ kms_object_t *key_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ if (pMechanism == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ /* Obtain the object pointer. */
+ HANDLE2OBJECT(hKey, key_p, rv);
+ if (rv != CKR_OK)
+ goto clean_exit;
+
+ /* Check to see if key object allows for decryption. */
+ if (!(key_p->bool_attr_mask & DECRYPT_BOOL_ON)) {
+ rv = CKR_KEY_FUNCTION_NOT_PERMITTED;
+ goto clean_exit1;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /* Check to see if decrypt operation is already active. */
+ if (session_p->decrypt.flags & CRYPTO_OPERATION_ACTIVE) {
+ /* free the memory to avoid memory leak */
+ kms_crypt_cleanup(session_p, B_FALSE, lock_held);
+ }
+
+ /*
+ * This active flag will remain ON until application calls either
+ * C_Decrypt or C_DecryptFinal to actually obtain the final piece
+ * of plaintext.
+ */
+ session_p->decrypt.flags = CRYPTO_OPERATION_ACTIVE;
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_decrypt_init(session_p, pMechanism, key_p);
+
+ if (rv != CKR_OK) {
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ session_p->decrypt.flags &= ~CRYPTO_OPERATION_ACTIVE;
+ lock_held = B_TRUE;
+ }
+
+clean_exit1:
+ OBJ_REFRELE(key_p);
+clean_exit:
+ REFRELE(session_p, lock_held);
+ return (rv);
+}
+
+CK_RV
+C_Decrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedData,
+ CK_ULONG ulEncryptedData, CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen)
+{
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obatin the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /*
+ * Only check if input buffer is null. How to handle zero input
+ * length depents on the mechanism in use. For secret key mechanisms,
+ * unpadded ones yield zero length output, but padded ones always
+ * result in smaller than original, possibly zero, length output.
+ */
+ if (pEncryptedData == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ /*
+ * No need to check pData because application might
+ * just want to know the length of decrypted data.
+ */
+ if (pulDataLen == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /* Application must call C_DecryptInit before calling C_Decrypt. */
+ if (!(session_p->decrypt.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ /*
+ * C_Decrypt must be called without intervening C_DecryptUpdate
+ * calls.
+ */
+ if (session_p->decrypt.flags & CRYPTO_OPERATION_UPDATE) {
+ /*
+ * C_Decrypt can not be used to terminate a multi-part
+ * operation, so we'll leave the active decrypt operation
+ * flag on and let the application continue with the
+ * decrypt update operation.
+ */
+ REFRELE(session_p, lock_held);
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_aes_decrypt_common(session_p, pEncryptedData,
+ ulEncryptedData, pData, pulDataLen, FALSE);
+
+ if ((rv == CKR_BUFFER_TOO_SMALL) ||
+ (pData == NULL && rv == CKR_OK)) {
+ /*
+ * We will not terminate the active decrypt operation flag,
+ * when the application-supplied buffer is too small, or
+ * the application asks for the length of buffer to hold
+ * the plaintext.
+ */
+ REFRELE(session_p, lock_held);
+ return (rv);
+ }
+
+clean_exit:
+ /* Clear context, free key, and release session counter */
+ kms_crypt_cleanup(session_p, B_FALSE, B_FALSE);
+
+ return (rv);
+}
+
+CK_RV
+C_DecryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart,
+ CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart,
+ CK_ULONG_PTR pulPartLen)
+{
+
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /*
+ * Only check if input buffer is null. How to handle zero input
+ * length depents on the mechanism in use. For secret key mechanisms,
+ * unpadded ones yeild zero length output, but padded ones always
+ * result in smaller than original, possibly zero, length output.
+ */
+ if (pEncryptedPart == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ /*
+ * Only check if pulPartLen is NULL.
+ * No need to check if pPart is NULL because application
+ * might just ask for the length of buffer to hold the
+ * recovered data.
+ */
+ if (pulPartLen == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /*
+ * Application must call C_DecryptInit before calling
+ * C_DecryptUpdate.
+ */
+ if (!(session_p->decrypt.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ session_p->decrypt.flags |= CRYPTO_OPERATION_UPDATE;
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_aes_decrypt_common(session_p, pEncryptedPart,
+ ulEncryptedPartLen, pPart, pulPartLen, B_TRUE);
+
+ /*
+ * If CKR_OK or CKR_BUFFER_TOO_SMALL, don't terminate the
+ * current decryption operation.
+ */
+ if ((rv == CKR_OK) || (rv == CKR_BUFFER_TOO_SMALL)) {
+ REFRELE(session_p, lock_held);
+ return (rv);
+ }
+
+clean_exit:
+ /*
+ * After an error occurred, terminate the current decrypt
+ * operation by resetting the active and update flags.
+ */
+ kms_crypt_cleanup(session_p, B_FALSE, lock_held);
+
+ return (rv);
+}
+
+CK_RV
+C_DecryptFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pLastPart,
+ CK_ULONG_PTR pulLastPartLen)
+{
+
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ if (pulLastPartLen == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /*
+ * Application must call C_DecryptInit before calling
+ * C_DecryptFinal.
+ */
+ if (!(session_p->decrypt.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_aes_decrypt_final(session_p, pLastPart, pulLastPartLen);
+
+ if ((rv == CKR_BUFFER_TOO_SMALL) ||
+ (pLastPart == NULL && rv == CKR_OK)) {
+ /*
+ * We will not terminate the active decrypt operation flag,
+ * when the application-supplied buffer is too small, or
+ * the application asks for the length of buffer to hold
+ * the plaintext.
+ */
+ REFRELE(session_p, lock_held);
+ return (rv);
+ }
+
+ /* Terminates the active encrypt operation. */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ session_p->decrypt.flags = 0;
+ lock_held = B_TRUE;
+ REFRELE(session_p, lock_held);
+ return (rv);
+
+clean_exit:
+ /* Terminates the active decrypt operation */
+ kms_crypt_cleanup(session_p, B_FALSE, lock_held);
+
+ return (rv);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDigest.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDigest.c
new file mode 100644
index 0000000000..5472ccb15b
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDigest.c
@@ -0,0 +1,78 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+
+/*ARGSUSED*/
+CK_RV
+C_DigestInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_Digest(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
+ CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_DigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
+ CK_ULONG ulPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_DigestKey(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_DigestFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pDigest,
+ CK_ULONG_PTR pulDigestLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDualCrypt.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDualCrypt.c
new file mode 100644
index 0000000000..1bde2b0946
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsDualCrypt.c
@@ -0,0 +1,74 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+
+/*ARGSUSED*/
+CK_RV
+C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
+ CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart,
+ CK_ULONG_PTR pulEncryptedPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_DecryptDigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart,
+ CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_SignEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
+ CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart,
+ CK_ULONG_PTR pulEncryptedPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart,
+ CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsEncrypt.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsEncrypt.c
new file mode 100644
index 0000000000..38ef8add89
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsEncrypt.c
@@ -0,0 +1,424 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <string.h>
+#include <strings.h>
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+#include "kmsCrypt.h"
+
+static CK_RV
+kms_encrypt_init(kms_session_t *session_p, CK_MECHANISM_PTR pMechanism,
+ kms_object_t *key_p)
+{
+ CK_RV rv = CKR_OK;
+ kms_aes_ctx_t *kms_aes_ctx;
+
+ if (pMechanism->mechanism != CKM_AES_CBC &&
+ pMechanism->mechanism != CKM_AES_CBC_PAD)
+ return (CKR_MECHANISM_INVALID);
+
+ if (key_p->key_type != CKK_AES) {
+ return (CKR_KEY_TYPE_INCONSISTENT);
+ }
+
+ if ((pMechanism->pParameter == NULL) ||
+ (pMechanism->ulParameterLen != AES_BLOCK_LEN)) {
+ return (CKR_MECHANISM_PARAM_INVALID);
+ }
+
+ rv = kms_aes_crypt_init_common(session_p, pMechanism,
+ key_p, B_TRUE);
+
+ if (rv != CKR_OK)
+ return (rv);
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+
+ kms_aes_ctx = (kms_aes_ctx_t *)session_p->encrypt.context;
+ /* Copy Initialization Vector (IV) into the context. */
+
+ (void) memcpy(kms_aes_ctx->ivec, pMechanism->pParameter,
+ AES_BLOCK_LEN);
+
+ /* Allocate a context for AES cipher-block chaining. */
+ kms_aes_ctx->aes_cbc = (void *)aes_cbc_ctx_init(
+ kms_aes_ctx->key_sched, kms_aes_ctx->keysched_len,
+ kms_aes_ctx->ivec);
+
+ if (kms_aes_ctx->aes_cbc == NULL) {
+ bzero(kms_aes_ctx->key_sched,
+ kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+ free(session_p->encrypt.context);
+ session_p->encrypt.context = NULL;
+ rv = CKR_HOST_MEMORY;
+ }
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ return (rv);
+}
+
+void
+kms_crypt_cleanup(kms_session_t *session_p, boolean_t encrypt,
+ boolean_t lock_held)
+{
+ kms_active_op_t *active_op;
+ boolean_t lock_true = B_TRUE;
+ kms_aes_ctx_t *kms_aes_ctx;
+ aes_ctx_t *aes_ctx;
+
+ if (!lock_held)
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+
+ active_op = (encrypt) ? &(session_p->encrypt) : &(session_p->decrypt);
+ if (active_op->mech.mechanism != CKM_AES_CBC &&
+ active_op->mech.mechanism != CKM_AES_CBC_PAD)
+ return;
+
+ kms_aes_ctx = (kms_aes_ctx_t *)active_op->context;
+
+ if (kms_aes_ctx != NULL) {
+ aes_ctx = (aes_ctx_t *)kms_aes_ctx->aes_cbc;
+ if (aes_ctx != NULL) {
+ bzero(aes_ctx->ac_keysched, aes_ctx->ac_keysched_len);
+ free(kms_aes_ctx->aes_cbc);
+ bzero(kms_aes_ctx->key_sched,
+ kms_aes_ctx->keysched_len);
+ free(kms_aes_ctx->key_sched);
+ }
+ }
+ if (active_op->context != NULL) {
+ free(active_op->context);
+ active_op->context = NULL;
+ }
+ active_op->flags = 0;
+ if (!lock_held)
+ REFRELE(session_p, lock_true);
+}
+
+CK_RV
+C_EncryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hKey)
+{
+ CK_RV rv;
+ kms_session_t *session_p;
+ kms_object_t *key_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ if (pMechanism == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ if (pMechanism->mechanism != CKM_AES_CBC &&
+ pMechanism->mechanism != CKM_AES_CBC_PAD)
+ return (CKR_MECHANISM_INVALID);
+
+ /* Obtain the object pointer. */
+ HANDLE2OBJECT(hKey, key_p, rv);
+ if (rv != CKR_OK)
+ goto clean_exit;
+
+ /* Check to see if key object allows for encryption. */
+ if (!(key_p->bool_attr_mask & ENCRYPT_BOOL_ON)) {
+ rv = CKR_KEY_FUNCTION_NOT_PERMITTED;
+ goto clean_exit1;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /* Check to see if encrypt operation is already active. */
+ if (session_p->encrypt.flags & CRYPTO_OPERATION_ACTIVE) {
+ /* free the memory to avoid memory leak */
+ kms_crypt_cleanup(session_p, B_TRUE, lock_held);
+ }
+
+ /*
+ * This active flag will remain ON until application calls either
+ * C_Encrypt or C_EncryptFinal to actually obtain the final piece
+ * of ciphertext.
+ */
+ session_p->encrypt.flags = CRYPTO_OPERATION_ACTIVE;
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_encrypt_init(session_p, pMechanism, key_p);
+
+ if (rv != CKR_OK) {
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ session_p->encrypt.flags &= ~CRYPTO_OPERATION_ACTIVE;
+ lock_held = B_TRUE;
+ }
+
+clean_exit1:
+ OBJ_REFRELE(key_p);
+clean_exit:
+ REFRELE(session_p, lock_held);
+ return (rv);
+}
+
+
+CK_RV
+C_Encrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
+ CK_BYTE_PTR pEncryptedData, CK_ULONG_PTR pulEncryptedDataLen)
+{
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /*
+ * Only check if input buffer is null. How to handle zero input
+ * length depends on the mechanism in use. For secret key mechanisms,
+ * unpadded ones yield zero length output, but padded ones always
+ * result in greater than zero length output.
+ */
+ if (pData == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ /*
+ * Only check if pulEncryptedDataLen is NULL.
+ * No need to check if pEncryptedData is NULL because
+ * application might just ask for the length of buffer to hold
+ * the ciphertext.
+ */
+ if (pulEncryptedDataLen == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /* Application must call C_EncryptInit before calling C_Encrypt. */
+ if (!(session_p->encrypt.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ /*
+ * C_Encrypt must be called without intervening C_EncryptUpdate
+ * calls.
+ */
+ if (session_p->encrypt.flags & CRYPTO_OPERATION_UPDATE) {
+ /*
+ * C_Encrypt can not be used to terminate a multi-part
+ * operation, so we'll leave the active encrypt operation
+ * flag on and let the application continue with the
+ * encrypt update operation.
+ */
+ REFRELE(session_p, lock_held);
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_aes_encrypt_common(session_p, pData, ulDataLen, pEncryptedData,
+ pulEncryptedDataLen, 0);
+
+ if ((rv == CKR_BUFFER_TOO_SMALL) ||
+ (pEncryptedData == NULL && rv == CKR_OK)) {
+ /*
+ * We will not terminate the active encrypt operation flag,
+ * when the application-supplied buffer is too small, or
+ * the application asks for the length of buffer to hold
+ * the ciphertext.
+ */
+ REFRELE(session_p, lock_held);
+ return (rv);
+ }
+
+clean_exit:
+ /* Clear context, free key, and release session counter */
+ kms_crypt_cleanup(session_p, B_TRUE, B_FALSE);
+ return (rv);
+}
+
+CK_RV
+C_EncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
+ CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart,
+ CK_ULONG_PTR pulEncryptedPartLen)
+{
+
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /*
+ * Only check if input buffer is null. How to handle zero input
+ * length depends on the mechanism in use. For secret key mechanisms,
+ * unpadded ones yeild zero length output, but padded ones always
+ * result in greater than zero length output.
+ */
+ if (pPart == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ /*
+ * Only check if pulEncryptedPartLen is NULL.
+ * No need to check if pEncryptedPart is NULL because
+ * application might just ask for the length of buffer to hold
+ * the ciphertext.
+ */
+ if (pulEncryptedPartLen == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /*
+ * Application must call C_EncryptInit before calling
+ * C_EncryptUpdate.
+ */
+ if (!(session_p->encrypt.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ session_p->encrypt.flags |= CRYPTO_OPERATION_UPDATE;
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_aes_encrypt_common(session_p, pPart, ulPartLen,
+ pEncryptedPart, pulEncryptedPartLen, B_TRUE);
+
+ /*
+ * If CKR_OK or CKR_BUFFER_TOO_SMALL, don't terminate the
+ * current encryption operation.
+ */
+ if ((rv == CKR_OK) || (rv == CKR_BUFFER_TOO_SMALL)) {
+ REFRELE(session_p, lock_held);
+ return (rv);
+ }
+
+clean_exit:
+ /*
+ * After an error occurred, terminate the current encrypt
+ * operation by resetting the active and update flags.
+ */
+ kms_crypt_cleanup(session_p, B_TRUE, lock_held);
+
+ return (rv);
+}
+
+
+CK_RV
+C_EncryptFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pLastEncryptedPart,
+ CK_ULONG_PTR pulLastEncryptedPartLen)
+{
+
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer. */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ if (pulLastEncryptedPartLen == NULL) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto clean_exit;
+ }
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ lock_held = B_TRUE;
+
+ /*
+ * Application must call C_EncryptInit before calling
+ * C_EncryptFinal.
+ */
+ if (!(session_p->encrypt.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ lock_held = B_FALSE;
+
+ rv = kms_aes_encrypt_final(session_p, pLastEncryptedPart,
+ pulLastEncryptedPartLen);
+
+ if ((rv == CKR_BUFFER_TOO_SMALL) ||
+ (pLastEncryptedPart == NULL && rv == CKR_OK)) {
+ /*
+ * We will not terminate the active encrypt operation flag,
+ * when the application-supplied buffer is too small, or
+ * the application asks for the length of buffer to hold
+ * the ciphertext.
+ */
+ REFRELE(session_p, lock_held);
+ return (rv);
+ }
+
+ /* Terminates the active encrypt operation. */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ session_p->encrypt.flags = 0;
+ lock_held = B_TRUE;
+ REFRELE(session_p, lock_held);
+
+ return (rv);
+
+clean_exit:
+ /* Terminates the active encrypt operation. */
+ kms_crypt_cleanup(session_p, B_TRUE, lock_held);
+
+ return (rv);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsGeneral.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsGeneral.c
new file mode 100644
index 0000000000..192d53827f
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsGeneral.c
@@ -0,0 +1,548 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <strings.h>
+#include <unistd.h> /* for pid */
+#include <errno.h>
+#include <security/cryptoki.h>
+
+#include "kmsKeystoreUtil.h"
+#include "kmsGlobal.h"
+#include "kmsSession.h"
+#include "kmsSlot.h"
+
+/*
+ * PKCS#11 KMS Crypto provider module.
+ *
+ * This module provides access to a Key Management System (v 2.0)
+ * through the Solaris Cryptographic Framework interfaces (PKCS#11).
+ *
+ * PREREQUISITES
+ * =============
+ * 1. You must have access to a KMS on the network and you must
+ * know the IP address and name of the "Agent" assigned to
+ * you and the passphrase needed to access the Agent information.
+ *
+ * 2. The token configuration must be completed prior
+ * to using this provider using the kmscfg(1m) utility.
+ *
+ * This provider provides support for 3 AES mechanisms:
+ * CKM_AES_KEY_GEN (for 256 bit keys only)
+ * CKM_AES_CBC (encrypt/decrypt)
+ * CKM_AES_CBC_PAD (encrypt/decrypt)
+ *
+ * DETAILS
+ * =======
+ * Each user has their own local configuration for the KMS.
+ * The local configuration information is typically located
+ * in a private token directory - /var/tmp/kms/$USERNAME
+ * The location may be overridden using an environment variable
+ * $KMSTOKEN_DIR. The user's private token namespace is configured
+ * using kmscfg(1M) which establishes the directory and populates
+ * it with a simple configuration file that this module later uses
+ * to access the KMS.
+ *
+ * INITIALIZING
+ * ============
+ * Once the token configuration is established, C_InitToken
+ * is used to initialize the first contact with the KMS. This
+ * will cause the provider to contact the KMS and download
+ * the profile configuration data, a server certificate, and a
+ * private entity key and certificate (in a PKCS#12 file).
+ * Once the above data is collected it is stored under $KMSTOKEN_DIR.
+ * The user may then proceed with normal PKCS#11 activity.
+ *
+ * LOGIN
+ * =====
+ * The concept of a "Login" is established when the user provides
+ * a PIN that will successfully unwrap the private data in the
+ * PKCS#12 file downloaded earlier when C_InitToken was called.
+ * If the PKCS#12 file is successfully opened, then the user
+ * is considered "logged in" and may use the private key and
+ * certificate to initiate secure communications with the KMS.
+ *
+ * CHANGE PIN
+ * ==========
+ * The C_SetPIN interface may be used to change the passphrase
+ * on the PKCS#12 file and thus effectively change the passphrase
+ * for the token itself (even though the wrapped private key and
+ * certificate do not change).
+ *
+ * KEY STORAGE
+ * ===========
+ * Keys generated in the KMS are always kept securely in the KMS.
+ * The local token area contains only a list of CKA_LABEL values
+ * for all successfully created keys, no sensitive key data
+ * is stored on the client system. When a key is "destroyed", the
+ * local references to that key's label is removed and it is no
+ * longer visible to the token provider.
+ *
+ * NOTE: The KMS itself does not have an interface for destroying
+ * keys, it only allows for the keys to be disassociated from
+ * a particular "DataUnit". Key labels should not be re-used.
+ */
+#pragma init(kms_init)
+#pragma fini(kms_fini)
+
+static struct CK_FUNCTION_LIST functionList = {
+ { 2, 20 }, /* version */
+ C_Initialize,
+ C_Finalize,
+ C_GetInfo,
+ C_GetFunctionList,
+ C_GetSlotList,
+ C_GetSlotInfo,
+ C_GetTokenInfo,
+ C_GetMechanismList,
+ C_GetMechanismInfo,
+ C_InitToken,
+ C_InitPIN,
+ C_SetPIN,
+ C_OpenSession,
+ C_CloseSession,
+ C_CloseAllSessions,
+ C_GetSessionInfo,
+ C_GetOperationState,
+ C_SetOperationState,
+ C_Login,
+ C_Logout,
+ C_CreateObject,
+ C_CopyObject,
+ C_DestroyObject,
+ C_GetObjectSize,
+ C_GetAttributeValue,
+ C_SetAttributeValue,
+ C_FindObjectsInit,
+ C_FindObjects,
+ C_FindObjectsFinal,
+ C_EncryptInit,
+ C_Encrypt,
+ C_EncryptUpdate,
+ C_EncryptFinal,
+ C_DecryptInit,
+ C_Decrypt,
+ C_DecryptUpdate,
+ C_DecryptFinal,
+ C_DigestInit,
+ C_Digest,
+ C_DigestUpdate,
+ C_DigestKey,
+ C_DigestFinal,
+ C_SignInit,
+ C_Sign,
+ C_SignUpdate,
+ C_SignFinal,
+ C_SignRecoverInit,
+ C_SignRecover,
+ C_VerifyInit,
+ C_Verify,
+ C_VerifyUpdate,
+ C_VerifyFinal,
+ C_VerifyRecoverInit,
+ C_VerifyRecover,
+ C_DigestEncryptUpdate,
+ C_DecryptDigestUpdate,
+ C_SignEncryptUpdate,
+ C_DecryptVerifyUpdate,
+ C_GenerateKey,
+ C_GenerateKeyPair,
+ C_WrapKey,
+ C_UnwrapKey,
+ C_DeriveKey,
+ C_SeedRandom,
+ C_GenerateRandom,
+ C_GetFunctionStatus,
+ C_CancelFunction,
+ C_WaitForSlotEvent
+};
+
+boolean_t kms_initialized = B_FALSE;
+static pid_t kms_pid = 0;
+
+
+/* protects kms_initialized and entrance to C_Initialize/Finalize */
+static pthread_mutex_t globalmutex = PTHREAD_MUTEX_INITIALIZER;
+
+ses_to_be_freed_list_t ses_delay_freed;
+object_to_be_freed_list_t obj_delay_freed;
+kms_elem_t **kms_mechhash; /* Hash table for kCF mech numbers */
+
+static void kms_finalize_common();
+static void kms_cleanup_library();
+static void kms_init();
+static void kms_fini();
+static void kms_fork_prepare();
+static void kms_fork_after();
+
+CK_RV
+C_Initialize(CK_VOID_PTR pInitArgs)
+{
+ int initialize_pid;
+ boolean_t supplied_ok;
+ CK_RV rv = CKR_OK;
+
+ /*
+ * Grab lock to insure that only one thread enters this
+ * function at a time.
+ */
+ (void) pthread_mutex_lock(&globalmutex);
+ initialize_pid = getpid();
+
+ if (kms_initialized) {
+ if (initialize_pid == kms_pid) {
+ /*
+ * This process has called C_Initialize already
+ */
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_CRYPTOKI_ALREADY_INITIALIZED);
+ } else {
+ /*
+ * A fork has happened and the child is
+ * reinitializing. Do a kms_cleanup_library to close
+ * out any state from the parent, and then
+ * continue on.
+ */
+ kms_cleanup_library();
+ }
+ }
+
+ if (pInitArgs != NULL) {
+ CK_C_INITIALIZE_ARGS *initargs1 =
+ (CK_C_INITIALIZE_ARGS *) pInitArgs;
+
+ /* pReserved must be NULL */
+ if (initargs1->pReserved != NULL) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * ALL supplied function pointers need to have the value
+ * either NULL or non-NULL.
+ */
+ supplied_ok = (initargs1->CreateMutex == NULL &&
+ initargs1->DestroyMutex == NULL &&
+ initargs1->LockMutex == NULL &&
+ initargs1->UnlockMutex == NULL) ||
+ (initargs1->CreateMutex != NULL &&
+ initargs1->DestroyMutex != NULL &&
+ initargs1->LockMutex != NULL &&
+ initargs1->UnlockMutex != NULL);
+
+ if (!supplied_ok) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * When the CKF_OS_LOCKING_OK flag isn't set and mutex
+ * function pointers are supplied by an application,
+ * return an error. We must be able to use our own locks.
+ */
+ if (!(initargs1->flags & CKF_OS_LOCKING_OK) &&
+ (initargs1->CreateMutex != NULL)) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_CANT_LOCK);
+ }
+ }
+
+ /* Create the hash table */
+ kms_mechhash = calloc(KMECH_HASHTABLE_SIZE, sizeof (void *));
+ if (kms_mechhash == NULL) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_HOST_MEMORY);
+ }
+
+ /* Initialize the slot table */
+ rv = kms_slottable_init();
+ if (rv != CKR_OK) {
+ free(kms_mechhash);
+ goto end;
+ }
+
+ /* Initialize the object_to_be_freed list */
+ (void) pthread_mutex_init(&obj_delay_freed.obj_to_be_free_mutex, NULL);
+ obj_delay_freed.count = 0;
+ obj_delay_freed.first = NULL;
+ obj_delay_freed.last = NULL;
+
+ /* Initialize the session_to_be_freed list */
+ (void) pthread_mutex_init(&ses_delay_freed.ses_to_be_free_mutex, NULL);
+ ses_delay_freed.count = 0;
+ ses_delay_freed.first = NULL;
+ ses_delay_freed.last = NULL;
+
+ rv = KMS_Initialize();
+ if (rv != CKR_OK) {
+ free(kms_mechhash);
+ goto end;
+ }
+
+ kms_initialized = B_TRUE;
+ kms_pid = initialize_pid;
+
+end:
+ (void) pthread_mutex_unlock(&globalmutex);
+
+ return (CKR_OK);
+}
+
+/*
+ * C_Finalize is a wrapper around kms_finalize_common. The
+ * globalmutex should be locked by C_Finalize().
+ */
+CK_RV
+C_Finalize(CK_VOID_PTR pReserved)
+{
+ (void) pthread_mutex_lock(&globalmutex);
+
+ if (!kms_initialized) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+ }
+
+ /* Check to see if pReseved is NULL */
+ if (pReserved != NULL) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * Delete all the sessions for each slot and release the allocated
+ * resources
+ */
+ kms_delete_all_sessions(B_FALSE);
+
+ kms_finalize_common();
+
+ (void) pthread_mutex_unlock(&globalmutex);
+
+ return (CKR_OK);
+}
+
+/*
+ * kms_finalize_common() does the work for C_Finalize. globalmutex
+ * must be held before calling this function.
+ */
+static void
+kms_finalize_common() {
+
+ int i;
+ kms_elem_t *elem, *next;
+ kms_object_t *delay_free_obj, *tmpo;
+ kms_session_t *delay_free_ses, *tmps;
+
+ cleanup_slottable();
+ /* Walk the hash table and free all entries */
+ for (i = 0; i < KMECH_HASHTABLE_SIZE; i++) {
+ elem = kms_mechhash[i];
+ while (elem != NULL) {
+ next = elem->knext;
+ free(elem);
+ elem = next;
+ }
+ }
+
+ free(kms_mechhash);
+
+ kms_mechhash = NULL;
+ kms_initialized = B_FALSE;
+ kms_pid = 0;
+
+ /*
+ * free all entries in the delay_freed list
+ */
+ delay_free_obj = obj_delay_freed.first;
+ while (delay_free_obj != NULL) {
+ tmpo = delay_free_obj->next;
+ free(delay_free_obj);
+ delay_free_obj = tmpo;
+ }
+ obj_delay_freed.count = 0;
+ obj_delay_freed.first = NULL;
+ obj_delay_freed.last = NULL;
+ (void) pthread_mutex_destroy(&obj_delay_freed.obj_to_be_free_mutex);
+
+ delay_free_ses = ses_delay_freed.first;
+ while (delay_free_ses != NULL) {
+ tmps = delay_free_ses->next;
+ free(delay_free_ses);
+ delay_free_ses = tmps;
+ }
+ ses_delay_freed.count = 0;
+ ses_delay_freed.first = NULL;
+ ses_delay_freed.last = NULL;
+ (void) pthread_mutex_destroy(&ses_delay_freed.ses_to_be_free_mutex);
+}
+
+/*
+ * This function cleans up all the resources in the library (user space only)
+ */
+static void
+kms_cleanup_library()
+{
+ kms_slot_t *pslot = get_slotinfo();
+
+ if (pslot)
+ kms_cleanup_pri_objects_in_slot(pslot, NULL);
+
+ /*
+ * Delete all the sessions for each slot and release the allocated
+ * resources from the library. The boolean argument TRUE indicates
+ * that we only wants to clean up the resource in the library only.
+ * We don't want to clean up the corresponding kernel part of
+ * resources, because they are used by the parent process still.
+ */
+ kms_delete_all_sessions(B_TRUE);
+
+ kms_finalize_common();
+}
+
+static void
+kms_init()
+{
+ (void) pthread_atfork(kms_fork_prepare, kms_fork_after,
+ kms_fork_after);
+}
+
+/*
+ * kms_fini() function required to make sure complete cleanup
+ * is done if pkcs11_kms is ever unloaded without
+ * a C_Finalize() call.
+ */
+static void
+kms_fini()
+{
+ (void) pthread_mutex_lock(&globalmutex);
+
+ (void) KMS_Finalize();
+
+ /* if we're not initilized, do not attempt to finalize */
+ if (!kms_initialized) {
+ (void) pthread_mutex_unlock(&globalmutex);
+ return;
+ }
+
+ kms_cleanup_library();
+
+ (void) pthread_mutex_unlock(&globalmutex);
+}
+
+CK_RV
+C_GetInfo(CK_INFO_PTR pInfo)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (pInfo == NULL) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /* Check if the cryptoki was initialized */
+ pInfo->cryptokiVersion.major = CRYPTOKI_VERSION_MAJOR;
+ pInfo->cryptokiVersion.minor = CRYPTOKI_VERSION_MINOR;
+ (void) strncpy((char *)pInfo->manufacturerID,
+ MANUFACTURER_ID, 32);
+ pInfo->flags = 0;
+ (void) strncpy((char *)pInfo->libraryDescription,
+ LIBRARY_DESCRIPTION, 32);
+ pInfo->libraryVersion.major = LIBRARY_VERSION_MAJOR;
+ pInfo->libraryVersion.minor = LIBRARY_VERSION_MINOR;
+
+ return (CKR_OK);
+}
+
+CK_RV
+C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR ppFunctionList)
+{
+ if (ppFunctionList == NULL) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ *ppFunctionList = &functionList;
+
+ return (CKR_OK);
+}
+
+/*
+ * PKCS#11 states that C_GetFunctionStatus should always return
+ * CKR_FUNCTION_NOT_PARALLEL
+ */
+/*ARGSUSED*/
+CK_RV
+C_GetFunctionStatus(CK_SESSION_HANDLE hSession)
+{
+ return (CKR_FUNCTION_NOT_PARALLEL);
+}
+
+/*
+ * Take out all mutexes before fork.
+ * Order:
+ * 1. globalmutex
+ * 2. all slots mutexes (and all their sessions) via
+ * kms_acquire_all_slots_mutexes()
+ * 3. obj_delay_freed.obj_to_be_free_mutex;
+ * 4. ses_delay_freed.ses_to_be_free_mutex
+ */
+void
+kms_fork_prepare()
+{
+ (void) pthread_mutex_lock(&globalmutex);
+ if (kms_initialized) {
+ kms_acquire_all_slots_mutexes();
+ (void) pthread_mutex_lock(
+ &obj_delay_freed.obj_to_be_free_mutex);
+ (void) pthread_mutex_lock(
+ &ses_delay_freed.ses_to_be_free_mutex);
+ }
+}
+
+/*
+ * Release in opposite order to kms_fork_prepare().
+ * Function is used for parent and child.
+ */
+void
+kms_fork_after()
+{
+ if (kms_initialized) {
+ (void) pthread_mutex_unlock(
+ &ses_delay_freed.ses_to_be_free_mutex);
+ (void) pthread_mutex_unlock(
+ &obj_delay_freed.obj_to_be_free_mutex);
+ kms_release_all_slots_mutexes();
+ }
+ (void) pthread_mutex_unlock(&globalmutex);
+}
+
+/*
+ * PKCS#11 states that C_CancelFunction should always return
+ * CKR_FUNCTION_NOT_PARALLEL
+ */
+/*ARGSUSED*/
+CK_RV
+C_CancelFunction(CK_SESSION_HANDLE hSession)
+{
+ return (CKR_FUNCTION_NOT_PARALLEL);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsGlobal.h b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsGlobal.h
new file mode 100644
index 0000000000..224fd357fc
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsGlobal.h
@@ -0,0 +1,88 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _KMSGLOBAL_H
+#define _KMSGLOBAL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/crypto/common.h>
+#include <security/cryptoki.h>
+#include <security/pkcs11t.h>
+#include "kmsObject.h"
+
+typedef struct kms_elem {
+ CK_MECHANISM_TYPE type;
+ struct kms_elem *knext; /* Next in hash chain */
+} kms_elem_t;
+
+extern kms_elem_t **kms_mechhash;
+extern boolean_t kms_initialized;
+
+#define KMECH_HASHTABLE_SIZE 67
+
+/* CK_INFO: Information about cryptoki */
+#define CRYPTOKI_VERSION_MAJOR 2
+#define CRYPTOKI_VERSION_MINOR 20
+#define MANUFACTURER_ID "Oracle Corporation "
+#define LIBRARY_DESCRIPTION "Oracle Key Management System "
+#define LIBRARY_VERSION_MAJOR 1
+#define LIBRARY_VERSION_MINOR 0
+
+/* CK_SLOT_INFO: Information about our slot */
+#define SLOT_DESCRIPTION "Oracle Key Management System " \
+ " "
+#define KMS_TOKEN_LABEL "KMS "
+#define KMS_TOKEN_MODEL " "
+#define KMS_TOKEN_SERIAL " "
+#define KMS_TOKEN_FLAGS CKF_LOGIN_REQUIRED
+#define MAX_PIN_LEN 256
+#define MIN_PIN_LEN 1
+#define HARDWARE_VERSION_MAJOR 0
+#define HARDWARE_VERSION_MINOR 0
+#define FIRMWARE_VERSION_MAJOR 0
+#define FIRMWARE_VERSION_MINOR 0
+
+CK_RV crypto2pkcs11_error_number(uint_t);
+CK_RV kms_mech(CK_MECHANISM_TYPE);
+unsigned char *get_symmetric_key_value(kms_object_t *);
+void free_key_attributes();
+
+CK_RV process_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t *,
+ CK_BBOOL *);
+CK_RV get_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t);
+void free_object_attributes(caddr_t, CK_ULONG);
+CK_RV process_found_objects(kms_session_t *, CK_OBJECT_HANDLE *,
+ CK_ULONG *);
+CK_RV get_mechanism_info(kms_slot_t *, CK_MECHANISM_TYPE,
+ CK_MECHANISM_INFO_PTR, uint32_t *);
+CK_RV kms_add_extra_attr(CK_ATTRIBUTE_PTR, kms_object_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _KMSGLOBAL_H */
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeys.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeys.c
new file mode 100644
index 0000000000..80d34542aa
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeys.c
@@ -0,0 +1,179 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <strings.h>
+#include <errno.h>
+#include <security/cryptoki.h>
+#include <cryptoutil.h>
+#include "kmsGlobal.h"
+#include "kmsSession.h"
+#include "kmsObject.h"
+#include "kmsKeystoreUtil.h"
+
+static CK_RV
+kms_generate_softkey(kms_object_t *keyp)
+{
+ if ((OBJ_SEC_VALUE(keyp) = malloc(OBJ_SEC_VALUE_LEN(keyp))) == NULL)
+ return (CKR_HOST_MEMORY);
+
+ if (pkcs11_get_urandom(OBJ_SEC_VALUE(keyp),
+ OBJ_SEC_VALUE_LEN(keyp)) < 0)
+ return (CKR_DEVICE_ERROR);
+
+ return (CKR_OK);
+}
+
+CK_RV
+C_GenerateKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR phKey)
+{
+ CK_RV rv = CKR_OK;
+ kms_session_t *session_p;
+ kms_object_t *new_objp = NULL;
+ kms_slot_t *pslot;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Obtain the session pointer */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ if ((pMechanism == NULL) || (phKey == NULL)) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto failed_exit;
+ }
+
+ if ((pTemplate == NULL) && (ulCount != 0)) {
+ rv = CKR_ARGUMENTS_BAD;
+ goto failed_exit;
+ }
+
+ switch (pMechanism->mechanism) {
+ case CKM_AES_KEY_GEN:
+ break;
+ default:
+ rv = CKR_MECHANISM_INVALID;
+ goto failed_exit;
+ break;
+ }
+
+ /* Create an object record */
+ new_objp = kms_new_object();
+ if (new_objp == NULL)
+ return (CKR_HOST_MEMORY);
+
+ new_objp->mechanism = pMechanism->mechanism;
+ rv = kms_build_object(pTemplate, ulCount, new_objp);
+ if (rv != CKR_OK)
+ goto failed_exit;
+
+ /*
+ * Generate the KMS key.
+ *
+ * This will put the AES key value from the KMS key into the
+ * key object record.
+ */
+ if (new_objp->bool_attr_mask & TOKEN_BOOL_ON)
+ rv = KMS_GenerateKey(session_p, new_objp);
+ else
+ rv = kms_generate_softkey(new_objp);
+
+ if (rv != CKR_OK)
+ goto failed_exit;
+
+ if (new_objp->bool_attr_mask & TOKEN_BOOL_ON) {
+ pslot = get_slotinfo();
+ if (pslot == NULL) {
+ rv = CKR_GENERAL_ERROR;
+ goto failed_exit;
+ }
+ kms_add_token_object_to_slot(new_objp, pslot);
+ } else {
+ kms_add_object_to_session(new_objp, session_p);
+ }
+
+ *phKey = (CK_OBJECT_HANDLE)new_objp;
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+
+failed_exit:
+ if (new_objp != NULL)
+ (void) free(new_objp);
+
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_GenerateKeyPair(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_ATTRIBUTE_PTR pPublicKeyTemplate, CK_ULONG ulPublicKeyAttributeCount,
+ CK_ATTRIBUTE_PTR pPrivateKeyTemplate, CK_ULONG ulPrivateKeyAttributeCount,
+ CK_OBJECT_HANDLE_PTR phPublicKey, CK_OBJECT_HANDLE_PTR phPrivateKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_WrapKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hWrappingKey, CK_OBJECT_HANDLE hKey,
+ CK_BYTE_PTR pWrappedKey, CK_ULONG_PTR pulWrappedKeyLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_UnwrapKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hUnwrappingKey, CK_BYTE_PTR pWrappedKey,
+ CK_ULONG ulWrappedKeyLen, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_DeriveKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.c
new file mode 100644
index 0000000000..2176aed030
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.c
@@ -0,0 +1,1227 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <malloc.h>
+#include <memory.h>
+#include <strings.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <cryptoutil.h>
+#include <unistd.h>
+#include <utmpx.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <sha2.h>
+#include <security/cryptoki.h>
+#include <aes_impl.h>
+#include <sys/avl.h>
+
+#include "kmsSession.h"
+#include "kmsGlobal.h"
+#include "kmsObject.h"
+
+static CK_RV
+GetPKCS11StatusFromAgentStatus(KMS_AGENT_STATUS status);
+
+static char keystore_path[BUFSIZ];
+static boolean_t keystore_path_initialized = B_FALSE;
+static time_t last_objlist_mtime = 0;
+pthread_mutex_t objlist_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t flock_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static struct flock fl = {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ {0, 0, 0, 0}
+};
+
+#define KEYSTORE_PATH "/var/kms"
+#define ALTERNATE_KEYSTORE_PATH "KMSTOKEN_DIR"
+#define KMS_PROFILE_FILENAME "profile.cfg"
+#define KMS_DATAUNIT_DESCRIPTION "Oracle PKCS11/KMS"
+#define KMS_ATTR_DESC_PFX "PKCS#11v2.20: "
+#define KMSTOKEN_CONFIG_FILENAME "kmstoken.cfg"
+#define KMSTOKEN_LABELLIST_FILENAME "objlabels.lst"
+
+static void
+kms_hash_string(char *label, uchar_t *hash)
+{
+ SHA2_CTX ctx;
+
+ SHA2Init(SHA256, &ctx);
+ SHA2Update(&ctx, label, strlen(label));
+ SHA2Final(hash, &ctx);
+}
+
+static char *
+get_username(char *username, int len)
+{
+ struct passwd pwd, *user_info;
+ long buflen;
+ char *pwdbuf = NULL;
+
+ bzero(username, len);
+
+ buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (buflen == -1)
+ return (username); /* should not happen */
+
+ pwdbuf = calloc(1, buflen);
+ if (pwdbuf == NULL)
+ return (username); /* zero-ed earlier */
+
+ user_info = getpwuid_r(getuid(), &pwd, pwdbuf, buflen);
+
+ if (user_info != NULL)
+ (void) strlcpy(username, user_info->pw_name, len);
+
+ free(pwdbuf);
+ return (username);
+}
+
+static char *
+kms_get_keystore_path()
+{
+ char *env_val;
+ char username[sizeof (((struct utmpx *)0)->ut_user)];
+
+ if (!keystore_path_initialized) {
+ env_val = getenv(ALTERNATE_KEYSTORE_PATH);
+ bzero(keystore_path, sizeof (keystore_path));
+ /*
+ * If it isn't set or is set to the empty string use the
+ * default location. We need to check for the empty string
+ * because some users "unset" environment variables by giving
+ * them no value, this isn't the same thing as removing it
+ * from the environment.
+ */
+ if ((env_val == NULL) || (strcmp(env_val, "") == 0)) {
+ /* alternate path not specified, use /var/kms/$USER */
+ (void) snprintf(keystore_path,
+ sizeof (keystore_path), "%s/%s",
+ KEYSTORE_PATH,
+ get_username(username, sizeof (username)));
+ } else {
+ (void) strlcpy(keystore_path, env_val,
+ sizeof (keystore_path));
+ }
+ keystore_path_initialized = B_TRUE;
+ }
+ return (keystore_path);
+}
+
+static char *
+get_non_comment_line(char *cfgbuf, size_t cfglen, char *buf, size_t buflen)
+{
+ char *s = cfgbuf;
+ char *end = cfgbuf + cfglen;
+ char *f;
+
+ /* Skip over blank lines CR/LF */
+ while (s < end && (*s == '#' || *s == '\n' || *s == '\r')) {
+ /* check for comment sign */
+ if (*s == '#') {
+ /* skip the rest of the line */
+ while ((*s != '\n' || *s == '\r') && s < end)
+ s++;
+ }
+ if ((s < end) && (*s == '\n' || *s == '\r'))
+ s++;
+ }
+
+ if (s < end) {
+ char save, *e;
+ f = s; /* mark the beginning. */
+ /* Find the end of the line and null terminate it. */
+ while (*s != '\n' && *s != '\r' && *s != '#' && s < end) s++;
+ save = *s;
+ *s = 0x00;
+ (void) strncpy(buf, f, buflen);
+ *s = save;
+
+ /* Strip trailing whitespace */
+ f = buf;
+ e = f + strlen(buf) - 1;
+ while (e >= f && isspace(*e)) {
+ *e = 0x00;
+ e--;
+ }
+
+ } else {
+ /* If we reached the end, return NULL */
+ s = NULL;
+ }
+done:
+ return (s);
+}
+
+static int
+flock_fd(int fd, int cmd, pthread_mutex_t *mutex)
+{
+ int ret = 0;
+
+ (void) pthread_mutex_lock(mutex);
+
+ fl.l_type = cmd;
+
+ while ((ret = fcntl(fd, F_SETLKW, &fl)) == -1) {
+ if (errno != EINTR)
+ break;
+ }
+ (void) pthread_mutex_unlock(mutex);
+ return (ret);
+}
+
+/*
+ * Open the keystore description file in the specified mode.
+ * If the keystore doesn't exist, the "do_create_keystore"
+ * argument determines if the keystore should be created
+ */
+static int
+open_and_lock_file(char *filename, int cmd, mode_t mode,
+ pthread_mutex_t *mutex)
+{
+ int fd;
+
+ fd = open_nointr(filename, mode|O_NONBLOCK);
+ if (fd < 0)
+ return (fd);
+
+ if (flock_fd(fd, cmd, mutex)) {
+ if (fd > 0)
+ (void) close(fd);
+ return (-1);
+ }
+
+ return (fd);
+}
+
+static int
+kms_slurp_file(char *file, char *buf, size_t buflen)
+{
+ int n, fd, total = 0;
+
+ fd = open_and_lock_file(file, F_RDLCK, O_RDONLY, &flock_mutex);
+ if (fd == -1)
+ return (-1);
+
+ do {
+ n = readn_nointr(fd, &buf[total], buflen - total);
+ if (n != (buflen - total))
+ break;
+ else
+ total += n;
+ } while (total < buflen);
+
+ if (flock_fd(fd, F_UNLCK, &flock_mutex))
+ total = -1;
+
+ (void) close(fd);
+
+ return (total);
+}
+
+/*
+ * The KMS token is considered "initialized" if the file with the token
+ * configuration information is present.
+ */
+CK_BBOOL
+kms_is_initialized()
+{
+ CK_BBOOL rv;
+ char *ksdir;
+ char cfgfile_path[BUFSIZ];
+ struct stat statp;
+
+ ksdir = kms_get_keystore_path();
+ if (ksdir == NULL)
+ return (CKR_FUNCTION_FAILED);
+
+ (void) snprintf(cfgfile_path, sizeof (cfgfile_path),
+ "%s/%s", ksdir, KMSTOKEN_CONFIG_FILENAME);
+
+ if (stat(cfgfile_path, &statp))
+ rv = FALSE;
+ else
+ rv = TRUE;
+
+ return (rv);
+}
+
+static CK_RV
+kms_read_config_data(char *path, kms_cfg_info_t *cfginfo)
+{
+ CK_RV rv = CKR_OK;
+ char *cfgbuf = NULL;
+ char *ptr;
+ char buf[BUFSIZ];
+ size_t buflen = 0, remain;
+ struct stat statp;
+
+ if (path == NULL || cfginfo == NULL)
+ return (CKR_ARGUMENTS_BAD);
+
+ if (stat(path, &statp) == -1) {
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ cfgbuf = calloc(1, statp.st_size);
+ if (cfgbuf == NULL)
+ return (CKR_HOST_MEMORY);
+
+ buflen = kms_slurp_file(path, cfgbuf, statp.st_size);
+ if (buflen != statp.st_size) {
+ free(cfgbuf);
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ remain = buflen;
+ ptr = cfgbuf;
+ ptr = get_non_comment_line(ptr, remain,
+ cfginfo->name, sizeof (cfginfo->name));
+ if (ptr == NULL) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ remain = buflen - (ptr - cfgbuf);
+ ptr = get_non_comment_line(ptr, remain,
+ cfginfo->agentId, sizeof (cfginfo->agentId));
+ if (ptr == 0) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ remain = buflen - (ptr - cfgbuf);
+ ptr = get_non_comment_line(ptr, remain,
+ cfginfo->agentAddr, sizeof (cfginfo->agentAddr));
+ if (ptr == 0) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ remain = buflen - (ptr - cfgbuf);
+ ptr = get_non_comment_line(ptr, remain, buf, sizeof (buf));
+ if (ptr == 0) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ cfginfo->transTimeout = atoi(buf);
+
+ remain = buflen - (ptr - cfgbuf);
+ ptr = get_non_comment_line(ptr, remain, buf, sizeof (buf));
+ if (ptr == 0) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ cfginfo->failoverLimit = atoi(buf);
+
+ remain = buflen - (ptr - cfgbuf);
+ ptr = get_non_comment_line(ptr, remain, buf, sizeof (buf));
+ if (ptr == 0) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ cfginfo->discoveryFreq = atoi(buf);
+
+ remain = buflen - (ptr - cfgbuf);
+ ptr = get_non_comment_line(ptr, remain, buf, sizeof (buf));
+ if (ptr == 0) {
+ rv = CKR_FUNCTION_FAILED;
+ goto done;
+ }
+ cfginfo->securityMode = atoi(buf);
+done:
+ if (cfgbuf != NULL)
+ free(cfgbuf);
+ return (rv);
+}
+
+CK_BBOOL
+kms_is_pin_set()
+{
+ CK_BBOOL rv = TRUE;
+ kms_cfg_info_t kmscfg;
+ struct stat statp;
+ char *ksdir;
+ char filepath[BUFSIZ];
+
+ ksdir = kms_get_keystore_path();
+ if (ksdir == NULL)
+ return (FALSE);
+
+ (void) snprintf(filepath, sizeof (filepath),
+ "%s/%s", ksdir, KMSTOKEN_CONFIG_FILENAME);
+
+ if ((rv = kms_read_config_data(filepath, &kmscfg)))
+ return (FALSE);
+
+ /*
+ * The PK12 file is only established once the user has enrolled
+ * and is thus considered having a PIN set.
+ */
+ (void) snprintf(filepath, sizeof (filepath),
+ "%s/%s/%s", ksdir, kmscfg.agentId, CLIENT_PK12_FILE);
+
+ if (stat(filepath, &statp))
+ rv = FALSE; /* file doesn't exist. */
+ else
+ rv = TRUE; /* File exists, PIN is set */
+
+ return (rv);
+}
+
+void
+kms_clear_label_list(avl_tree_t *tree)
+{
+ void *cookie = NULL;
+ objlabel_t *node;
+
+ while ((node = avl_destroy_nodes(tree, &cookie)) != NULL) {
+ free(node->label);
+ free(node);
+ }
+}
+
+static void
+add_label_node(avl_tree_t *tree, char *label)
+{
+ avl_index_t where;
+ objlabel_t *node;
+ objlabel_t *newnode;
+ int i;
+
+ if (tree == NULL || label == NULL)
+ return;
+
+ /* Remove trailing CR */
+ i = strlen(label) - 1;
+ while (i > 0 && label[i] == '\n')
+ label[i--] = 0x00;
+
+ newnode = calloc(1, sizeof (objlabel_t));
+ newnode->label = (char *)strdup(label);
+ if (newnode->label == NULL) {
+ free(newnode);
+ return;
+ }
+ /* see if this entry already exists */
+ node = avl_find(tree, newnode, &where);
+ if (node == NULL) {
+ avl_insert(tree, newnode, where);
+ } else {
+ /* It's a dup, don't add it */
+ free(newnode->label);
+ free(newnode);
+ }
+}
+
+CK_RV
+kms_reload_labels(kms_session_t *sp)
+{
+ CK_RV rv = CKR_OK;
+ char *cfgbuf = NULL, *ptr, buffer[BUFSIZ];
+ size_t buflen, remain;
+ struct stat statp;
+ char *ksdir;
+ char labelfile[BUFSIZ];
+
+ ksdir = kms_get_keystore_path();
+ if (ksdir == NULL)
+ return (CKR_GENERAL_ERROR);
+
+ (void) snprintf(labelfile, sizeof (labelfile),
+ "%s/%s", ksdir, KMSTOKEN_LABELLIST_FILENAME);
+
+ bzero(&statp, sizeof (statp));
+ if (stat(labelfile, &statp) == -1) {
+ if (errno == ENOENT) {
+ FILE *fp;
+ /* Create it */
+ fp = fopen(labelfile, "w");
+ if (fp == NULL)
+ return (CKR_GENERAL_ERROR);
+ (void) fclose(fp);
+ }
+ }
+
+ if (statp.st_size == 0) {
+ return (CKR_OK);
+ }
+
+ cfgbuf = calloc(1, statp.st_size);
+ if (cfgbuf == NULL)
+ return (CKR_HOST_MEMORY);
+
+ buflen = kms_slurp_file(labelfile, cfgbuf, statp.st_size);
+ if (buflen != statp.st_size) {
+ free(cfgbuf);
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ if (statp.st_mtime == last_objlist_mtime) {
+ /* No change */
+ goto end;
+ }
+
+ /* If we got here, we need to refresh the entire list */
+ kms_clear_label_list(&sp->objlabel_tree);
+
+ /*
+ * Read each line and add it as a label node.
+ */
+ remain = buflen;
+ ptr = cfgbuf;
+ while (remain > 0) {
+ ptr = get_non_comment_line(ptr, remain,
+ buffer, sizeof (buffer));
+ if (ptr == NULL) {
+ goto end;
+ }
+ add_label_node(&sp->objlabel_tree, buffer);
+ remain = buflen - (ptr - cfgbuf);
+ }
+end:
+ if (cfgbuf)
+ free(cfgbuf);
+
+ return (rv);
+}
+
+static CK_RV
+kms_get_object_label(kms_object_t *obj, char *label, int len)
+{
+ CK_RV rv = CKR_OK;
+ CK_ATTRIBUTE stLabel;
+
+ bzero(label, len);
+
+ stLabel.type = CKA_LABEL;
+ stLabel.pValue = label;
+ stLabel.ulValueLen = len;
+
+ /*
+ * The caller MUST provide a CKA_LABEL when deleting.
+ */
+ rv = kms_get_attribute(obj, &stLabel);
+
+ return (rv);
+}
+
+/*
+ * Retrieve a data unit associated with the label.
+ */
+static CK_RV
+kms_get_data_unit(kms_session_t *session, char *label,
+ KMSAgent_DataUnit *pDataUnit)
+{
+ KMS_AGENT_STATUS status;
+ const utf8cstr pDescription = KMS_DATAUNIT_DESCRIPTION;
+ uchar_t externalUniqueId[SHA256_DIGEST_LENGTH];
+
+ /* Find the data unit that holds the key */
+ kms_hash_string(label, externalUniqueId);
+
+ status = KMSAgent_RetrieveDataUnitByExternalUniqueID(
+ &session->kmsProfile,
+ (const unsigned char *)externalUniqueId,
+ sizeof (externalUniqueId),
+ label,
+ pDescription,
+ pDataUnit);
+
+ if (status != KMS_AGENT_STATUS_OK) {
+ return (GetPKCS11StatusFromAgentStatus(status));
+ }
+
+ return (CKR_OK);
+}
+
+static CK_RV
+kms_decode_description(char *description, kms_object_t *pKey)
+{
+ CK_RV rv = CKR_OK;
+ char *ptr;
+ uint32_t keylen;
+ u_longlong_t boolattrs;
+
+ /* If it doesn't start with the expected prefix, return */
+ if (strncmp(description, KMS_ATTR_DESC_PFX,
+ strlen(KMS_ATTR_DESC_PFX)))
+ return (rv);
+
+ ptr = description + strlen(KMS_ATTR_DESC_PFX);
+
+ /*
+ * Decode as follows:
+ * CK_OBJECT_CLASS (2 bytes)
+ * CK_KEY_TYPE (2 bytes)
+ * CKA_VALUE_LEN (4 bytes)
+ * CK_CERTIFICATE_TYPE (2 bytes - not used)
+ * CK_MECHANISM_TYPE (4 bytes)
+ * boolean attributes (3 bytes)
+ * extra attributes (1 byte)
+ * non-boolean attributes
+ */
+ if (sscanf(ptr,
+ "%02lx%02lx%02x00%04lx%06llx00",
+ &pKey->class,
+ &pKey->key_type,
+ &keylen,
+ &pKey->mechanism,
+ &boolattrs) != 5)
+ /* We didn't get the full set of attributes */
+ rv = CKR_ATTRIBUTE_TYPE_INVALID;
+ pKey->bool_attr_mask = boolattrs;
+
+ return (rv);
+}
+
+/*
+ * Create a new PKCS#11 object record for the KMSAgent_Key.
+ */
+static CK_RV
+kms_new_key_object(
+ char *label,
+ KMSAgent_DataUnit *dataUnit,
+ KMSAgent_Key *pKey,
+ kms_object_t **pObj)
+{
+ CK_RV rv = CKR_OK;
+ CK_BBOOL bTrue = B_TRUE;
+ CK_KEY_TYPE keytype = CKK_AES;
+ CK_OBJECT_CLASS class = CKO_SECRET_KEY;
+ CK_ULONG keylen;
+ kms_object_t *newObj;
+
+ CK_ATTRIBUTE template[] = {
+ {CKA_TOKEN, NULL, sizeof (bTrue)},
+ {CKA_LABEL, NULL, 0},
+ {CKA_KEY_TYPE, NULL, sizeof (keytype)},
+ {CKA_CLASS, NULL, sizeof (class)},
+ {CKA_VALUE, NULL, NULL},
+ {CKA_VALUE_LEN, NULL, NULL},
+ {CKA_PRIVATE, NULL, sizeof (bTrue)},
+ };
+
+ keylen = (CK_ULONG)pKey->m_iKeyLength;
+
+ template[0].pValue = &bTrue;
+ template[1].pValue = label;
+ template[1].ulValueLen = strlen(label);
+ template[2].pValue = &keytype;
+ template[3].pValue = &class;
+ template[4].pValue = pKey->m_acKey;
+ template[4].ulValueLen = pKey->m_iKeyLength;
+ template[5].pValue = &keylen;
+ template[5].ulValueLen = sizeof (keylen);
+ template[6].pValue = &bTrue;
+
+ newObj = kms_new_object();
+ if (newObj == NULL)
+ return (CKR_HOST_MEMORY);
+
+ /*
+ * Decode the DataUnit description field to find various
+ * object attributes.
+ */
+ rv = kms_decode_description(dataUnit->m_acDescription, newObj);
+ if (rv) {
+ free(newObj);
+ return (rv);
+ }
+ /*
+ * Set the template keytype and class according to the
+ * data parsed from the description.
+ */
+ if (newObj->key_type)
+ keytype = newObj->key_type;
+ if (newObj->class)
+ class = newObj->class;
+
+ rv = kms_build_object(template, 7, newObj);
+ if (rv) {
+ free(newObj);
+ return (rv);
+ }
+
+ newObj->bool_attr_mask |= TOKEN_BOOL_ON;
+
+ *pObj = newObj;
+ return (rv);
+}
+
+static CK_RV
+kms_get_data_unit_keys(kms_session_t *sp, KMSAgent_DataUnit *dataUnit,
+ KMSAgent_ArrayOfKeys **keylist, int *numkeys)
+{
+ CK_RV rv = CKR_OK;
+ KMSAgent_ArrayOfKeys *kmskeys = NULL;
+ KMS_AGENT_STATUS status;
+ int keysLeft = 0;
+
+ status = KMSAgent_RetrieveDataUnitKeys(
+ &sp->kmsProfile, dataUnit,
+ KMS_MAX_PAGE_SIZE, 0,
+ (int * const)&keysLeft,
+ NULL, /* KeyID */
+ &kmskeys);
+
+ if (status != KMS_AGENT_STATUS_OK) {
+ return (GetPKCS11StatusFromAgentStatus(status));
+ }
+
+ if (keylist != NULL && kmskeys != NULL)
+ *keylist = kmskeys;
+
+ if (numkeys != NULL && kmskeys != NULL)
+ *numkeys = kmskeys->m_iSize;
+
+ if (keylist == NULL && kmskeys != NULL)
+ KMSAgent_FreeArrayOfKeys(kmskeys);
+
+ return (rv);
+}
+
+
+/*
+ * Retrieve a key from KMS. We can't use "RetrieveKey" because
+ * we don't know the key id. Instead get all keys associated
+ * with our data unit (there should be only 1.
+ */
+CK_RV
+KMS_RetrieveKeyObj(kms_session_t *sp, char *label, kms_object_t **pobj)
+{
+ CK_RV rv = CKR_OK;
+ KMSAgent_DataUnit dataUnit;
+ KMSAgent_ArrayOfKeys *kmsKeys = NULL;
+ KMSAgent_Key *pKey;
+
+ rv = kms_get_data_unit(sp, label, &dataUnit);
+ if (rv != CKR_OK)
+ return (rv);
+
+ rv = kms_get_data_unit_keys(sp, &dataUnit, &kmsKeys, NULL);
+
+ if (rv != CKR_OK || kmsKeys == NULL || kmsKeys->m_iSize == 0)
+ return (CKR_GENERAL_ERROR);
+
+ pKey = &kmsKeys->m_pKeys[0];
+
+ rv = kms_new_key_object(label, &dataUnit, pKey, pobj);
+
+ KMSAgent_FreeArrayOfKeys(kmsKeys);
+ return (rv);
+}
+
+CK_RV
+KMS_RefreshObjectList(kms_session_t *sp, kms_slot_t *pslot)
+{
+ kms_object_t *pObj;
+ char label[BUFSIZ];
+ CK_RV rv;
+ objlabel_t *node;
+
+ rv = kms_reload_labels(sp);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /*
+ * If an object is not in the list, reload it from KMS.
+ */
+ node = avl_first(&sp->objlabel_tree);
+ while (node != NULL) {
+ boolean_t found = FALSE;
+ /* Search object list for matching object */
+ pObj = pslot->sl_tobj_list;
+ while (pObj != NULL && !found) {
+ (void) pthread_mutex_lock(&pObj->object_mutex);
+ if ((rv = kms_get_object_label(pObj, label,
+ sizeof (label))) != CKR_OK) {
+ (void) pthread_mutex_unlock(
+ &pObj->object_mutex);
+ return (rv);
+ }
+ (void) pthread_mutex_unlock(&pObj->object_mutex);
+ found = (strcmp(label, node->label) == 0);
+ pObj = pObj->next;
+ }
+ if (!found) {
+ /*
+ * Fetch KMS key and prepend it to the
+ * token object list for the slot.
+ */
+ rv = KMS_RetrieveKeyObj(sp, node->label, &pObj);
+ if (rv == CKR_OK) {
+ if (pslot->sl_tobj_list == NULL) {
+ pslot->sl_tobj_list = pObj;
+ pObj->prev = NULL;
+ pObj->next = NULL;
+ } else {
+ pObj->next = pslot->sl_tobj_list;
+ pObj->prev = NULL;
+ pslot->sl_tobj_list = pObj;
+ }
+ }
+ }
+ node = AVL_NEXT(&sp->objlabel_tree, node);
+ }
+ return (rv);
+}
+
+CK_RV
+KMS_Initialize(void)
+{
+ char *ksdir;
+ struct stat fn_stat;
+ KMS_AGENT_STATUS kmsrv;
+
+ ksdir = kms_get_keystore_path();
+ if (ksdir == NULL)
+ return (CKR_GENERAL_ERROR);
+
+ /*
+ * If the keystore directory doesn't exist, create it.
+ */
+ if ((stat(ksdir, &fn_stat) != 0) && (errno == ENOENT)) {
+ if (mkdir(ksdir, S_IRUSR|S_IWUSR|S_IXUSR) < 0) {
+ if (errno != EEXIST)
+ return (CKR_GENERAL_ERROR);
+ }
+ }
+
+ if ((kmsrv = KMSAgent_InitializeLibrary(ksdir, FALSE)) !=
+ KMS_AGENT_STATUS_OK) {
+ return (GetPKCS11StatusFromAgentStatus(kmsrv));
+ }
+
+ return (CKR_OK);
+}
+
+CK_RV
+KMS_Finalize()
+{
+ last_objlist_mtime = 0;
+
+ return (KMSAgent_FinalizeLibrary() == KMS_AGENT_STATUS_OK) ?
+ CKR_OK : CKR_FUNCTION_FAILED;
+}
+
+CK_RV
+KMS_ChangeLocalPWD(kms_session_t *session,
+ const char *pOldPassword,
+ const char *pNewPassword)
+{
+ KMS_AGENT_STATUS status;
+
+ status = KMSAgent_ChangeLocalPWD(
+ &session->kmsProfile,
+ (char * const)pOldPassword,
+ (char * const)pNewPassword);
+
+ return (GetPKCS11StatusFromAgentStatus(status));
+}
+
+CK_RV
+KMS_GetConfigInfo(kms_cfg_info_t *cfginfo)
+{
+ CK_RV rv = CKR_OK;
+ char cfgfile_path[BUFSIZ];
+ char *ksdir = kms_get_keystore_path();
+
+ if (ksdir == NULL)
+ return (CKR_GENERAL_ERROR);
+
+ (void) snprintf(cfgfile_path, sizeof (cfgfile_path),
+ "%s/%s", ksdir, KMSTOKEN_CONFIG_FILENAME);
+
+ rv = kms_read_config_data(cfgfile_path, cfginfo);
+
+ return (rv);
+}
+
+CK_RV
+KMS_LoadProfile(KMSClientProfile *profile,
+ kms_cfg_info_t *kmscfg,
+ const char *pPassword,
+ size_t iPasswordLength)
+{
+ KMS_AGENT_STATUS status;
+ CK_RV rv;
+ char *sPassword;
+ char cfgfile_path[BUFSIZ];
+ char *ksdir;
+
+ sPassword = calloc(1, iPasswordLength + 1);
+ if (sPassword == NULL)
+ return (CKR_FUNCTION_FAILED);
+
+ (void) memcpy(sPassword, pPassword, iPasswordLength);
+
+ ksdir = kms_get_keystore_path();
+ if (ksdir == NULL)
+ return (CKR_GENERAL_ERROR);
+
+ (void) snprintf(cfgfile_path, sizeof (cfgfile_path),
+ "%s/%s", ksdir, KMSTOKEN_CONFIG_FILENAME);
+
+ if ((rv = kms_read_config_data(cfgfile_path, kmscfg))) {
+ free(sPassword);
+ return (rv);
+ }
+
+ /* First, try to load existing profile */
+ status = KMSAgent_LoadProfile(
+ profile,
+ kmscfg->name,
+ kmscfg->agentId,
+ sPassword,
+ kmscfg->agentAddr,
+ kmscfg->transTimeout,
+ kmscfg->failoverLimit,
+ kmscfg->discoveryFreq,
+ kmscfg->securityMode);
+
+ free(sPassword);
+ return (GetPKCS11StatusFromAgentStatus(status));
+}
+
+static CK_RV
+GetPKCS11StatusFromAgentStatus(KMS_AGENT_STATUS status)
+{
+ switch (status) {
+ case KMS_AGENT_STATUS_OK:
+ return (CKR_OK);
+
+ case KMS_AGENT_STATUS_GENERIC_ERROR:
+ return (CKR_GENERAL_ERROR);
+
+ case KMS_AGENT_STATUS_NO_MEMORY:
+ return (CKR_HOST_MEMORY);
+
+ case KMS_AGENT_STATUS_INVALID_PARAMETER:
+ return (CKR_ARGUMENTS_BAD);
+
+ case KMS_AGENT_STATUS_PROFILE_NOT_LOADED:
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ case KMS_AGENT_STATUS_KMS_UNAVAILABLE:
+ case KMS_AGENT_STATUS_KMS_NO_READY_KEYS:
+ return (CKR_DEVICE_MEMORY);
+
+ case KMS_AGENT_STATUS_NO_FIPS_KMAS_AVAILABLE:
+ return (CKR_GENERAL_ERROR);
+
+ case KMS_AGENT_STATUS_PROFILE_ALREADY_LOADED:
+ return (CKR_USER_ANOTHER_ALREADY_LOGGED_IN);
+
+ case KMS_AGENT_STATUS_FIPS_KAT_AES_KEYWRAP_ERROR:
+ case KMS_AGENT_STATUS_FIPS_KAT_AES_ECB_ERROR:
+ case KMS_AGENT_STATUS_FIPS_KAT_HMAC_SHA1_ERROR:
+ return (CKR_DEVICE_ERROR);
+
+ case KMS_AGENT_STATUS_ACCESS_DENIED:
+ case KMS_AGENT_LOCAL_AUTH_FAILURE:
+ return (CKR_PIN_INCORRECT);
+
+ case KMS_AGENT_STATUS_SERVER_BUSY:
+ case KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS:
+ case KMS_AGENT_STATUS_DATA_UNIT_ID_NOT_FOUND_EXTERNAL_ID_EXISTS:
+ case KMS_AGENT_STATUS_KEY_DOES_NOT_EXIST:
+ case KMS_AGENT_STATUS_KEY_DESTROYED:
+ case KMS_AGENT_AES_KEY_UNWRAP_ERROR:
+ case KMS_AGENT_AES_KEY_WRAP_SETUP_ERROR:
+ case KMS_AGENT_STATUS_KEY_CALLOUT_FAILURE:
+ default:
+ return (CKR_GENERAL_ERROR);
+ }
+}
+
+void
+KMS_UnloadProfile(KMSClientProfile *kmsProfile)
+{
+ (void) KMSAgent_UnloadProfile(kmsProfile);
+}
+
+/*
+ * kms_update_label_file
+ *
+ * KMS doesn't provide an API to allow one to query for available
+ * data units (which map 1-1 to keys). To allow for PKCS11 to
+ * query for a list of available objects, we keep a local list
+ * and update it when an object is added or deleted.
+ */
+static CK_RV
+kms_update_label_file(kms_session_t *sp)
+{
+ CK_RV rv = CKR_OK;
+ objlabel_t *node;
+ char *ksdir, *tmpfile, labelfile[BUFSIZ];
+ FILE *fp;
+ int fd;
+ struct stat statp;
+
+ ksdir = kms_get_keystore_path();
+ if (ksdir == NULL)
+ return (CKR_GENERAL_ERROR);
+
+ (void) snprintf(labelfile, sizeof (labelfile),
+ "%s/%s", ksdir, KMSTOKEN_LABELLIST_FILENAME);
+
+ tmpfile = tempnam(ksdir, "kmspk11");
+ if (tmpfile == NULL)
+ return (CKR_HOST_MEMORY);
+
+ fp = fopen(tmpfile, "w");
+ if (fp == NULL) {
+ free(tmpfile);
+ return (CKR_GENERAL_ERROR);
+ }
+
+ /* Lock it even though its a temporary file */
+ fd = fileno(fp);
+ if ((rv = flock_fd(fd, F_WRLCK, &objlist_mutex))) {
+ (void) fclose(fp);
+ free(tmpfile);
+ return (rv);
+ }
+
+ node = avl_first(&sp->objlabel_tree);
+ while (node != NULL) {
+ if (node->label != NULL)
+ (void) fprintf(fp, "%s\n", node->label);
+ node = AVL_NEXT(&sp->objlabel_tree, node);
+ }
+
+ /* Update the last mtime */
+ if (fstat(fd, &statp) == 0) {
+ last_objlist_mtime = statp.st_mtime;
+ }
+
+ (void) flock_fd(fd, F_UNLCK, &objlist_mutex);
+ (void) fclose(fp);
+
+ (void) unlink(labelfile);
+ if (rename(tmpfile, labelfile))
+ rv = CKR_GENERAL_ERROR;
+
+ free(tmpfile);
+ return (rv);
+}
+
+/*
+ * Destroy a key in the KMS by disassociating an entire data unit.
+ * The KMSAgent API does not have an interface for destroying an
+ * individual key.
+ */
+CK_RV
+KMS_DestroyKey(kms_session_t *session, kms_object_t *i_oKey)
+{
+ CK_RV rv;
+ KMSAgent_DataUnit oDataUnit;
+ KMS_AGENT_STATUS status;
+ char label[BUFSIZ];
+ objlabel_t labelnode, *tnode;
+ avl_index_t where = 0;
+
+ /*
+ * The caller MUST provide a CKA_LABEL when deleting.
+ */
+ (void) pthread_mutex_lock(&i_oKey->object_mutex);
+ if ((rv = kms_get_object_label(i_oKey, label, sizeof (label)))) {
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+ return (rv);
+ }
+
+ rv = kms_get_data_unit(session, label, &oDataUnit);
+ if (rv != CKR_OK)
+ return (rv);
+
+ status = KMSAgent_DisassociateDataUnitKeys(
+ &session->kmsProfile, &oDataUnit);
+
+ /*
+ * Remove the label from the label list and update
+ * the file that tracks active keys.
+ */
+ bzero(&labelnode, sizeof (labelnode));
+ labelnode.label = label;
+
+ if ((tnode = avl_find(&session->objlabel_tree,
+ &labelnode, &where)) != NULL)
+ avl_remove(&session->objlabel_tree, tnode);
+
+ /* rewrite the list of labels to disk */
+ rv = kms_update_label_file(session);
+ if (rv)
+ /* Ignore error here */
+ rv = CKR_OK;
+
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+
+ return (GetPKCS11StatusFromAgentStatus(status));
+}
+
+void
+kms_encode_attributes(kms_object_t *pKey, char *attrstr, int len)
+{
+ char *ptr;
+
+ bzero(attrstr, len);
+
+ (void) strlcpy(attrstr, KMS_ATTR_DESC_PFX, len);
+ ptr = attrstr + strlen(attrstr);
+
+ /*
+ * Encode as follows:
+ * CK_OBJECT_CLASS (2 bytes)
+ * CK_KEY_TYPE (2 bytes)
+ * CKA_VALUE_LEN (4 bytes)
+ * CK_CERTIFICATE_TYPE (2 bytes - not used)
+ * CK_MECHANISM_TYPE (4 bytes)
+ * boolean attributes (3 bytes)
+ * extra attributes (1 byte)
+ * non-boolean attributes
+ */
+ (void) snprintf(ptr, len - strlen(attrstr),
+ "%02x%02x%02x00%04x%06x00",
+ pKey->class,
+ pKey->key_type,
+ 32,
+ pKey->mechanism,
+ (pKey->bool_attr_mask & 0x00FFFFFF));
+}
+
+CK_RV
+KMS_GenerateKey(kms_session_t *session, kms_object_t *i_oKey)
+{
+ CK_RV rv;
+ CK_ATTRIBUTE stLabel;
+ KMSAgent_DataUnit oDataUnit;
+ KMSAgent_Key oKey;
+ KMS_AGENT_STATUS status;
+ char label[128];
+ uchar_t externalUniqueId[SHA256_DIGEST_LENGTH];
+ char pDescription[KMS_MAX_DESCRIPTION + 1];
+
+ (void) pthread_mutex_lock(&i_oKey->object_mutex);
+
+ stLabel.type = CKA_LABEL;
+ stLabel.pValue = label;
+ stLabel.ulValueLen = sizeof (label);
+
+ /*
+ * The caller MUST provide a CKA_LABEL for storing in the KMS.
+ */
+ if ((rv = kms_get_attribute(i_oKey, &stLabel)) != CKR_OK) {
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+ return (rv);
+ }
+
+ label[stLabel.ulValueLen] = '\0';
+
+ kms_hash_string(label, externalUniqueId);
+
+ /* Encode attributes in Description */
+ kms_encode_attributes(i_oKey, pDescription,
+ sizeof (pDescription));
+
+ status = KMSAgent_CreateDataUnit(
+ &session->kmsProfile,
+ (const unsigned char *)externalUniqueId,
+ sizeof (externalUniqueId),
+ label, /* externalTag */
+ pDescription,
+ &oDataUnit);
+
+ /*
+ * If the DataUnit exists, check to see if it has any keys.
+ * If it has no keys, then it is OK to continue.
+ */
+ if (status == KMS_AGENT_STATUS_EXTERNAL_UNIQUE_ID_EXISTS) {
+ int numkeys = 0;
+
+ rv = kms_get_data_unit(session, label, &oDataUnit);
+ if (rv != CKR_OK)
+ return (rv);
+
+ rv = kms_get_data_unit_keys(session,
+ &oDataUnit, NULL, &numkeys);
+
+ if (rv != CKR_OK || numkeys > 0)
+ /*
+ * This would be better if there were PKCS#11
+ * error codes for duplicate objects or
+ * something like that.
+ */
+ return (CKR_ARGUMENTS_BAD);
+
+ /* If no keys associated with data unit, continue */
+ status = KMS_AGENT_STATUS_OK;
+ }
+
+ if (status != KMS_AGENT_STATUS_OK) {
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+ return (GetPKCS11StatusFromAgentStatus(status));
+ }
+
+ status = KMSAgent_CreateKey(&session->kmsProfile,
+ &oDataUnit, "", &oKey);
+
+ if (status != KMS_AGENT_STATUS_OK) {
+ /*
+ * Clean up the old data unit.
+ */
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+ return (GetPKCS11StatusFromAgentStatus(status));
+ }
+
+ /*
+ * KMS Agent only creates AES-256 keys, so ignore what the user
+ * requested at this point.
+ */
+ OBJ_SEC_VALUE(i_oKey) = malloc(oKey.m_iKeyLength);
+ if (OBJ_SEC_VALUE(i_oKey) == NULL) {
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+ return (CKR_HOST_MEMORY);
+ }
+ (void) memcpy(OBJ_SEC_VALUE(i_oKey), oKey.m_acKey,
+ oKey.m_iKeyLength);
+ OBJ_SEC_VALUE_LEN(i_oKey) = oKey.m_iKeyLength;
+
+ /*
+ * Add the label to the local list of available objects
+ */
+ add_label_node(&session->objlabel_tree, label);
+
+ rv = kms_update_label_file(session);
+
+ (void) pthread_mutex_unlock(&i_oKey->object_mutex);
+
+ return (GetPKCS11StatusFromAgentStatus(status));
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.h b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.h
new file mode 100644
index 0000000000..02e627f9fa
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsKeystoreUtil.h
@@ -0,0 +1,57 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _KEYSTOREUTIL_H
+#define _KEYSTOREUTIL_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "kmsSession.h"
+#include "kmsObject.h"
+
+CK_RV KMS_Initialize(void);
+CK_RV KMS_Finalize();
+CK_RV KMS_LoadProfile(KMSClientProfile *, kms_cfg_info_t *,
+ const char *, size_t);
+CK_RV KMS_GenerateKey(kms_session_t *, kms_object_t *);
+CK_RV KMS_DestroyKey(kms_session_t *, kms_object_t *);
+void KMS_UnloadProfile(KMSClientProfile *);
+CK_RV KMS_RefreshObjectList(kms_session_t *, kms_slot_t *);
+CK_RV KMS_ChangeLocalPWD(kms_session_t *, const char *, const char *);
+CK_RV KMS_GetConfigInfo(kms_cfg_info_t *);
+
+CK_BBOOL kms_is_initialized();
+CK_BBOOL kms_is_pin_set();
+CK_RV kms_reload_labels(kms_session_t *);
+void kms_clear_label_list(avl_tree_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _KEYSTOREUTIL_H */
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.c
new file mode 100644
index 0000000000..2ddd76fab9
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.c
@@ -0,0 +1,664 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <errno.h>
+#include <string.h>
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+#include "kmsObject.h"
+#include "kmsSession.h"
+
+CK_RV
+C_CreateObject(CK_SESSION_HANDLE hSession,
+ CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulCount,
+ CK_OBJECT_HANDLE_PTR phObject)
+{
+
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if ((pTemplate == NULL) || (ulCount == 0) ||
+ (phObject == NULL)) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Create a new object. */
+ rv = kms_add_object(pTemplate, ulCount, phObject, session_p);
+
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ REFRELE(session_p, ses_lock_held);
+
+ return (rv);
+}
+
+CK_RV
+C_CopyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
+ CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
+ CK_OBJECT_HANDLE_PTR phNewObject)
+{
+
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+ kms_object_t *old_object;
+ kms_object_t *new_object = NULL;
+ int i;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Check arguments */
+ if (((ulCount > 0) && (pTemplate == NULL)) ||
+ (phNewObject == NULL)) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Obtain the object pointer. */
+ HANDLE2OBJECT(hObject, old_object, rv);
+ if (rv != CKR_OK) {
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+
+ (void) pthread_mutex_lock(&old_object->object_mutex);
+
+ if (old_object->is_lib_obj) {
+ /*
+ * Copy the old object to a new object.
+ * The 3rd argument with TRUE value indicates that
+ * everything in the object will be duplicated.
+ */
+ rv = kms_copy_object(old_object, &new_object, B_TRUE,
+ session_p);
+ (void) pthread_mutex_unlock(&old_object->object_mutex);
+ if ((rv != CKR_OK) || (new_object == NULL)) {
+ /*
+ * Most likely we ran out of space.
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ OBJ_REFRELE(old_object);
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+
+ new_object->is_lib_obj = B_TRUE;
+
+ /* Modify the object attribute if requested */
+ for (i = 0; i < ulCount; i++) {
+ /* Set the requested attribute into the new object. */
+ rv = kms_set_attribute(new_object, &pTemplate[i],
+ B_TRUE);
+
+ if (rv != CKR_OK) {
+ kms_cleanup_object(new_object);
+ OBJ_REFRELE(old_object);
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+ }
+
+ /* Insert the new object into this session's object list. */
+ kms_add_object_to_session(new_object, session_p);
+
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ OBJ_REFRELE(old_object);
+ REFRELE(session_p, ses_lock_held);
+
+ /* set handle of the new object */
+ *phNewObject = (CK_ULONG)new_object;
+
+ }
+
+ return (rv);
+
+failed_cleanup:
+ if (new_object != NULL) {
+ (void) kms_free_object(new_object);
+ }
+
+ OBJ_REFRELE(old_object);
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
+
+CK_RV
+C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
+{
+ CK_RV rv;
+ kms_object_t *object_p;
+ kms_session_t *session_p = (kms_session_t *)(hSession);
+ kms_slot_t *pslot;
+ boolean_t ses_lock_held = B_FALSE;
+ CK_SESSION_HANDLE creating_session;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * The reason that we don't call handle2session is because
+ * the argument hSession may not be the creating_session of
+ * the object to be destroyed, and we want to avoid the lock
+ * contention. The handle2session will be called later for
+ * the creating_session.
+ */
+ if ((session_p == NULL) ||
+ (session_p->magic_marker != KMSTOKEN_SESSION_MAGIC)) {
+ return (CKR_SESSION_HANDLE_INVALID);
+ }
+ /* Obtain the object pointer without incrementing reference count. */
+ HANDLE2OBJECT_DESTROY(hObject, object_p, rv);
+ if (rv != CKR_OK) {
+ return (rv);
+ }
+
+ /* Only session objects can be destroyed at a read-only session. */
+ if ((session_p->ses_RO) &&
+ (object_p->bool_attr_mask & TOKEN_BOOL_ON)) {
+ return (CKR_SESSION_READ_ONLY);
+ }
+
+
+ /*
+ * If the object is a session object, obtain the session handle
+ * which object belongs to. For a token object, we will use the
+ * session handle from the caller, because the session used to
+ * create the token object may no longer exist.
+ */
+ if (!(object_p->bool_attr_mask & TOKEN_BOOL_ON))
+ creating_session = object_p->session_handle;
+ else
+ creating_session = hSession;
+
+ rv = handle2session(creating_session, &session_p);
+ if (rv != CKR_OK) {
+ return (rv);
+ }
+
+ /*
+ * Set OBJECT_IS_DELETING flag so any access to this
+ * object will be rejected.
+ */
+ (void) pthread_mutex_lock(&object_p->object_mutex);
+ if (object_p->obj_delete_sync & OBJECT_IS_DELETING) {
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+ REFRELE(session_p, ses_lock_held);
+ return (CKR_OBJECT_HANDLE_INVALID);
+ }
+ object_p->obj_delete_sync |= OBJECT_IS_DELETING;
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+
+ if (object_p->bool_attr_mask & TOKEN_BOOL_ON) {
+ /*
+ * The first FALSE boolean argument indicates that the caller
+ * does not hold the slot lock. The second FALSE boolean
+ * argument indicates that the caller wants to clean up the
+ * object in the HW provider also.
+ */
+ pslot = get_slotinfo();
+ rv = kms_delete_token_object(pslot, session_p, object_p,
+ B_FALSE, B_FALSE);
+ } else {
+ /*
+ * The first FALSE boolean argument indicates that the caller
+ * does not hold the session lock. The second FALSE boolean
+ * argument indicates that the caller wants to clean the object
+ * in the HW provider also.
+ */
+ rv = kms_delete_object(session_p, object_p, B_FALSE,
+ B_FALSE);
+ }
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
+
+CK_RV
+C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
+ CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
+{
+
+ CK_RV rv = CKR_OK, rv1 = CKR_OK;
+ kms_object_t *object_p;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+ int i;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if ((pTemplate == NULL) || (ulCount == 0))
+ return (CKR_ARGUMENTS_BAD);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Obtain the object pointer. */
+ HANDLE2OBJECT(hObject, object_p, rv);
+ if (rv != CKR_OK) {
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+
+ /* Acquire the lock on the object. */
+ (void) pthread_mutex_lock(&object_p->object_mutex);
+
+ /*
+ * The object was created in the library. The library
+ * contains the value information of each attribute.
+ */
+ for (i = 0; i < ulCount; i++) {
+ /*
+ * Get the value of each attribute in the template.
+ * (We must process EVERY attribute in the template.)
+ */
+ rv = kms_get_attribute(object_p, &pTemplate[i]);
+ if (rv != CKR_OK)
+ rv1 = rv;
+ }
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+
+clean_exit:
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ OBJ_REFRELE(object_p);
+ REFRELE(session_p, ses_lock_held);
+ rv = rv1;
+ return (rv);
+}
+
+CK_RV
+C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
+ CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
+{
+ CK_RV rv = CKR_OK;
+ kms_object_t *object_p;
+ kms_object_t *new_object = NULL;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+ int i;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if ((pTemplate == NULL) || (ulCount == 0))
+ return (CKR_ARGUMENTS_BAD);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Obtain the object pointer. */
+ HANDLE2OBJECT(hObject, object_p, rv);
+ if (rv != CKR_OK) {
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+
+ /* lock the object */
+ (void) pthread_mutex_lock(&object_p->object_mutex);
+
+ /*
+ * If the object was created in the HW provider, changing its
+ * attributes' values need to be done in the provider too.
+ */
+ if (!object_p->is_lib_obj) {
+
+ /* Cannot modify a token object with a READ-ONLY session */
+ if (session_p->ses_RO &&
+ (object_p->bool_attr_mask & TOKEN_BOOL_ON)) {
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+ rv = CKR_SESSION_READ_ONLY;
+ goto clean_exit;
+ }
+ }
+
+ /*
+ * if we come here, the object must have been created in the
+ * library. The work will be done completely in the library.
+ *
+ * Copy the old object to a new object. We work on the copied
+ * version because in case of error we still keep the old one
+ * intact.
+ */
+ rv = kms_copy_object(object_p, &new_object, B_FALSE, NULL);
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+ if ((rv != CKR_OK) || (new_object == NULL)) {
+ /*
+ * Most likely we ran out of space.
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ goto clean_exit;
+ }
+
+ for (i = 0; i < ulCount; i++) {
+ /* Set the requested attribute into the new object. */
+ rv = kms_set_attribute(new_object, &pTemplate[i], B_FALSE);
+
+ if (rv != CKR_OK) {
+ kms_cleanup_object(new_object);
+ goto clean_exit;
+ }
+ }
+
+ /*
+ * We've successfully set all the requested attributes.
+ * Merge the new object with the old object, then destory
+ * the new one. The reason to do the merging is because we
+ * have to keep the original object handle (address of object).
+ */
+ (void) pthread_mutex_lock(&object_p->object_mutex);
+ kms_merge_object(object_p, new_object);
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+
+clean_exit:
+ if (new_object != NULL)
+ (void) kms_free_object(new_object);
+
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ OBJ_REFRELE(object_p);
+ REFRELE(session_p, ses_lock_held);
+
+ return (rv);
+}
+
+CK_RV
+C_GetObjectSize(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
+ CK_ULONG_PTR pulSize)
+{
+
+ CK_RV rv = CKR_OK;
+ kms_object_t *object_p;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Check if pulSize is valid */
+ if (pulSize == NULL) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Obtain the object pointer. */
+ HANDLE2OBJECT(hObject, object_p, rv);
+ if (rv != CKR_OK) {
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+
+ /* Acquire the lock on the object. */
+ (void) pthread_mutex_lock(&object_p->object_mutex);
+
+ rv = kms_get_object_size(object_p, pulSize);
+
+ (void) pthread_mutex_unlock(&object_p->object_mutex);
+
+ /*
+ * Decrement the session reference count.
+ * We do not hold the session lock.
+ */
+ OBJ_REFRELE(object_p);
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
+
+CK_RV
+C_FindObjectsInit(CK_SESSION_HANDLE sh, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulCount)
+{
+ CK_RV rv;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Check the arguments */
+ if ((ulCount > 0) && (pTemplate == NULL)) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(sh, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Acquire the session lock */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ ses_lock_held = B_TRUE;
+
+ /* Check to see if find operation is already active */
+ if (session_p->find_objects.flags & CRYPTO_OPERATION_ACTIVE) {
+ /* decrement the session count, and unlock the mutex */
+ REFRELE(session_p, ses_lock_held);
+ return (CKR_OPERATION_ACTIVE);
+ } else {
+ /*
+ * This active flag will remain ON until application calls
+ * C_FindObjectsFinal.
+ */
+ session_p->find_objects.flags = CRYPTO_OPERATION_ACTIVE;
+ }
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ /*
+ * If the KMS provider supports object creation, we call the
+ * CRYPTO_OBJECT_FIND_INIT to initialize object finding.
+ * Otherwise, all the objects are created in the library and we
+ * do the find objects solely in the library.
+ */
+ rv = kms_find_objects_init(session_p, pTemplate, ulCount);
+ if (rv != CKR_OK) {
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ session_p->find_objects.flags = 0;
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ }
+ /* decrement the session count, and unlock the mutex */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
+
+CK_RV
+C_FindObjects(CK_SESSION_HANDLE sh, CK_OBJECT_HANDLE_PTR phObject,
+ CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount)
+{
+ CK_RV rv = CKR_OK;
+ kms_slot_t *pslot = NULL;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* check for invalid arguments */
+ if (((phObject == NULL) && (ulMaxObjectCount != 0)) ||
+ (pulObjectCount == NULL)) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ if (ulMaxObjectCount == 0) {
+ /* don't need to do anything, just return */
+ *pulObjectCount = 0;
+ return (CKR_OK);
+ }
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(sh, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Acquire the slot lock */
+ pslot = get_slotinfo();
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ /* Acquire the session lock */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ ses_lock_held = B_TRUE;
+
+ /* Check to see if find operation is active */
+ if (!(session_p->find_objects.flags & CRYPTO_OPERATION_ACTIVE)) {
+ rv = CKR_OPERATION_NOT_INITIALIZED;
+ goto clean_exit;
+ }
+
+ /*
+ * Similar to C_FindObjectInit(), if the KMS provider supports object
+ * creation, we need to find objects.
+ * Otherwise, all the objects are created in the library and we do
+ * the find objects solely in the library.
+ */
+
+ rv = kms_find_objects(session_p, phObject,
+ ulMaxObjectCount, pulObjectCount);
+
+clean_exit:
+ /* decrement the session count, and release the session lock */
+ REFRELE(session_p, ses_lock_held);
+
+ /* release the slot lock */
+ if (pslot)
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+
+ return (rv);
+}
+
+CK_RV
+C_FindObjectsFinal(CK_SESSION_HANDLE sh)
+{
+ kms_session_t *session_p;
+ CK_RV rv;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(sh, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Acquire the session lock */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ ses_lock_held = B_TRUE;
+
+ /* Check to see if find operation is active */
+ if (!(session_p->find_objects.flags & CRYPTO_OPERATION_ACTIVE)) {
+ REFRELE(session_p, ses_lock_held);
+ return (CKR_OPERATION_NOT_INITIALIZED);
+ }
+
+ /*
+ * Similar to C_FindObjectInit(), if the KMS provider supports object
+ * creation, we need to finalize the search on the KMS side.
+ */
+ kms_find_objects_final(session_p);
+
+ /* decrement the session count, and release the lock */
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.h b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.h
new file mode 100644
index 0000000000..afd5803854
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObject.h
@@ -0,0 +1,308 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _KMSOBJECT_H
+#define _KMSOBJECT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <security/pkcs11t.h>
+#include "kmsSession.h"
+#include "kmsSlot.h"
+
+#define KMSTOKEN_OBJECT_MAGIC 0xECF0B004
+
+#define KMS_CREATE_OBJ 1
+#define KMS_GEN_KEY 2
+
+/*
+ * Secret key Struct
+ */
+typedef struct secret_key_obj {
+ CK_BYTE *sk_value;
+ CK_ULONG sk_value_len;
+ void *key_sched;
+ size_t keysched_len;
+} secret_key_obj_t;
+
+/*
+ * This structure is used to hold the attributes in the
+ * Extra Attribute List.
+ */
+typedef struct attribute_info {
+ CK_ATTRIBUTE attr;
+ struct attribute_info *next;
+} attribute_info_t;
+
+typedef attribute_info_t *CK_ATTRIBUTE_INFO_PTR;
+
+/*
+ * This is the main structure of the Objects.
+ */
+typedef struct object {
+ boolean_t is_lib_obj; /* default is TRUE */
+
+ /* Generic common fields. Always present */
+ CK_OBJECT_CLASS class;
+ CK_KEY_TYPE key_type;
+ CK_ULONG magic_marker;
+ uint64_t bool_attr_mask;
+ CK_MECHANISM_TYPE mechanism;
+
+ /* Fields for access and arbitration */
+ pthread_mutex_t object_mutex;
+ struct object *next;
+ struct object *prev;
+
+ /* Extra non-boolean attribute list */
+ CK_ATTRIBUTE_INFO_PTR extra_attrlistp;
+ CK_ULONG extra_attrcount;
+
+ /* For each object, only one object class is presented */
+ union {
+ secret_key_obj_t *secret_key;
+ } object_class_u;
+
+ /* Session handle that the object belongs to */
+ CK_SESSION_HANDLE session_handle;
+ uint32_t obj_refcnt; /* object reference count */
+ pthread_cond_t obj_free_cond; /* cond variable for signal and wait */
+ uint32_t obj_delete_sync; /* object delete sync flags */
+} kms_object_t;
+
+typedef struct find_context {
+ kms_object_t **objs_found;
+ CK_ULONG num_results;
+ CK_ULONG next_result_index; /* next result object to return */
+} find_context_t;
+
+/*
+ * The following structure is used to link the to-be-freed session
+ * objects into a linked list. The objects on this linked list have
+ * not yet been freed via free() after C_DestroyObject() call; instead
+ * they are added to this list. The actual free will take place when
+ * the number of objects queued reaches MAX_OBJ_TO_BE_FREED, at which
+ * time the first object in the list will be freed.
+ */
+#define MAX_OBJ_TO_BE_FREED 300
+
+typedef struct obj_to_be_freed_list {
+ kms_object_t *first; /* points to first obj in the list */
+ kms_object_t *last; /* points to last obj in the list */
+ uint32_t count; /* current total objs in the list */
+ pthread_mutex_t obj_to_be_free_mutex;
+} object_to_be_freed_list_t;
+
+extern object_to_be_freed_list_t obj_delay_freed;
+
+/*
+ * The following definitions are the shortcuts
+ */
+
+/*
+ * Secret Key Object Attributes
+ */
+#define OBJ_SEC(o) \
+ ((o)->object_class_u.secret_key)
+#define OBJ_SEC_VALUE(o) \
+ ((o)->object_class_u.secret_key->sk_value)
+#define OBJ_SEC_VALUE_LEN(o) \
+ ((o)->object_class_u.secret_key->sk_value_len)
+#define OBJ_KEY_SCHED(o) \
+ ((o)->object_class_u.secret_key->key_sched)
+#define OBJ_KEY_SCHED_LEN(o) \
+ ((o)->object_class_u.secret_key->keysched_len)
+
+/*
+ * key related attributes with CK_BBOOL data type
+ */
+#define DERIVE_BOOL_ON 0x00000001
+#define LOCAL_BOOL_ON 0x00000002
+#define SENSITIVE_BOOL_ON 0x00000004
+#define SECONDARY_AUTH_BOOL_ON 0x00000008
+#define ENCRYPT_BOOL_ON 0x00000010
+#define DECRYPT_BOOL_ON 0x00000020
+#define SIGN_BOOL_ON 0x00000040
+#define SIGN_RECOVER_BOOL_ON 0x00000080
+#define VERIFY_BOOL_ON 0x00000100
+#define VERIFY_RECOVER_BOOL_ON 0x00000200
+#define WRAP_BOOL_ON 0x00000400
+#define UNWRAP_BOOL_ON 0x00000800
+#define TRUSTED_BOOL_ON 0x00001000
+#define EXTRACTABLE_BOOL_ON 0x00002000
+#define ALWAYS_SENSITIVE_BOOL_ON 0x00004000
+#define NEVER_EXTRACTABLE_BOOL_ON 0x00008000
+#define PRIVATE_BOOL_ON 0x00010000
+#define TOKEN_BOOL_ON 0x00020000
+#define MODIFIABLE_BOOL_ON 0x00040000
+
+#define SECRET_KEY_DEFAULT (ENCRYPT_BOOL_ON|\
+ DECRYPT_BOOL_ON|\
+ SIGN_BOOL_ON|\
+ VERIFY_BOOL_ON|\
+ WRAP_BOOL_ON|\
+ UNWRAP_BOOL_ON|\
+ EXTRACTABLE_BOOL_ON|\
+ MODIFIABLE_BOOL_ON)
+
+/*
+ * Flag definitions for obj_delete_sync
+ */
+#define OBJECT_IS_DELETING 1 /* Object is in a deleting state */
+#define OBJECT_REFCNT_WAITING 2 /* Waiting for object reference */
+ /* count to become zero */
+
+/*
+ * This macro is used to type cast an object handle to a pointer to
+ * the object struct. Also, it checks to see if the object struct
+ * is tagged with an object magic number. This is to detect when an
+ * application passes a bogus object pointer.
+ * Also, it checks to see if the object is in the deleting state that
+ * another thread is performing. If not, increment the object reference
+ * count by one. This is to prevent this object from being deleted by
+ * other thread.
+ */
+#define HANDLE2OBJECT_COMMON(hObject, object_p, rv, REFCNT_CODE) { \
+ object_p = (kms_object_t *)(hObject); \
+ if ((object_p == NULL) || \
+ (object_p->magic_marker != KMSTOKEN_OBJECT_MAGIC)) {\
+ rv = CKR_OBJECT_HANDLE_INVALID; \
+ } else { \
+ (void) pthread_mutex_lock(&object_p->object_mutex); \
+ if (!(object_p->obj_delete_sync & OBJECT_IS_DELETING)) { \
+ REFCNT_CODE; \
+ rv = CKR_OK; \
+ } else { \
+ rv = CKR_OBJECT_HANDLE_INVALID; \
+ } \
+ (void) pthread_mutex_unlock(&object_p->object_mutex); \
+ } \
+}
+
+#define HANDLE2OBJECT(hObject, object_p, rv) \
+ HANDLE2OBJECT_COMMON(hObject, object_p, rv, object_p->obj_refcnt++)
+
+#define HANDLE2OBJECT_DESTROY(hObject, object_p, rv) \
+ HANDLE2OBJECT_COMMON(hObject, object_p, rv, /* no refcnt increment */)
+
+
+#define OBJ_REFRELE(object_p) { \
+ (void) pthread_mutex_lock(&object_p->object_mutex); \
+ if ((--object_p->obj_refcnt) == 0 && \
+ (object_p->obj_delete_sync & OBJECT_REFCNT_WAITING)) { \
+ (void) pthread_cond_signal(&object_p->obj_free_cond); \
+ } \
+ (void) pthread_mutex_unlock(&object_p->object_mutex); \
+}
+
+
+/*
+ * Function Prototypes.
+ */
+void kms_cleanup_object(kms_object_t *objp);
+
+CK_RV kms_add_object(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
+ CK_ULONG *objecthandle_p, kms_session_t *sp);
+
+CK_RV kms_delete_object(kms_session_t *, kms_object_t *,
+ boolean_t, boolean_t);
+
+void kms_cleanup_extra_attr(kms_object_t *object_p);
+
+CK_RV kms_copy_extra_attr(CK_ATTRIBUTE_INFO_PTR old_attrp,
+ kms_object_t *object_p);
+
+void kms_cleanup_object_bigint_attrs(kms_object_t *object_p);
+
+CK_RV kms_build_object(CK_ATTRIBUTE_PTR, CK_ULONG, kms_object_t *);
+
+CK_RV kms_copy_object(kms_object_t *old_object,
+ kms_object_t **new_object, boolean_t copy_everything,
+ kms_session_t *sp);
+
+void kms_merge_object(kms_object_t *old_object,
+ kms_object_t *new_object);
+
+CK_RV kms_get_attribute(kms_object_t *object_p,
+ CK_ATTRIBUTE_PTR template);
+
+CK_RV kms_set_attribute(kms_object_t *, CK_ATTRIBUTE_PTR, boolean_t);
+
+void kms_add_object_to_session(kms_object_t *objp, kms_session_t *sp);
+
+CK_RV kms_copy_secret_key_attr(secret_key_obj_t *old_secret_key_obj_p,
+ secret_key_obj_t **new_secret_key_obj_p);
+
+CK_RV kms_validate_attr(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum,
+ CK_OBJECT_CLASS *class);
+
+CK_RV kms_find_objects_init(kms_session_t *sp,
+ CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount);
+
+void kms_find_objects_final(kms_session_t *sp);
+
+CK_RV kms_find_objects(kms_session_t *sp,
+ CK_OBJECT_HANDLE *obj_found, CK_ULONG max_obj_requested,
+ CK_ULONG *found_obj_count);
+
+void kms_process_find_attr(CK_OBJECT_CLASS *pclasses,
+ CK_ULONG *num_result_pclasses, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulCount);
+
+boolean_t kms_find_match_attrs(kms_object_t *obj,
+ CK_OBJECT_CLASS *pclasses, CK_ULONG num_pclasses,
+ CK_ATTRIBUTE *tmpl_attr, CK_ULONG num_attr);
+
+CK_ATTRIBUTE_PTR get_extra_attr(CK_ATTRIBUTE_TYPE type, kms_object_t *obj);
+
+CK_RV get_string_from_template(CK_ATTRIBUTE_PTR dest, CK_ATTRIBUTE_PTR src);
+
+void string_attr_cleanup(CK_ATTRIBUTE_PTR template);
+
+void kms_add_token_object_to_slot(kms_object_t *objp,
+ kms_slot_t *pslot);
+
+void kms_remove_token_object_from_slot(kms_slot_t *pslot,
+ kms_object_t *objp);
+
+CK_RV kms_delete_token_object(kms_slot_t *pslot, kms_session_t *sp,
+ kms_object_t *obj, boolean_t lock_held, boolean_t wrapper_only);
+
+void kms_cleanup_pri_objects_in_slot(kms_slot_t *pslot,
+ kms_session_t *sp);
+
+CK_RV kms_get_object_size(kms_object_t *objp, CK_ULONG_PTR pulSize);
+
+void kms_object_delay_free(kms_object_t *);
+
+kms_object_t *kms_new_object();
+void kms_free_object(kms_object_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _KMSOBJECT_H */
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObjectUtil.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObjectUtil.c
new file mode 100644
index 0000000000..64ddc11060
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsObjectUtil.c
@@ -0,0 +1,930 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <errno.h>
+#include <security/cryptoki.h>
+#include <cryptoutil.h>
+
+#include "kmsGlobal.h"
+#include "kmsObject.h"
+#include "kmsSession.h"
+#include "kmsSlot.h"
+#include "kmsKeystoreUtil.h"
+
+kms_object_t *
+kms_new_object()
+{
+ kms_object_t *obj;
+
+ obj = calloc(1, sizeof (kms_object_t));
+ if (obj == NULL)
+ return (NULL);
+
+ (void) pthread_cond_init(&obj->obj_free_cond, NULL);
+ (void) pthread_mutex_init(&obj->object_mutex, NULL);
+ obj->magic_marker = KMSTOKEN_OBJECT_MAGIC;
+
+ return (obj);
+}
+
+/*
+ * Add an object to the session's object list.
+ *
+ * This function will acquire the lock on the session, and release
+ * that lock after adding the object to the session's object list.
+ */
+void
+kms_add_object_to_session(kms_object_t *objp, kms_session_t *sp)
+{
+ /* Acquire the session lock. */
+ (void) pthread_mutex_lock(&sp->session_mutex);
+
+ /* Insert the new object in front of session's object list. */
+ if (sp->object_list == NULL) {
+ sp->object_list = objp;
+ objp->next = NULL;
+ objp->prev = NULL;
+ } else {
+ sp->object_list->prev = objp;
+ objp->next = sp->object_list;
+ objp->prev = NULL;
+ sp->object_list = objp;
+ }
+
+ /* Release the session lock. */
+ (void) pthread_mutex_unlock(&sp->session_mutex);
+}
+
+/*
+ * Clean up and release the storage allocated to the object.
+ *
+ * The function is called either with the object lock being held
+ * (by caller kms_delete_object()), or there is no object lock
+ * yet (by kms_build_XXX_object() during creating an object).
+ */
+void
+kms_cleanup_object(kms_object_t *objp)
+{
+ /*
+ * Free the storage allocated to a secret key object.
+ */
+ if (objp->class == CKO_SECRET_KEY) {
+ if (OBJ_SEC(objp) != NULL && OBJ_SEC_VALUE(objp) != NULL) {
+ bzero(OBJ_SEC_VALUE(objp), OBJ_SEC_VALUE_LEN(objp));
+ free(OBJ_SEC_VALUE(objp));
+ OBJ_SEC_VALUE(objp) = NULL;
+ OBJ_SEC_VALUE_LEN(objp) = 0;
+ }
+ if (OBJ_SEC(objp) != NULL)
+ free(OBJ_SEC(objp));
+
+ OBJ_SEC(objp) = NULL;
+ }
+
+ /*
+ * Free the storage allocated to the extra attribute list.
+ */
+ kms_cleanup_extra_attr(objp);
+}
+
+void
+kms_free_object(kms_object_t *obj)
+{
+ (void) pthread_cond_destroy(&obj->obj_free_cond);
+ (void) pthread_mutex_destroy(&obj->object_mutex);
+
+ kms_cleanup_object(obj);
+
+ free(obj);
+}
+
+/*
+ * Create a new object. Copy the attributes that can be modified
+ * (in the boolean attribute mask field and extra attribute list)
+ * from the old object to the new object.
+ *
+ * The caller of this function holds the lock on the old object.
+ */
+CK_RV
+kms_copy_object(kms_object_t *old_object, kms_object_t **new_object,
+ boolean_t copy_everything, kms_session_t *sp)
+{
+ CK_RV rv = CKR_OK;
+ kms_object_t *new_objp = NULL;
+ CK_ATTRIBUTE_INFO_PTR attrp;
+
+ /* Allocate new object. */
+ new_objp = kms_new_object();
+ if (new_objp == NULL)
+ return (CKR_HOST_MEMORY);
+
+ new_objp->class = old_object->class;
+ new_objp->bool_attr_mask = old_object->bool_attr_mask;
+
+ attrp = old_object->extra_attrlistp;
+ while (attrp) {
+ /*
+ * Copy the attribute_info struct from the old
+ * object to a new attribute_info struct, and add
+ * that new struct to the extra attribute list
+ * of the new object.
+ */
+ rv = kms_copy_extra_attr(attrp, new_objp);
+ if (rv != CKR_OK) {
+ kms_free_object(new_objp);
+ return (rv);
+ }
+ attrp = attrp->next;
+ }
+
+ *new_object = new_objp;
+
+ if (!copy_everything) {
+ /* done with copying all information that can be modified */
+ return (CKR_OK);
+ }
+
+ /*
+ * Copy the rest of the object.
+ * Certain fields that are not appropriate for coping will be
+ * initialized.
+ */
+ new_objp->key_type = old_object->key_type;
+ new_objp->magic_marker = old_object->magic_marker;
+ new_objp->mechanism = old_object->mechanism;
+ new_objp->session_handle = (CK_SESSION_HANDLE)sp;
+
+ /* copy key related information */
+ switch (new_objp->class) {
+ case CKO_SECRET_KEY:
+ rv = kms_copy_secret_key_attr(OBJ_SEC(old_object),
+ &(OBJ_SEC(new_objp)));
+ break;
+ default:
+ /* should never be this case */
+ break;
+ }
+ if (rv != CKR_OK) {
+ kms_free_object(new_objp);
+ *new_object = NULL;
+ }
+ return (rv);
+}
+
+/*
+ * Copy the attributes (in the boolean attribute mask field and
+ * extra attribute list) from the new object back to the original
+ * object. Also, clean up and release all the storage in the extra
+ * attribute list of the original object.
+ *
+ * The caller of this function holds the lock on the old object.
+ */
+void
+kms_merge_object(kms_object_t *old_object, kms_object_t *new_object)
+{
+ old_object->bool_attr_mask = new_object->bool_attr_mask;
+ kms_cleanup_extra_attr(old_object);
+ old_object->extra_attrlistp = new_object->extra_attrlistp;
+}
+
+/*
+ * Create a new object struct. If it is a session object, add the object to
+ * the session's object list. If it is a token object, add it to the slot's
+ * token object list. The caller does not hold the slot lock.
+ */
+CK_RV
+kms_add_object(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
+ CK_ULONG *objecthandle_p, kms_session_t *sp)
+{
+ CK_RV rv = CKR_OK;
+ kms_object_t *new_objp = NULL;
+ kms_slot_t *pslot;
+ CK_ATTRIBUTE pritmpl;
+ CK_BBOOL is_pri_obj, is_token_obj;
+
+ new_objp = kms_new_object();
+ if (new_objp == NULL)
+ return (CKR_HOST_MEMORY);
+
+ rv = kms_build_object(pTemplate, ulCount, new_objp);
+ if (rv != CKR_OK)
+ goto fail_cleanup;
+
+ /* Cannot create a token object with a READ-ONLY session */
+ pritmpl.type = CKA_TOKEN;
+ pritmpl.pValue = &is_token_obj;
+ pritmpl.ulValueLen = sizeof (is_token_obj);
+ rv = kms_get_attribute(new_objp, &pritmpl);
+ if (rv != CKR_OK)
+ goto fail_cleanup;
+
+ if (is_token_obj && sp->ses_RO) {
+ rv = CKR_SESSION_READ_ONLY;
+ goto fail_cleanup;
+ }
+
+ /*
+ * If the KMS supports object creation, create the object
+ * in the KMS. Otherwise, create the object in the library.
+ */
+
+ /* Get the CKA_PRIVATE value of this object. */
+ pritmpl.type = CKA_PRIVATE;
+ pritmpl.pValue = &is_pri_obj;
+ pritmpl.ulValueLen = sizeof (is_pri_obj);
+
+ rv = kms_get_attribute(new_objp, &pritmpl);
+ if (rv != CKR_OK) {
+ goto fail_cleanup;
+ }
+
+ /* Set the PRIVATE_BOOL_ON and TOKEN_BOOL_ON attributes */
+ if (is_pri_obj)
+ new_objp->bool_attr_mask |= PRIVATE_BOOL_ON;
+ else
+ new_objp->bool_attr_mask &= ~PRIVATE_BOOL_ON;
+
+ if (is_token_obj)
+ new_objp->bool_attr_mask |= TOKEN_BOOL_ON;
+ else
+ new_objp->bool_attr_mask &= ~TOKEN_BOOL_ON;
+
+ new_objp->session_handle = (CK_SESSION_HANDLE)sp;
+
+ if (is_token_obj) {
+ /* Add the new object to the slot's token object list. */
+ pslot = get_slotinfo();
+ kms_add_token_object_to_slot(new_objp, pslot);
+ } else {
+ /* Add the new object to the session's object list. */
+ kms_add_object_to_session(new_objp, sp);
+ }
+
+ /* Type casting the address of an object struct to an object handle. */
+ if (rv == CKR_OK)
+ *objecthandle_p = (CK_ULONG)new_objp;
+
+fail_cleanup:
+ if (rv != CKR_OK) {
+ kms_free_object(new_objp);
+ }
+ return (rv);
+}
+
+/*
+ * Remove an object from the session's object list.
+ *
+ * The caller of this function holds the session lock.
+ */
+CK_RV
+kms_remove_object_from_session(kms_object_t *objp, kms_session_t *sp)
+{
+ kms_object_t *tmp_objp;
+ boolean_t found = B_FALSE;
+
+ /*
+ * Remove the object from the session's object list.
+ */
+ if ((sp == NULL) ||
+ (sp->magic_marker != KMSTOKEN_SESSION_MAGIC)) {
+ return (CKR_SESSION_HANDLE_INVALID);
+ }
+
+ if ((sp->object_list == NULL) || (objp == NULL) ||
+ (objp->magic_marker != KMSTOKEN_OBJECT_MAGIC)) {
+ return (CKR_OBJECT_HANDLE_INVALID);
+ }
+
+ tmp_objp = sp->object_list;
+ while (tmp_objp) {
+ if (tmp_objp == objp) {
+ found = B_TRUE;
+ break;
+ }
+ tmp_objp = tmp_objp->next;
+ }
+ if (!found)
+ return (CKR_OBJECT_HANDLE_INVALID);
+
+ if (sp->object_list == objp) {
+ /* Object is the first one in the list. */
+ if (objp->next) {
+ sp->object_list = objp->next;
+ objp->next->prev = NULL;
+ } else {
+ /* Object is the only one in the list. */
+ sp->object_list = NULL;
+ }
+ } else {
+ /* Object is not the first one in the list. */
+ if (objp->next) {
+ /* Object is in the middle of the list. */
+ objp->prev->next = objp->next;
+ objp->next->prev = objp->prev;
+ } else {
+ /* Object is the last one in the list. */
+ objp->prev->next = NULL;
+ }
+ }
+ return (CKR_OK);
+}
+
+/*
+ * This function adds the to-be-freed session object to a linked list.
+ * When the number of objects queued in the linked list reaches the
+ * maximum threshold MAX_OBJ_TO_BE_FREED, it will free the first
+ * object (FIFO) in the list.
+ */
+void
+kms_object_delay_free(kms_object_t *objp)
+{
+ kms_object_t *tmp;
+
+ (void) pthread_mutex_lock(&obj_delay_freed.obj_to_be_free_mutex);
+
+ /* Add the newly deleted object at the end of the list */
+ objp->next = NULL;
+ if (obj_delay_freed.first == NULL) {
+ obj_delay_freed.last = objp;
+ obj_delay_freed.first = objp;
+ } else {
+ obj_delay_freed.last->next = objp;
+ obj_delay_freed.last = objp;
+ }
+
+ if (++obj_delay_freed.count >= MAX_OBJ_TO_BE_FREED) {
+ /*
+ * Free the first object in the list only if
+ * the total count reaches maximum threshold.
+ */
+ obj_delay_freed.count--;
+ tmp = obj_delay_freed.first->next;
+ kms_free_object(obj_delay_freed.first);
+ obj_delay_freed.first = tmp;
+ }
+ (void) pthread_mutex_unlock(&obj_delay_freed.obj_to_be_free_mutex);
+}
+
+static void
+kms_delete_object_cleanup(kms_object_t *objp, boolean_t force)
+{
+ /* Acquire the lock on the object. */
+ (void) pthread_mutex_lock(&objp->object_mutex);
+
+ /*
+ * Make sure another thread hasn't freed the object.
+ */
+ if (objp->magic_marker != KMSTOKEN_OBJECT_MAGIC) {
+ (void) pthread_mutex_unlock(&objp->object_mutex);
+ return;
+ }
+
+ /*
+ * The deletion of an object must be blocked when the object
+ * reference count is not zero. This means if any object related
+ * operation starts prior to the delete object operation gets in,
+ * the object deleting thread must wait for the non-deleting
+ * operation to be completed before it can proceed the delete
+ * operation.
+ *
+ * Unless we are being forced to shut everything down, this only
+ * happens if the library's _fini() is running not if someone
+ * explicitly called C_Finalize().
+ */
+ if (force) {
+ objp->obj_refcnt = 0;
+ }
+
+ while (objp->obj_refcnt != 0) {
+ /*
+ * We set the OBJECT_REFCNT_WAITING flag before we put
+ * this deleting thread in a wait state, so other non-deleting
+ * operation thread will signal to wake it up only when
+ * the object reference count becomes zero and this flag
+ * is set.
+ */
+ objp->obj_delete_sync |= OBJECT_REFCNT_WAITING;
+ (void) pthread_cond_wait(&objp->obj_free_cond,
+ &objp->object_mutex);
+ }
+
+ objp->obj_delete_sync &= ~OBJECT_REFCNT_WAITING;
+
+ /* Mark object as no longer valid. */
+ objp->magic_marker = 0;
+ kms_cleanup_object(objp);
+
+ objp->obj_delete_sync &= ~OBJECT_IS_DELETING;
+ (void) pthread_mutex_unlock(&objp->object_mutex);
+
+ if (objp->bool_attr_mask & TOKEN_BOOL_ON)
+ free(objp);
+ else
+ kms_object_delay_free(objp);
+}
+
+/*
+ * Delete a session object:
+ * - Remove the object from the session's object list.
+ * - Release the storage allocated to the object.
+ *
+ * The boolean argument ses_lock_held is used to indicate that whether
+ * the caller holds the session lock or not.
+ * - When called by kms_delete_all_objects_in_session() or
+ * kms_delete_pri_objects_in_slot() -- ses_lock_held = TRUE.
+ *
+ * The boolean argument wrapper_only is used to indicate that whether
+ * the caller only wants to clean up the object wrapper from the library and
+ * needs not to make an call to KMS.
+ * - This argument only applies to the object created in the provider level.
+ * - When called by kms_cleanup_pri_objects_in_slot(), wrapper_only is TRUE.
+ * - When called by C_DestroyObject(), wrapper_only is FALSE.
+ * - When called by kms_delete_all_objects_in_session(), the value of
+ * wrapper_only depends on its caller.
+ */
+CK_RV
+kms_delete_object(kms_session_t *sp, kms_object_t *objp,
+ boolean_t ses_lock_held, boolean_t wrapper_only)
+{
+ CK_RV rv = CKR_OK;
+
+ /*
+ * Check to see if the caller holds the lock on the session.
+ * If not, we need to acquire that lock in order to proceed.
+ */
+ if (!ses_lock_held) {
+ /* Acquire the session lock. */
+ (void) pthread_mutex_lock(&sp->session_mutex);
+ }
+
+ /* Remove the object from the session's object list first. */
+ if ((rv = kms_remove_object_from_session(objp, sp))) {
+ if (!ses_lock_held)
+ (void) pthread_mutex_unlock(&sp->session_mutex);
+ return (rv);
+ }
+
+ if (!wrapper_only)
+ (void) pthread_mutex_unlock(&sp->session_mutex);
+
+ kms_delete_object_cleanup(objp, wrapper_only);
+
+ return (rv);
+}
+
+/*
+ * Delete all the objects in a session. The caller holds the lock
+ * on the session. If the wrapper_only argument is TRUE, the caller only
+ * want to clean up object wrappers in the library.
+ */
+void
+kms_delete_all_objects_in_session(kms_session_t *sp,
+ boolean_t wrapper_only)
+{
+ kms_object_t *objp = sp->object_list;
+ kms_object_t *objp1;
+
+ /* Delete all the objects in the session. */
+ while (objp) {
+ objp1 = objp->next;
+ (void) kms_delete_object(sp, objp, B_TRUE,
+ wrapper_only);
+
+ objp = objp1;
+ }
+}
+
+static CK_RV
+add_to_search_result(kms_object_t *obj, find_context_t *fcontext,
+ CK_ULONG *num_result_alloc)
+{
+ /*
+ * allocate space for storing results if the currently
+ * allocated space is not enough
+ */
+ if (*num_result_alloc <= fcontext->num_results) {
+ fcontext->objs_found = realloc(fcontext->objs_found,
+ sizeof (kms_object_t *) * (*num_result_alloc + BUFSIZ));
+ if (fcontext->objs_found == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+ *num_result_alloc += BUFSIZ;
+ }
+
+ (fcontext->objs_found)[(fcontext->num_results)++] = obj;
+ return (CKR_OK);
+}
+
+static CK_RV
+search_for_objects(kms_session_t *sp, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulCount, find_context_t *fcontext)
+{
+ kms_session_t *session_p;
+ kms_object_t *obj;
+ CK_OBJECT_CLASS pclasses[6]; /* classes attrs possibly exist */
+ CK_ULONG num_pclasses; /* number of possible classes */
+ CK_ULONG num_result_alloc = 0; /* spaces allocated for results */
+ CK_RV rv = CKR_OK;
+ kms_slot_t *pslot = NULL;
+ boolean_t token_specified = B_FALSE;
+ boolean_t token_flag_val = B_FALSE;
+ int i;
+
+ if (ulCount > 0) {
+ /* there are some search requirement */
+ kms_process_find_attr(pclasses, &num_pclasses,
+ pTemplate, ulCount);
+ }
+
+ /*
+ * look through template and see if it explicitly specifies
+ * whether we need to look for token objects or not
+ */
+ for (i = 0; i < ulCount; i++) {
+ if (pTemplate[i].type == CKA_TOKEN) {
+ token_specified = B_TRUE;
+ token_flag_val = *((CK_BBOOL *)pTemplate[i].pValue);
+ break;
+ }
+ }
+
+ pslot = get_slotinfo();
+
+ /* Acquire the slot lock */
+ if (token_flag_val || !token_specified) {
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ /*
+ * Make sure the object list is current.
+ */
+ rv = KMS_RefreshObjectList(sp, pslot);
+ if (rv != CKR_OK) {
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (rv);
+ }
+
+ obj = pslot->sl_tobj_list;
+ while (obj) {
+ (void) pthread_mutex_lock(&obj->object_mutex);
+ if (((token_specified) && (ulCount > 1)) ||
+ ((!token_specified) && (ulCount > 0))) {
+ if (kms_find_match_attrs(obj, pclasses,
+ num_pclasses, pTemplate, ulCount)) {
+ rv = add_to_search_result(
+ obj, fcontext, &num_result_alloc);
+ }
+ } else {
+ /* no search criteria, just record the object */
+ rv = add_to_search_result(obj, fcontext,
+ &num_result_alloc);
+ }
+ (void) pthread_mutex_unlock(&obj->object_mutex);
+ if (rv != CKR_OK) {
+ goto cleanup;
+ }
+ obj = obj->next;
+ }
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ }
+
+ if (token_flag_val) {
+ return (rv);
+ }
+
+ /*
+ * Go through all objects in each session.
+ * Acquire individual session lock for the session
+ * we are searching.
+ */
+ session_p = pslot->sl_sess_list;
+ while (session_p) {
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ obj = session_p->object_list;
+ while (obj) {
+ (void) pthread_mutex_lock(&obj->object_mutex);
+ if (ulCount > 0) {
+ if (kms_find_match_attrs(obj, pclasses,
+ num_pclasses, pTemplate, ulCount)) {
+ rv = add_to_search_result(
+ obj, fcontext, &num_result_alloc);
+ }
+ } else {
+ /* no search criteria, just record the object */
+ rv = add_to_search_result(obj, fcontext,
+ &num_result_alloc);
+ }
+ (void) pthread_mutex_unlock(&obj->object_mutex);
+ if (rv != CKR_OK) {
+ (void) pthread_mutex_unlock(
+ &session_p->session_mutex);
+ goto cleanup;
+ }
+ obj = obj->next;
+ }
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ session_p = session_p->next;
+ }
+
+cleanup:
+ /* Release the slot lock */
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (rv);
+}
+
+/*
+ * Initialize the context for C_FindObjects() calls
+ */
+CK_RV
+kms_find_objects_init(kms_session_t *sp, CK_ATTRIBUTE_PTR pTemplate,
+ CK_ULONG ulCount)
+{
+ CK_RV rv = CKR_OK;
+ CK_OBJECT_CLASS class; /* for kms_validate_attr(). Value unused */
+ find_context_t *fcontext;
+
+ if (ulCount) {
+ rv = kms_validate_attr(pTemplate, ulCount, &class);
+ /* Make sure all attributes in template are valid */
+ if (rv != CKR_OK) {
+ return (rv);
+ }
+ }
+
+ /* prepare the find context */
+ fcontext = calloc(1, sizeof (find_context_t));
+ if (fcontext == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+
+ rv = search_for_objects(sp, pTemplate, ulCount, fcontext);
+ if (rv != CKR_OK) {
+ free(fcontext);
+ return (rv);
+ }
+
+ /* store the find_context in the session */
+ sp->find_objects.context = (CK_VOID_PTR)fcontext;
+
+ return (rv);
+}
+
+void
+kms_find_objects_final(kms_session_t *sp)
+{
+ find_context_t *fcontext;
+
+ fcontext = sp->find_objects.context;
+ sp->find_objects.context = NULL;
+ sp->find_objects.flags = 0;
+ if (fcontext->objs_found != NULL) {
+ free(fcontext->objs_found);
+ }
+
+ free(fcontext);
+}
+
+CK_RV
+kms_find_objects(kms_session_t *sp, CK_OBJECT_HANDLE *obj_found,
+ CK_ULONG max_obj_requested, CK_ULONG *found_obj_count)
+{
+ find_context_t *fcontext;
+ CK_ULONG num_obj_found = 0;
+ CK_ULONG i;
+ kms_object_t *obj;
+
+ fcontext = sp->find_objects.context;
+
+ for (i = fcontext->next_result_index;
+ ((num_obj_found < max_obj_requested) &&
+ (i < fcontext->num_results));
+ i++) {
+ obj = fcontext->objs_found[i];
+ if (obj != NULL) {
+ (void) pthread_mutex_lock(&obj->object_mutex);
+ /* a sanity check to make sure the obj is still valid */
+ if (obj->magic_marker == KMSTOKEN_OBJECT_MAGIC) {
+ obj_found[num_obj_found] =
+ (CK_OBJECT_HANDLE)obj;
+ num_obj_found++;
+ }
+ (void) pthread_mutex_unlock(&obj->object_mutex);
+ }
+ }
+ fcontext->next_result_index = i;
+ *found_obj_count = num_obj_found;
+ return (CKR_OK);
+}
+
+/*
+ * Add an token object to the token object list in slot.
+ *
+ * This function will acquire the lock on the slot, and release
+ * that lock after adding the object to the slot's token object list.
+ */
+void
+kms_add_token_object_to_slot(kms_object_t *objp, kms_slot_t *pslot)
+{
+ /* Acquire the slot lock. */
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ /* Insert the new object in front of slot's token object list. */
+ if (pslot->sl_tobj_list == NULL) {
+ pslot->sl_tobj_list = objp;
+ objp->next = NULL;
+ objp->prev = NULL;
+ } else {
+ pslot->sl_tobj_list->prev = objp;
+ objp->next = pslot->sl_tobj_list;
+ objp->prev = NULL;
+ pslot->sl_tobj_list = objp;
+ }
+
+ /* Release the slot lock. */
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+}
+
+/*
+ * Remove an token object from the slot's token object list.
+ * This routine is called by kms_delete_token_object().
+ * The caller of this function hold the slot lock.
+ */
+void
+kms_remove_token_object_from_slot(kms_slot_t *pslot,
+ kms_object_t *objp)
+{
+
+ if (pslot->sl_tobj_list == objp) {
+ /* Object is the first one in the list */
+ if (objp->next) {
+ pslot->sl_tobj_list = objp->next;
+ objp->next->prev = NULL;
+ } else {
+ /* Object is the only one in the list. */
+ pslot->sl_tobj_list = NULL;
+ }
+ } else {
+ /* Object is not the first one in the list. */
+ if (objp->next) {
+ /* Object is in the middle of the list. */
+ if (objp->prev)
+ objp->prev->next = objp->next;
+ objp->next->prev = objp->prev;
+ } else if (objp->prev) {
+ /* Object is the last one in the list. */
+ objp->prev->next = NULL;
+ }
+ }
+}
+
+/*
+ * Delete a token object:
+ * - Remove the object from the slot's token object list.
+ * - Release the storage allocated to the object.
+ *
+ * The boolean argument slot_lock_held is used to indicate that whether
+ * the caller holds the slot lock or not. When the caller does not hold
+ * the slot lock, this function will acquire that lock in order to proceed,
+ * and also release that lock before returning to caller.
+ *
+ * The boolean argument wrapper_only is used to indicate that whether
+ * the caller only wants to the object wrapper from library.
+ */
+CK_RV
+kms_delete_token_object(kms_slot_t *pslot, kms_session_t *sp,
+ kms_object_t *objp, boolean_t slot_lock_held, boolean_t wrapper_only)
+{
+ CK_RV rv = CKR_OK;
+
+ if (!slot_lock_held) {
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ }
+ if (!wrapper_only && objp->class == CKO_SECRET_KEY) {
+ /* Delete from KMS */
+ rv = KMS_DestroyKey(sp, objp);
+ }
+
+ /* Remove the object from the slot's token object list first. */
+ kms_remove_token_object_from_slot(pslot, objp);
+
+ /* Release the slot lock if the call doesn't hold the lock. */
+ if (!slot_lock_held) {
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ }
+
+ kms_delete_object_cleanup(objp, wrapper_only);
+
+ return (rv);
+}
+
+/*
+ * Clean up private object wrappers in this slot. The caller holds the slot
+ * lock.
+ */
+void
+kms_cleanup_pri_objects_in_slot(kms_slot_t *pslot,
+ kms_session_t *cur_sp)
+{
+ kms_session_t *session_p;
+ kms_object_t *objp;
+ kms_object_t *objp1;
+
+ /*
+ * Delete every private token object from
+ * the slot token object list.
+ */
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ objp = pslot->sl_tobj_list;
+ while (objp) {
+ objp1 = objp->next;
+ /*
+ * The first TRUE boolean argument indicates that the caller
+ * hold the slot lock. The second TRUE boolean argument
+ * indicates that the caller just wants to clean up the object
+ * wrapper from the library only.
+ */
+ if (objp->bool_attr_mask & PRIVATE_BOOL_ON) {
+ (void) kms_delete_token_object(pslot, cur_sp, objp,
+ B_TRUE, B_TRUE);
+ }
+ objp = objp1;
+ }
+
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ /*
+ * Walk through all the sessions in this slot and delete every
+ * private object.
+ */
+ session_p = pslot->sl_sess_list;
+ while (session_p) {
+
+ /* Delete all the objects in the session. */
+ objp = session_p->object_list;
+ while (objp) {
+ objp1 = objp->next;
+ /*
+ * The FALSE boolean argument indicates that the
+ * caller does not hold the session lock. The TRUE
+ * boolean argument indicates that the caller just
+ * want to clean upt the object wrapper from the
+ * library only.
+ */
+ if (objp->bool_attr_mask & PRIVATE_BOOL_ON) {
+ (void) kms_delete_object(session_p,
+ objp, B_FALSE, B_TRUE);
+ }
+ objp = objp1;
+ }
+
+ session_p = session_p->next;
+ }
+}
+
+/*
+ * Get the object size in bytes for the objects created in the library.
+ */
+CK_RV
+kms_get_object_size(kms_object_t *obj, CK_ULONG_PTR pulSize)
+{
+ CK_RV rv = CKR_OK;
+ CK_ULONG obj_size;
+
+ obj_size = sizeof (kms_object_t);
+
+ switch (obj->class) {
+ case CKO_SECRET_KEY:
+ obj_size += OBJ_SEC_VALUE_LEN(obj);
+ break;
+
+ default:
+ rv = CKR_OBJECT_HANDLE_INVALID;
+ }
+
+ if (rv == CKR_OK) {
+ *pulSize = obj_size;
+ }
+
+ return (rv);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsRand.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsRand.c
new file mode 100644
index 0000000000..088c09c204
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsRand.c
@@ -0,0 +1,48 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+
+/*ARGSUSED*/
+CK_RV
+C_SeedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed, CK_ULONG ulSeedLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_GenerateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pRandomData,
+ CK_ULONG ulRandomLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.c
new file mode 100644
index 0000000000..bdde865b56
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.c
@@ -0,0 +1,355 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <pthread.h>
+#include <errno.h>
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+#include "kmsSession.h"
+#include "kmsSlot.h"
+#include "kmsKeystoreUtil.h"
+
+CK_RV
+C_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication,
+ CK_NOTIFY Notify, CK_SESSION_HANDLE_PTR phSession)
+{
+ CK_RV rv = CKR_OK;
+ kms_slot_t *pslot;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (!(flags & CKF_SERIAL_SESSION))
+ return (CKR_SESSION_PARALLEL_NOT_SUPPORTED);
+
+ if (phSession == NULL)
+ return (CKR_ARGUMENTS_BAD);
+
+ if (slotID != KMS_TOKEN_SLOTID) {
+ return (CKR_SLOT_ID_INVALID);
+ }
+
+ /*
+ * Acquire the slot lock to protect sl_state and sl_sess_list.
+ * These two fields need to be protected atomically, even though
+ * "sl_sess_list" is updated in kms_add_session().
+ */
+ pslot = get_slotinfo();
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ /* If SO is logged in the slot, only the RW session is allowed. */
+ if ((pslot->sl_state == CKU_SO) && !(flags & CKF_RW_SESSION)) {
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (CKR_SESSION_READ_WRITE_SO_EXISTS);
+ }
+
+ /* Create a new session */
+ rv = kms_add_session(slotID, flags, pApplication, Notify,
+ phSession);
+
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (rv);
+}
+
+CK_RV
+C_CloseSession(CK_SESSION_HANDLE hSession)
+{
+ CK_RV rv;
+
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ ses_lock_held = B_TRUE;
+
+ /*
+ * Set SESSION_IS_CLOSING flag so any access to this
+ * session will be rejected.
+ */
+ if (session_p->ses_close_sync & SESSION_IS_CLOSING) {
+ REFRELE(session_p, ses_lock_held);
+ return (CKR_SESSION_CLOSED);
+ }
+ session_p->ses_close_sync |= SESSION_IS_CLOSING;
+
+ /*
+ * Decrement the session reference count.
+ * We hold the session lock, and REFRELE()
+ * will release the session lock for us.
+ */
+ REFRELE(session_p, ses_lock_held);
+
+ /*
+ * Delete a session by calling kms_delete_session() with
+ * a session pointer and two boolean arguments. The 3rd argument
+ * boolean value FALSE indicates that the caller does not
+ * hold the slot lock. The 4th argument boolean value B_FALSE
+ * indicates that we want to delete all the objects completely.
+ *
+ * kms_delete_session() will reset SESSION_IS_CLOSING
+ * flag after it is done.
+ */
+ kms_delete_session(session_p, B_FALSE, B_FALSE);
+ return (rv);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_CloseAllSessions(CK_SLOT_ID slotID)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /* Delete all the sessions and release the allocated resources */
+ kms_delete_all_sessions(B_FALSE);
+
+ return (CKR_OK);
+}
+
+/*
+ * Utility routine to get CK_STATE value for a session.
+ * The caller should not be holding the session lock.
+ */
+static CK_STATE
+get_ses_state(kms_session_t *session_p)
+{
+ CK_STATE state;
+ kms_slot_t *pslot;
+
+ pslot = get_slotinfo();
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ if (pslot->sl_state == CKU_PUBLIC) {
+ state = (session_p->ses_RO) ?
+ CKS_RO_PUBLIC_SESSION : CKS_RW_PUBLIC_SESSION;
+ } else if (pslot->sl_state == CKU_USER) {
+ state = (session_p->ses_RO) ?
+ CKS_RO_USER_FUNCTIONS : CKS_RW_USER_FUNCTIONS;
+ } else if (pslot->sl_state == CKU_SO) {
+ state = CKS_RW_SO_FUNCTIONS;
+ }
+
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+
+ return (state);
+}
+
+CK_RV
+C_GetSessionInfo(CK_SESSION_HANDLE hSession, CK_SESSION_INFO_PTR pInfo)
+{
+ kms_session_t *session_p;
+ CK_RV rv;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (pInfo == NULL)
+ return (CKR_ARGUMENTS_BAD);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Provide information for the specified session */
+ pInfo->slotID = session_p->ses_slotid;
+ pInfo->flags = session_p->flags;
+ pInfo->ulDeviceError = 0;
+ pInfo->state = get_ses_state(session_p);
+
+ /*
+ * Decrement the session reference count.
+ */
+ REFRELE(session_p, ses_lock_held);
+
+ return (rv);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_GetOperationState(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pOperationState,
+ CK_ULONG_PTR pulOperationStateLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_SetOperationState(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pOperationState,
+ CK_ULONG ulOperationStateLen, CK_OBJECT_HANDLE hEncryptionKey,
+ CK_OBJECT_HANDLE hAuthenticationKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+CK_RV
+C_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType,
+ CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen)
+{
+ CK_RV rv = CKR_OK;
+ kms_session_t *session_p;
+ kms_slot_t *pslot;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if ((userType != CKU_SO) && (userType != CKU_USER)) {
+ return (CKR_USER_TYPE_INVALID);
+ }
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Acquire the slot lock */
+ pslot = get_slotinfo();
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ /* Check if the slot is logged in already */
+ if ((pslot->sl_state == CKU_USER) || (pslot->sl_state == CKU_SO)) {
+ rv = CKR_USER_ALREADY_LOGGED_IN;
+ goto clean_exit;
+ }
+
+ /* To login as SO, every session in this slot needs to be R/W */
+ if (userType == CKU_SO) {
+ kms_session_t *sp;
+ boolean_t found;
+
+ found = B_FALSE;
+ sp = pslot->sl_sess_list;
+ while (sp) {
+ /*
+ * Need not to lock individual sessions before
+ * accessing their "ses_RO" and "next" fields,
+ * because they are always accessed under the
+ * slot's mutex protection.
+ */
+ if (sp->ses_RO) {
+ found = B_TRUE;
+ break;
+ }
+ sp = sp->next;
+ }
+
+ if (found) {
+ rv = CKR_SESSION_READ_ONLY_EXISTS;
+ goto clean_exit;
+ }
+ }
+
+ /*
+ * Login to KMS by attempting to load the profile using
+ * the given password.
+ */
+ rv = KMS_LoadProfile(
+ &session_p->kmsProfile,
+ &session_p->configInfo,
+ (const char *)pPin,
+ (size_t)ulPinLen);
+
+ if (rv == CKR_OK) {
+ /* Set the slot's session state. */
+ pslot->sl_state = userType;
+ }
+
+clean_exit:
+
+ REFRELE(session_p, ses_lock_held);
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (rv);
+}
+
+CK_RV
+C_Logout(CK_SESSION_HANDLE hSession)
+{
+ CK_RV rv = CKR_OK;
+ kms_session_t *session_p;
+ kms_slot_t *pslot;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Acquire the slot lock. */
+ pslot = get_slotinfo();
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ /* Check if the user or SO was logged in */
+ if (pslot->sl_state == CKU_PUBLIC) {
+ rv = CKR_USER_NOT_LOGGED_IN;
+ goto clean_exit;
+ }
+
+ KMS_UnloadProfile(&session_p->kmsProfile);
+
+ /*
+ * If this slot was logged in as USER previously, we need to clean up
+ * all private object wrappers in library for this slot.
+ */
+ kms_cleanup_pri_objects_in_slot(pslot, session_p);
+
+ if (rv == CKR_OK) {
+ /* Reset the slot's session state. */
+ pslot->sl_state = CKU_PUBLIC;
+ }
+
+clean_exit:
+ REFRELE(session_p, ses_lock_held);
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ return (rv);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.h b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.h
new file mode 100644
index 0000000000..3f8db9d250
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSession.h
@@ -0,0 +1,188 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _KMSSESSION_H
+#define _KMSSESSION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <pthread.h>
+#include <sys/avl.h>
+#include <security/pkcs11t.h>
+
+#define K_SOLARIS_PLATFORM
+#include "KMSAgent.h"
+
+#define KMSTOKEN_SESSION_MAGIC 0xECF00004
+
+#define CRYPTO_OPERATION_ACTIVE 0x01
+#define CRYPTO_OPERATION_UPDATE 0x02
+
+typedef struct {
+ CK_MECHANISM mech;
+ void *context;
+ uint32_t flags;
+} kms_active_op_t;
+
+typedef struct {
+ char *label;
+ avl_node_t nodep;
+} objlabel_t;
+
+#define KMSOFFSETOF(s, m) ((size_t)(&(((s *)0)->m)))
+
+/*
+ * Data stored in the KMS profile config file.
+ */
+typedef struct {
+ char name[BUFSIZ];
+ char agentId[BUFSIZ];
+ char agentAddr[BUFSIZ];
+ int transTimeout;
+ int failoverLimit;
+ int discoveryFreq;
+ int securityMode;
+} kms_cfg_info_t;
+
+typedef struct session {
+ CK_ULONG magic_marker; /* magic # be validated for integrity */
+ pthread_mutex_t session_mutex; /* session's mutex lock */
+ pthread_mutex_t ses_free_mutex; /* mutex used during closing session */
+ pthread_cond_t ses_free_cond; /* cond variable for signal and wait */
+ uint32_t ses_refcnt; /* session reference count */
+ uint32_t ses_close_sync; /* session closing flags */
+ boolean_t ses_RO; /* RO or RW session flag */
+ CK_SLOT_ID ses_slotid; /* slotID saved from C_OpenSession() */
+
+ /* Place holder for parameters passed in the C_OpenSession */
+ CK_FLAGS flags;
+ CK_NOTIFY Notify;
+ CK_VOID_PTR pApplication;
+
+ /* Pointers to form the global session list */
+ struct session *next; /* points to next session on the list */
+ struct session *prev; /* points to prev session on the list */
+
+ struct object *object_list; /* points to list of objects */
+
+ kms_active_op_t find_objects;
+ kms_active_op_t encrypt;
+ kms_active_op_t decrypt;
+
+ kms_cfg_info_t configInfo;
+
+ avl_tree_t objlabel_tree;
+ KMSClientProfile kmsProfile;
+} kms_session_t;
+
+/*
+ * The following structure is used to link the to-be-freed sessions
+ * into a linked list. The sessions on this linked list have
+ * not yet been freed via free() after C_CloseSession() call; instead
+ * they are added to this list. The actual free will take place when
+ * the number of sessions queued reaches MAX_SES_TO_BE_FREED, at which
+ * time the first session in the list will be freed.
+ */
+#define MAX_SES_TO_BE_FREED 300
+
+typedef struct ses_to_be_freed_list {
+ kms_session_t *first; /* points to the first session in the list */
+ kms_session_t *last; /* points to the last session in the list */
+ uint32_t count; /* current total sessions in the list */
+ pthread_mutex_t ses_to_be_free_mutex;
+} ses_to_be_freed_list_t;
+
+extern ses_to_be_freed_list_t ses_delay_freed;
+extern CK_ULONG kms_session_cnt;
+extern CK_ULONG kms_session_rw_cnt;
+
+/*
+ * Flag definitions for ses_close_sync
+ */
+#define SESSION_IS_CLOSING 1 /* Session is in a closing state */
+#define SESSION_REFCNT_WAITING 2 /* Waiting for session reference */
+ /* count to become zero */
+/*
+ * This macro is used to decrement the session reference count by one.
+ *
+ * The caller of this macro uses the argument lock_held to indicate that
+ * whether the caller holds the lock on the session or not.
+ *
+ * REFRELE macro does the following:
+ * 1) Get the session lock if the caller does not hold it.
+ * 2) Decrement the session reference count by one.
+ * 3) If the session reference count becomes zero after being decremented,
+ * and there is a closing session thread in the wait state, then
+ * call pthread_cond_signal() to wake up that thread who is blocked
+ * in the session deletion routine due to non-zero reference ount.
+ * 4) Always release the session lock.
+ */
+#define REFRELE(s, ses_lock_held) { \
+ if (!ses_lock_held) \
+ (void) pthread_mutex_lock(&s->session_mutex); \
+ if ((--((s)->ses_refcnt) == 0) && \
+ (s->ses_close_sync & SESSION_REFCNT_WAITING)) { \
+ (void) pthread_mutex_unlock(&s->session_mutex); \
+ (void) pthread_cond_signal(&s->ses_free_cond); \
+ } else { \
+ (void) pthread_mutex_unlock(&s->session_mutex); \
+ } \
+}
+
+
+/*
+ * Function Prototypes.
+ */
+CK_RV
+handle2session(CK_SESSION_HANDLE hSession, kms_session_t **session_p);
+
+void
+kms_delete_all_sessions(boolean_t wrapper_only);
+
+void
+kms_delete_all_objects_in_session(kms_session_t *sp,
+ boolean_t wrapper_only);
+
+CK_RV
+kms_add_session(CK_SLOT_ID slotID, CK_FLAGS flags,
+ CK_VOID_PTR pApplication, CK_NOTIFY notify, CK_ULONG *phSession);
+
+void
+kms_delete_session(kms_session_t *sp,
+ boolean_t lock_held, boolean_t wrapper_only);
+
+void
+kms_session_delay_free(kms_session_t *sp);
+
+void kms_acquire_all_slots_mutexes();
+void kms_release_all_slots_mutexes();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _KMSSESSION_H */
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSessionUtil.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSessionUtil.c
new file mode 100644
index 0000000000..f46cda9b7c
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSessionUtil.c
@@ -0,0 +1,491 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <pthread.h>
+#include <syslog.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+#include "kmsSession.h"
+#include "kmsSlot.h"
+#include "kmsKeystoreUtil.h"
+
+static pthread_mutex_t delete_sessions_mutex = PTHREAD_MUTEX_INITIALIZER;
+CK_ULONG kms_session_cnt = 0;
+CK_ULONG kms_session_rw_cnt = 0;
+
+/*
+ * Delete all the sessions. First, obtain the slot lock.
+ * Then start to delete one session at a time. The boolean wrapper_only
+ * argument indicates that whether the caller only wants to clean up the
+ * session wrappers and the object wrappers in the library.
+ * - When this function is called by C_CloseAllSessions or indirectly by
+ * C_Finalize, wrapper_only is FALSE.
+ * - When this function is called by cleanup_child, wrapper_only is TRUE.
+ */
+void
+kms_delete_all_sessions(boolean_t wrapper_only)
+{
+ kms_session_t *session_p;
+ kms_slot_t *pslot;
+
+ (void) pthread_mutex_lock(&delete_sessions_mutex);
+
+ pslot = get_slotinfo();
+
+ /*
+ * Delete all the sessions in the slot's session list.
+ * The routine kms_delete_session() updates the linked list.
+ * So, we do not need to maintain the list here.
+ */
+ for (;;) {
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ if (pslot->sl_sess_list == NULL)
+ break;
+
+ session_p = pslot->sl_sess_list;
+ /*
+ * Set SESSION_IS_CLOSING flag so any access to this
+ * session will be rejected.
+ */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ if (session_p->ses_close_sync & SESSION_IS_CLOSING) {
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ continue;
+ }
+ session_p->ses_close_sync |= SESSION_IS_CLOSING;
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ kms_delete_session(session_p, B_FALSE, wrapper_only);
+ }
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ (void) pthread_mutex_unlock(&delete_sessions_mutex);
+}
+
+static int
+labelcmp(const void *a, const void *b)
+{
+ objlabel_t *obja = (objlabel_t *)a;
+ objlabel_t *objb = (objlabel_t *)b;
+ int n;
+
+ if (obja == NULL || obja->label == NULL)
+ return (-1);
+ if (objb == NULL || objb->label == NULL)
+ return (1);
+
+ n = strcmp((char *)obja->label, (char *)objb->label);
+ if (n == 0)
+ return (0);
+ else if (n < 0)
+ return (-1);
+ return (1);
+}
+
+/*
+ * Create a new session struct, and add it to the slot's session list.
+ *
+ * This function is called by C_OpenSession(), which hold the slot lock.
+ */
+CK_RV
+kms_add_session(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication,
+ CK_NOTIFY notify, CK_ULONG *sessionhandle_p)
+{
+ kms_session_t *new_sp = NULL;
+ kms_slot_t *pslot;
+ CK_RV rv;
+
+ /* Allocate a new session struct */
+ new_sp = calloc(1, sizeof (kms_session_t));
+ if (new_sp == NULL) {
+ return (CKR_HOST_MEMORY);
+ }
+
+ new_sp->magic_marker = KMSTOKEN_SESSION_MAGIC;
+ new_sp->pApplication = pApplication;
+ new_sp->Notify = notify;
+ new_sp->flags = flags;
+ new_sp->ses_RO = (flags & CKF_RW_SESSION) ? B_FALSE : B_TRUE;
+ new_sp->ses_slotid = slotID;
+ new_sp->object_list = NULL;
+ new_sp->ses_refcnt = 0;
+ new_sp->ses_close_sync = 0;
+
+ avl_create(&new_sp->objlabel_tree, labelcmp, sizeof (objlabel_t),
+ KMSOFFSETOF(objlabel_t, nodep));
+
+ rv = kms_reload_labels(new_sp);
+ if (rv != CKR_OK) {
+ free(new_sp);
+ return (rv);
+ }
+
+ /* Initialize the lock for the newly created session */
+ if (pthread_mutex_init(&new_sp->session_mutex, NULL) != 0) {
+ free(new_sp);
+ return (CKR_CANT_LOCK);
+ }
+
+ pslot = get_slotinfo();
+
+ (void) pthread_mutex_init(&new_sp->ses_free_mutex, NULL);
+ (void) pthread_cond_init(&new_sp->ses_free_cond, NULL);
+
+ /* Insert the new session in front of the slot's session list */
+ if (pslot->sl_sess_list == NULL) {
+ pslot->sl_sess_list = new_sp;
+ new_sp->prev = NULL;
+ new_sp->next = NULL;
+ } else {
+ pslot->sl_sess_list->prev = new_sp;
+ new_sp->next = pslot->sl_sess_list;
+ new_sp->prev = NULL;
+ pslot->sl_sess_list = new_sp;
+ }
+
+ /* Type casting the address of a session struct to a session handle */
+ *sessionhandle_p = (CK_ULONG)new_sp;
+ return (CKR_OK);
+}
+
+/*
+ * Delete a session:
+ * - Remove the session from the slot's session list.
+ * - Release all the objects created by the session.
+ *
+ * The boolean argument slot_lock_held is used to indicate that whether
+ * the caller of this function holds the slot lock or not.
+ * - When called by kms_delete_all_sessions(), which is called by
+ * C_Finalize() or C_CloseAllSessions() -- slot_lock_held = TRUE.
+ * - When called by C_CloseSession() -- slot_lock_held = FALSE.
+ */
+void
+kms_delete_session(kms_session_t *session_p,
+ boolean_t slot_lock_held, boolean_t wrapper_only)
+{
+ kms_slot_t *pslot;
+ kms_object_t *objp;
+ kms_object_t *objp1;
+
+ /*
+ * Check to see if the caller holds the lock on the global
+ * session list. If not, we need to acquire that lock in
+ * order to proceed.
+ */
+ pslot = get_slotinfo();
+ if (!slot_lock_held) {
+ /* Acquire the slot lock */
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ }
+
+ /*
+ * Remove the session from the slot's session list first.
+ */
+ if (pslot->sl_sess_list == session_p) {
+ /* Session is the first one in the list */
+ if (session_p->next) {
+ pslot->sl_sess_list = session_p->next;
+ session_p->next->prev = NULL;
+ } else {
+ /* Session is the only one in the list */
+ pslot->sl_sess_list = NULL;
+ }
+ } else {
+ /* Session is not the first one in the list */
+ if (session_p->next) {
+ /* Session is in the middle of the list */
+ session_p->prev->next = session_p->next;
+ session_p->next->prev = session_p->prev;
+ } else {
+ /* Session is the last one in the list */
+ session_p->prev->next = NULL;
+ }
+ }
+
+ if (!slot_lock_held) {
+ /*
+ * If the slot lock is obtained by
+ * this function, then release that lock after
+ * removing the session from session linked list.
+ * We want the releasing of the objects of the
+ * session, and freeing of the session itself to
+ * be done without holding the slot's session list
+ * lock.
+ */
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ }
+
+ /* Acquire the individual session lock */
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+
+ /*
+ * Make sure another thread hasn't freed the session.
+ */
+ if (session_p->magic_marker != KMSTOKEN_SESSION_MAGIC) {
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ return;
+ }
+
+ /*
+ * The deletion of a session must be blocked when the session reference
+ * count is not zero. This means that if the thread that is attempting
+ * to close the session must wait until the prior operations on this
+ * session are finished.
+ *
+ * Unless we are being forced to shut everything down, this only
+ * happens if the library's _fini() is running not if someone
+ * explicitly called C_Finalize().
+ */
+ (void) pthread_mutex_lock(&session_p->ses_free_mutex);
+
+ if (wrapper_only) {
+ session_p->ses_refcnt = 0;
+ }
+
+ while (session_p->ses_refcnt != 0) {
+ /*
+ * We set the SESSION_REFCNT_WAITING flag before we put
+ * this closing thread in a wait state, so other non-closing
+ * operation thread will wake it up only when
+ * the session reference count becomes zero and this flag
+ * is set.
+ */
+ session_p->ses_close_sync |= SESSION_REFCNT_WAITING;
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ (void) pthread_cond_wait(&session_p->ses_free_cond,
+ &session_p->ses_free_mutex);
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ }
+
+ session_p->ses_close_sync &= ~SESSION_REFCNT_WAITING;
+
+ /* Mark session as no longer valid. */
+ session_p->magic_marker = 0;
+
+ (void) pthread_mutex_unlock(&session_p->ses_free_mutex);
+ (void) pthread_mutex_destroy(&session_p->ses_free_mutex);
+ (void) pthread_cond_destroy(&session_p->ses_free_cond);
+
+ /*
+ * Remove all the objects created in this session, waiting
+ * until each object's refcnt is 0.
+ */
+ kms_delete_all_objects_in_session(session_p, wrapper_only);
+
+ /* Close the KMS agent profile. */
+ KMS_UnloadProfile(&session_p->kmsProfile);
+
+ /* Reset SESSION_IS_CLOSING flag. */
+ session_p->ses_close_sync &= ~SESSION_IS_CLOSING;
+
+ kms_clear_label_list(&session_p->objlabel_tree);
+ avl_destroy(&session_p->objlabel_tree);
+
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ /* Destroy the individual session lock */
+ (void) pthread_mutex_destroy(&session_p->session_mutex);
+
+ kms_session_delay_free(session_p);
+
+ /*
+ * If there is no more session remained in this slot, reset the slot's
+ * session state to CKU_PUBLIC. Also, clean up all the token object
+ * wrappers in the library for this slot.
+ */
+ /* Acquire the slot lock if lock is not held */
+ if (!slot_lock_held) {
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+ }
+
+ if (pslot->sl_sess_list == NULL) {
+ /* Reset the session auth state. */
+ pslot->sl_state = CKU_PUBLIC;
+
+ /* Clean up token object wrappers. */
+ objp = pslot->sl_tobj_list;
+ while (objp) {
+ objp1 = objp->next;
+ (void) pthread_mutex_destroy(&objp->object_mutex);
+ (void) kms_cleanup_object(objp);
+ free(objp);
+ objp = objp1;
+ }
+ pslot->sl_tobj_list = NULL;
+ }
+
+ /* Release the slot lock if lock is not held */
+ if (!slot_lock_held) {
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ }
+}
+
+/*
+ * This function is used to type cast a session handle to a pointer to
+ * the session struct. Also, it does the following things:
+ * 1) Check to see if the session struct is tagged with a session
+ * magic number. This is to detect when an application passes
+ * a bogus session pointer.
+ * 2) Acquire the locks on the designated session.
+ * 3) Check to see if the session is in the closing state that another
+ * thread is performing.
+ * 4) Increment the session reference count by one. This is to prevent
+ * this session from being closed by other thread.
+ * 5) Release the locks on the designated session.
+ */
+CK_RV
+handle2session(CK_SESSION_HANDLE hSession, kms_session_t **session_p)
+{
+ kms_session_t *sp = (kms_session_t *)(hSession);
+ CK_RV rv;
+
+ if ((sp == NULL) ||
+ (sp->magic_marker != KMSTOKEN_SESSION_MAGIC)) {
+ return (CKR_SESSION_HANDLE_INVALID);
+ } else {
+ (void) pthread_mutex_lock(&sp->session_mutex);
+ if (sp->ses_close_sync & SESSION_IS_CLOSING) {
+ rv = CKR_SESSION_CLOSED;
+ } else {
+ /* Increment session ref count. */
+ sp->ses_refcnt++;
+ rv = CKR_OK;
+ }
+ (void) pthread_mutex_unlock(&sp->session_mutex);
+ }
+
+ if (rv == CKR_OK)
+ *session_p = sp;
+
+ return (rv);
+}
+
+/*
+ * This function adds the to-be-freed session to a linked list.
+ * When the number of sessions queued in the linked list reaches the
+ * maximum threshold MAX_SES_TO_BE_FREED, it will free the first
+ * session (FIFO) in the list.
+ */
+void
+kms_session_delay_free(kms_session_t *sp)
+{
+ kms_session_t *tmp;
+
+ (void) pthread_mutex_lock(&ses_delay_freed.ses_to_be_free_mutex);
+
+ /* Add the newly deleted session at the end of the list */
+ sp->next = NULL;
+ if (ses_delay_freed.first == NULL) {
+ ses_delay_freed.last = sp;
+ ses_delay_freed.first = sp;
+ } else {
+ ses_delay_freed.last->next = sp;
+ ses_delay_freed.last = sp;
+ }
+
+ if (++ses_delay_freed.count >= MAX_SES_TO_BE_FREED) {
+ /*
+ * Free the first session in the list only if
+ * the total count reaches maximum threshold.
+ */
+ ses_delay_freed.count--;
+ tmp = ses_delay_freed.first->next;
+ free(ses_delay_freed.first);
+ ses_delay_freed.first = tmp;
+ }
+ (void) pthread_mutex_unlock(&ses_delay_freed.ses_to_be_free_mutex);
+}
+
+/*
+ * Acquire all slots' mutexes and all their sessions' mutexes.
+ * Order:
+ * 1. delete_sessions_mutex
+ * for each slot:
+ * 2. pslot->sl_mutex
+ * for each session:
+ * 3. session_p->session_mutex
+ * 4. session_p->ses_free_mutex
+ */
+void
+kms_acquire_all_slots_mutexes()
+{
+ kms_slot_t *pslot;
+ kms_session_t *session_p;
+
+ (void) pthread_mutex_lock(&delete_sessions_mutex);
+
+ pslot = get_slotinfo();
+ (void) pthread_mutex_lock(&pslot->sl_mutex);
+
+ /* Iterate through sessions acquiring all mutexes */
+ session_p = pslot->sl_sess_list;
+ while (session_p) {
+ struct object *objp;
+
+ (void) pthread_mutex_lock(&session_p->session_mutex);
+ (void) pthread_mutex_lock(&session_p->ses_free_mutex);
+
+ objp = session_p->object_list;
+ while (objp) {
+ (void) pthread_mutex_lock(&objp->object_mutex);
+ objp = objp->next;
+ }
+
+ session_p = session_p->next;
+ }
+}
+
+/* Release in opposite order to kms_acquire_all_slots_mutexes(). */
+void
+kms_release_all_slots_mutexes()
+{
+ kms_slot_t *pslot;
+ kms_session_t *session_p;
+
+ pslot = get_slotinfo();
+
+ /* Iterate through sessions releasing all mutexes */
+ session_p = pslot->sl_sess_list;
+ while (session_p) {
+ struct object *objp;
+
+ objp = session_p->object_list;
+ while (objp) {
+ (void) pthread_mutex_unlock(&objp->object_mutex);
+ objp = objp->next;
+ }
+
+ (void) pthread_mutex_unlock(&session_p->ses_free_mutex);
+ (void) pthread_mutex_unlock(&session_p->session_mutex);
+ session_p = session_p->next;
+ }
+
+ /*
+ * acquired in "acquire_all_slots_mutexes" which only
+ * happens just prior to a fork.
+ */
+ (void) pthread_mutex_unlock(&pslot->sl_mutex);
+ (void) pthread_mutex_unlock(&delete_sessions_mutex);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSign.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSign.c
new file mode 100644
index 0000000000..9e2fe28784
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSign.c
@@ -0,0 +1,92 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+
+/*ARGSUSED*/
+CK_RV
+C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_Sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
+ CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+
+/*ARGSUSED*/
+CK_RV
+C_SignUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
+ CK_ULONG ulPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_SignFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
+ CK_ULONG_PTR pulSignatureLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_SignRecoverInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+
+}
+
+/*ARGSUSED*/
+CK_RV
+C_SignRecover(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
+ CK_ULONG ulDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlot.h b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlot.h
new file mode 100644
index 0000000000..f1bb38f3d1
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlot.h
@@ -0,0 +1,63 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef _KMS_SLOT_H
+#define _KMS_SLOT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "kmsSession.h"
+
+#define CKU_PUBLIC 2 /* default session auth. state */
+
+typedef struct kms_slot {
+ CK_SLOT_ID sl_provider_id; /* kernel provider ID */
+ kms_session_t *sl_sess_list; /* all open sessions */
+ CK_USER_TYPE sl_state; /* session's auth. state */
+ struct object *sl_tobj_list; /* token object list */
+ pthread_mutex_t sl_mutex;
+
+ /*
+ * The valid values are defined above.
+ */
+ uint32_t sl_flags;
+ int total_threshold_count;
+} kms_slot_t;
+
+#define KMS_TOKEN_SLOTID 1
+#define KMS_SLOTS 1
+
+/*
+ * Function Prototypes.
+ */
+CK_RV kms_slottable_init();
+void cleanup_slottable();
+kms_slot_t *get_slotinfo();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _KMS_SLOT_H */
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlotToken.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlotToken.c
new file mode 100644
index 0000000000..0ee47521f0
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlotToken.c
@@ -0,0 +1,386 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+
+#include <stdlib.h>
+#include <strings.h>
+#include <security/cryptoki.h>
+#include <cryptoutil.h>
+#include <errno.h>
+#include <aes_impl.h>
+
+#include "kmsGlobal.h"
+#include "kmsSlot.h"
+#include "kmsKeystoreUtil.h"
+
+/*
+ * Just basic AES mechanisms (for now...)
+ */
+static CK_MECHANISM_TYPE kms_mechanisms[] = {
+ CKM_AES_KEY_GEN,
+ CKM_AES_CBC,
+ CKM_AES_CBC_PAD
+};
+
+/*
+ * KMS only supports 256 bit keys, so the range below is MAX-MAX
+ * instead of MIN-MAX.
+ */
+static CK_MECHANISM_INFO kms_mechanism_info[] = {
+ {AES_MAX_KEY_BYTES, AES_MAX_KEY_BYTES, CKF_GENERATE},
+ {AES_MAX_KEY_BYTES, AES_MAX_KEY_BYTES, CKF_ENCRYPT|CKF_DECRYPT|
+ CKF_WRAP|CKF_UNWRAP}, /* CKM_AES_CBC */
+ {AES_MAX_KEY_BYTES, AES_MAX_KEY_BYTES, CKF_ENCRYPT|CKF_DECRYPT|
+ CKF_WRAP|CKF_UNWRAP} /* CKM_AES_CBC_PAD */
+};
+
+/* ARGSUSED */
+CK_RV
+C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList,
+ CK_ULONG_PTR pulCount)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (pulCount == NULL) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ /*
+ * If KMS is not available or initialized, return 0 slots
+ * but CKR_OK status.
+ */
+ if (!kms_is_initialized()) {
+ *pulCount = 0;
+ return (CKR_OK);
+ }
+
+ if (pSlotList == NULL) {
+ *pulCount = KMS_SLOTS;
+ return (CKR_OK);
+ }
+
+ if (*pulCount < KMS_SLOTS) {
+ *pulCount = KMS_SLOTS;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+
+ *pulCount = 1;
+ pSlotList[0] = KMS_TOKEN_SLOTID;
+
+ return (CKR_OK);
+}
+
+CK_RV
+C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (slotID != KMS_TOKEN_SLOTID ||
+ !kms_is_initialized()) {
+ return (CKR_SLOT_ID_INVALID);
+ }
+
+ if (pInfo == NULL)
+ return (CKR_ARGUMENTS_BAD);
+
+ /* Provide information about the slot in the provided buffer */
+ (void) strncpy((char *)pInfo->slotDescription, SLOT_DESCRIPTION,
+ 64);
+ (void) strncpy((char *)pInfo->manufacturerID, MANUFACTURER_ID, 32);
+ pInfo->flags = CKF_TOKEN_PRESENT;
+ pInfo->hardwareVersion.major = HARDWARE_VERSION_MAJOR;
+ pInfo->hardwareVersion.minor = HARDWARE_VERSION_MINOR;
+ pInfo->firmwareVersion.major = FIRMWARE_VERSION_MAJOR;
+ pInfo->firmwareVersion.minor = FIRMWARE_VERSION_MINOR;
+
+ return (CKR_OK);
+}
+
+CK_RV
+C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo)
+{
+ kms_cfg_info_t kmscfg;
+ KMSAGENT_PROFILE_FLAGS kmsflags = 0;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (slotID != KMS_TOKEN_SLOTID ||
+ !kms_is_initialized())
+ return (CKR_SLOT_ID_INVALID);
+
+ if (pInfo == NULL)
+ return (CKR_ARGUMENTS_BAD);
+
+ /* Provide information about a token in the provided buffer */
+ (void) strncpy((char *)pInfo->label, KMS_TOKEN_LABEL, 32);
+ (void) strncpy((char *)pInfo->manufacturerID, MANUFACTURER_ID, 32);
+ (void) strncpy((char *)pInfo->model, KMS_TOKEN_MODEL, 16);
+ (void) strncpy((char *)pInfo->serialNumber, KMS_TOKEN_SERIAL, 16);
+
+ pInfo->flags = KMS_TOKEN_FLAGS;
+ pInfo->ulMaxSessionCount = CK_EFFECTIVELY_INFINITE;
+ pInfo->ulSessionCount = kms_session_cnt;
+ pInfo->ulMaxRwSessionCount = CK_EFFECTIVELY_INFINITE;
+ pInfo->ulRwSessionCount = kms_session_rw_cnt;
+ pInfo->ulMaxPinLen = MAX_PIN_LEN;
+ pInfo->ulMinPinLen = MIN_PIN_LEN;
+ pInfo->ulTotalPublicMemory = CK_UNAVAILABLE_INFORMATION;
+ pInfo->ulFreePublicMemory = CK_UNAVAILABLE_INFORMATION;
+ pInfo->ulTotalPrivateMemory = CK_UNAVAILABLE_INFORMATION;
+ pInfo->ulFreePrivateMemory = CK_UNAVAILABLE_INFORMATION;
+ pInfo->hardwareVersion.major = HARDWARE_VERSION_MAJOR;
+ pInfo->hardwareVersion.minor = HARDWARE_VERSION_MINOR;
+ pInfo->firmwareVersion.major = FIRMWARE_VERSION_MAJOR;
+ pInfo->firmwareVersion.minor = FIRMWARE_VERSION_MINOR;
+ (void) memset(pInfo->utcTime, ' ', 16);
+
+ if (KMS_GetConfigInfo(&kmscfg) == CKR_OK &&
+ KMSAgent_GetProfileStatus(kmscfg.name, &kmsflags) ==
+ KMS_AGENT_STATUS_OK) {
+
+ if ((kmsflags & KMSAGENT_PROFILE_EXISTS_FLAG) &&
+ (kmsflags & KMSAGENT_CLIENTKEY_EXISTS_FLAG))
+ pInfo->flags |= CKF_TOKEN_INITIALIZED;
+ else
+ pInfo->flags &= ~CKF_TOKEN_INITIALIZED;
+ }
+ return (CKR_OK);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+
+CK_RV
+C_GetMechanismList(CK_SLOT_ID slotID,
+ CK_MECHANISM_TYPE_PTR pMechanismList,
+ CK_ULONG_PTR pulCount)
+{
+ int i;
+ ulong_t mechnum;
+
+ /*
+ * Just check to see if the library has been
+ * properly initialized.
+ */
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * This is different from above check, this verifies that
+ * the KMS token is actually configured.
+ */
+ if (slotID != KMS_TOKEN_SLOTID ||
+ !kms_is_initialized())
+ return (CKR_SLOT_ID_INVALID);
+
+ mechnum = sizeof (kms_mechanisms) / sizeof (CK_MECHANISM_TYPE);
+ if (pMechanismList == NULL) {
+ *pulCount = mechnum;
+ return (CKR_OK);
+ }
+ if (*pulCount < mechnum) {
+ *pulCount = mechnum;
+ return (CKR_BUFFER_TOO_SMALL);
+ }
+ for (i = 0; i < mechnum; i++)
+ pMechanismList[i] = kms_mechanisms[i];
+
+ *pulCount = mechnum;
+
+ return (CKR_OK);
+}
+
+CK_RV
+C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type,
+ CK_MECHANISM_INFO_PTR pInfo)
+{
+ CK_ULONG mechnum, i;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (slotID != KMS_TOKEN_SLOTID ||
+ !kms_is_initialized())
+ return (CKR_SLOT_ID_INVALID);
+
+ if (pInfo == NULL) {
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ mechnum = sizeof (kms_mechanisms) / sizeof (CK_MECHANISM_TYPE);
+ for (i = 0; i < mechnum; i++) {
+ if (kms_mechanisms[i] == type)
+ break;
+ }
+
+ if (i == mechnum)
+ /* unsupported mechanism */
+ return (CKR_MECHANISM_INVALID);
+
+ pInfo->ulMinKeySize = kms_mechanism_info[i].ulMinKeySize;
+ pInfo->ulMaxKeySize = kms_mechanism_info[i].ulMaxKeySize;
+ pInfo->flags = kms_mechanism_info[i].flags;
+
+ return (CKR_OK);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_InitToken(CK_SLOT_ID slotID, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen,
+ CK_UTF8CHAR_PTR pLabel)
+{
+ CK_RV rv = CKR_FUNCTION_FAILED;
+ kms_cfg_info_t kmscfg;
+ KMSAGENT_PROFILE_FLAGS kmsflags;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ if (slotID != KMS_TOKEN_SLOTID ||
+ !kms_is_initialized())
+ return (CKR_SLOT_ID_INVALID);
+
+ if (KMS_GetConfigInfo(&kmscfg) != CKR_OK ||
+ KMSAgent_GetProfileStatus(kmscfg.name, &kmsflags) !=
+ KMS_AGENT_STATUS_OK)
+ return (CKR_FUNCTION_FAILED);
+
+ if (!(kmsflags & KMSAGENT_PROFILE_EXISTS_FLAG) ||
+ !(kmsflags & KMSAGENT_CLIENTKEY_EXISTS_FLAG)) {
+ KMSClientProfile kmsProfile;
+ /*
+ * Attempt to enroll and load a KMS profile.
+ * This will force the KMSAgent library to fetch
+ * the profile, the CA certificate, and the
+ * client private key and store them locally so that
+ * the KMS agent API can be used later.
+ */
+ rv = KMS_LoadProfile(
+ &kmsProfile,
+ &kmscfg,
+ (const char *)pPin,
+ (size_t)ulPinLen);
+
+ if (rv == CKR_OK)
+ KMS_UnloadProfile(&kmsProfile);
+ }
+ return (rv);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_InitPIN(CK_SESSION_HANDLE hSession, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * Could be supported once the agent library supports
+ * storing the client certificate in a PKCS#12 file.
+ */
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+CK_RV
+C_SetPIN(CK_SESSION_HANDLE hSession, CK_UTF8CHAR_PTR pOldPin,
+ CK_ULONG ulOldLen, CK_UTF8CHAR_PTR pNewPin, CK_ULONG ulNewLen)
+{
+ CK_RV rv = CKR_OK;
+ kms_session_t *session_p;
+ boolean_t ses_lock_held = B_FALSE;
+
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ /*
+ * Obtain the session pointer. Also, increment the session
+ * reference count.
+ */
+ rv = handle2session(hSession, &session_p);
+ if (rv != CKR_OK)
+ return (rv);
+
+ /* Make sure it is a RW session. */
+ if (session_p->ses_RO) {
+ rv = CKR_SESSION_READ_ONLY;
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+ }
+
+ /*
+ * If the token is not yet initialized, we cannot set the pin.
+ */
+ if (!kms_is_initialized()) {
+ REFRELE(session_p, ses_lock_held);
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ if (pOldPin == NULL || ulOldLen == 0 ||
+ pNewPin == NULL || ulNewLen == 0) {
+ REFRELE(session_p, ses_lock_held);
+ return (CKR_ARGUMENTS_BAD);
+ }
+
+ if (!kms_is_pin_set()) {
+ /*
+ * We don't yet support this mode since
+ * the KMS private key file will automatically
+ * be generated using the KMS Agent passphrase
+ * which is initialized out-of-band.
+ */
+ rv = CKR_FUNCTION_NOT_SUPPORTED;
+
+ } else {
+ /*
+ * Login to KMS by attempting to load the profile using
+ * the given password.
+ */
+ rv = KMS_LoadProfile(&session_p->kmsProfile,
+ &session_p->configInfo,
+ (const char *)pOldPin,
+ (size_t)ulOldLen);
+ if (rv == CKR_USER_ANOTHER_ALREADY_LOGGED_IN)
+ rv = CKR_OK;
+
+ if (rv == CKR_OK)
+ rv = KMS_ChangeLocalPWD(session_p,
+ (const char *)pOldPin,
+ (const char *)pNewPin);
+ }
+
+ REFRELE(session_p, ses_lock_held);
+ return (rv);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlottable.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlottable.c
new file mode 100644
index 0000000000..c34954dc51
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsSlottable.c
@@ -0,0 +1,77 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <errno.h>
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+#include "kmsSlot.h"
+
+static kms_slot_t *slotinfo = NULL;
+
+/*
+ * Initialize the slotinfo record.
+ *
+ * This function is called from C_Initialize() only. Since C_Initialize()
+ * holds the global mutex lock, there is no need to acquire another lock
+ * in this routine to protect the slot table.
+ */
+CK_RV
+kms_slottable_init()
+{
+ CK_RV rv = CKR_OK;
+
+ /* Allocate space for the slot table */
+ slotinfo = calloc(KMS_SLOTS, sizeof (kms_slot_t));
+ if (slotinfo == NULL)
+ return (CKR_HOST_MEMORY);
+
+ slotinfo->sl_sess_list = NULL;
+ slotinfo->sl_tobj_list = NULL;
+ slotinfo->sl_state = CKU_PUBLIC;
+
+ /* Initialize this slot's mutex */
+ if (pthread_mutex_init(&slotinfo->sl_mutex, NULL) != 0) {
+ (void) free(slotinfo);
+ slotinfo = NULL;
+ return (CKR_FUNCTION_FAILED);
+ }
+
+ return (rv);
+}
+
+void
+cleanup_slottable()
+{
+ if (slotinfo != NULL) {
+ (void) pthread_mutex_destroy(&slotinfo->sl_mutex);
+ (void) free(slotinfo);
+ slotinfo = NULL;
+ }
+}
+
+kms_slot_t *
+get_slotinfo()
+{
+ return (slotinfo);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/kmsVerify.c b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsVerify.c
new file mode 100644
index 0000000000..64db49c9a3
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/kmsVerify.c
@@ -0,0 +1,91 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <security/cryptoki.h>
+#include "kmsGlobal.h"
+
+/*ARGSUSED*/
+CK_RV
+C_VerifyInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_Verify(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
+ CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_VerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
+ CK_ULONG ulPartLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_VerifyFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
+ CK_ULONG ulSignatureLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_VerifyRecoverInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
+ CK_OBJECT_HANDLE hKey)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
+
+/*ARGSUSED*/
+CK_RV
+C_VerifyRecover(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
+ CK_ULONG ulSignatureLen, CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen)
+{
+ if (!kms_initialized)
+ return (CKR_CRYPTOKI_NOT_INITIALIZED);
+
+ return (CKR_FUNCTION_NOT_SUPPORTED);
+}
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/common/mapfile-vers b/usr/src/lib/pkcs11/pkcs11_kms/common/mapfile-vers
new file mode 100644
index 0000000000..a66e3742f7
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/common/mapfile-vers
@@ -0,0 +1,98 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION SUNW_1.1 {
+ global:
+ C_CancelFunction;
+ C_CloseAllSessions;
+ C_CloseSession;
+ C_CopyObject;
+ C_CreateObject;
+ C_Decrypt;
+ C_DecryptDigestUpdate;
+ C_DecryptFinal;
+ C_DecryptInit;
+ C_DecryptUpdate;
+ C_DecryptVerifyUpdate;
+ C_DeriveKey;
+ C_DestroyObject;
+ C_Digest;
+ C_DigestEncryptUpdate;
+ C_DigestFinal;
+ C_DigestInit;
+ C_DigestKey;
+ C_DigestUpdate;
+ C_Encrypt;
+ C_EncryptFinal;
+ C_EncryptInit;
+ C_EncryptUpdate;
+ C_Finalize;
+ C_FindObjects;
+ C_FindObjectsFinal;
+ C_FindObjectsInit;
+ C_GenerateKey;
+ C_GenerateKeyPair;
+ C_GenerateRandom;
+ C_GetAttributeValue;
+ C_GetFunctionList;
+ C_GetFunctionStatus;
+ C_GetInfo;
+ C_GetMechanismInfo;
+ C_GetMechanismList;
+ C_GetObjectSize;
+ C_GetOperationState;
+ C_GetSessionInfo;
+ C_GetSlotInfo;
+ C_GetSlotList;
+ C_GetTokenInfo;
+ C_Initialize;
+ C_InitPIN;
+ C_InitToken;
+ C_Login;
+ C_Logout;
+ C_OpenSession;
+ C_SeedRandom;
+ C_SetAttributeValue;
+ C_SetOperationState;
+ C_SetPIN;
+ C_Sign;
+ C_SignEncryptUpdate;
+ C_SignFinal;
+ C_SignInit;
+ C_SignRecover;
+ C_SignRecoverInit;
+ C_SignUpdate;
+ C_UnwrapKey;
+ C_Verify;
+ C_VerifyFinal;
+ C_VerifyInit;
+ C_VerifyRecover;
+ C_VerifyRecoverInit;
+ C_VerifyUpdate;
+ C_WaitForSlotEvent;
+ C_WrapKey;
+ local:
+ *;
+};
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/i386/Makefile b/usr/src/lib/pkcs11/pkcs11_kms/i386/Makefile
new file mode 100644
index 0000000000..5b0478c540
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/i386/Makefile
@@ -0,0 +1,29 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/sparc/Makefile b/usr/src/lib/pkcs11/pkcs11_kms/sparc/Makefile
new file mode 100644
index 0000000000..f51825ef6c
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/sparc/Makefile
@@ -0,0 +1,27 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/pkcs11/pkcs11_kms/sparcv9/Makefile b/usr/src/lib/pkcs11/pkcs11_kms/sparcv9/Makefile
new file mode 100644
index 0000000000..99c7ac2351
--- /dev/null
+++ b/usr/src/lib/pkcs11/pkcs11_kms/sparcv9/Makefile
@@ -0,0 +1,36 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+
+include ../Makefile.com
+include ../../../Makefile.lib.64
+
+LINTCHECKFLAGS += -erroff=E_INCONS_ARG_DECL2 \
+ -erroff=E_INCONS_ARG_USED2 \
+ -erroff=E_INCONS_VAL_TYPE_DECL2 \
+ -erroff=E_INCONS_VAL_TYPE_USED2 \
+ -erroff=E_FUNC_DECL_VAR_ARG2
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/pkg/manifests/system-library-security-crypto-pkcs11_kms.mf b/usr/src/pkg/manifests/system-library-security-crypto-pkcs11_kms.mf
new file mode 100644
index 0000000000..663e337f1e
--- /dev/null
+++ b/usr/src/pkg/manifests/system-library-security-crypto-pkcs11_kms.mf
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+set name=pkg.fmri value=pkg:/system/library/security/crypto/pkcs11_kms@$(PKGVERS)
+set name=pkg.description \
+ value="PKCS#11 KMS Provider"
+set name=pkg.summary value="pkcs11_kms"
+set name=info.classification value=org.opensolaris.category.2010:System/Security/Crypto
+set name=variant.arch value=$(ARCH)
+set name=variant.opensolaris.zone value=global value=nonglobal
+dir path=usr group=sys
+dir path=usr/lib
+dir path=usr/lib/$(ARCH64)
+dir path=usr/lib/security
+dir path=usr/lib/security/$(ARCH64)
+dir path=usr/bin
+dir path=usr/share
+file path=usr/lib/$(ARCH64)/libkmsagent.so.1
+file path=usr/lib/security/$(ARCH64)/pkcs11_kms.so.1
+file path=usr/lib/libkmsagent.so.1
+file path=usr/lib/security/pkcs11_kms.so.1
+file path=usr/bin/kmscfg group=sys mode=0555
+license cr_Sun license=cr_Sun
+license lic_CDDL license=lic_CDDL
+license lib/libkmsagent/THIRDPARTYLICENSE \
+ license=lib/libkmsagent/THIRDPARTYLICENSE
+link path=usr/lib/security/$(ARCH64)/pkcs11_kms.so target=pkcs11_kms.so.1
+link path=usr/lib/security/pkcs11_kms.so target=pkcs11_kms.so.1
diff --git a/usr/src/tools/opensolaris/license-list b/usr/src/tools/opensolaris/license-list
index 0c87b1927d..e666fec819 100644
--- a/usr/src/tools/opensolaris/license-list
+++ b/usr/src/tools/opensolaris/license-list
@@ -90,6 +90,7 @@ usr/src/lib/libgss/THIRDPARTYLICENSE
usr/src/lib/libima/THIRDPARTYLICENSE
usr/src/lib/libinetutil/common/THIRDPARTYLICENSE
usr/src/lib/libkmf/THIRDPARTYLICENSE
+usr/src/lib/libkmsagent/THIRDPARTYLICENSE
usr/src/lib/libldap5/THIRDPARTYLICENSE
usr/src/lib/libmp/common/THIRDPARTYLICENSE
usr/src/lib/libntfs/THIRDPARTYLICENSE